Skip to content

Commit 90c9962

Browse files
committed
Contributed EmailAddress Scalar
1 parent 64615c9 commit 90c9962

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# EmailAddress — GraphQL Custom Scalar
2+
3+
Author - Juke-Duke
4+
5+
Date - 2023-02-06
6+
7+
This is a String-based Scalar.
8+
9+
**License and Copyright**
10+
11+
Copyright © GraphQL contributors. This specification is licensed under
12+
[OWFa 1.0](https://www.openwebfoundation.org/the-agreements/the-owf-1-0-agreements-granted-claims/owfa-1-0).
13+
14+
# Overview
15+
16+
This Scalar represents a valid electronic mail address using a simplified version of [RFC 5322](https://www.rfc-editor.org/rfc/rfc5322).
17+
18+
The format of an email address is `local@domain`, where the local part may consist of up to 64 UTF-8 characters, the domain part may consist of up to 255 UTF-8 characters, and the two parts are separated by an `@` sign.
19+
20+
Other formats, including using square-bracketed IP addresses in the domain part, and quoted-string local parts, are not supported for simplicity.
21+
22+
The local part may contain any of the following ASCII characters:
23+
- Uppercase and lowercase Latin letters `A` to `Z` and `a` to `z`
24+
- Digits `0` to `9`
25+
- Printable characters ``!#$%&'*+-/=?^_`{|}~``
26+
- Dot `.`, provided that it is not the first or last character and provided also that it does not appear consecutively
27+
28+
The domain part may contain any of the following ASCII characters:
29+
- Uppercase and lowercase Latin letters `A` to `Z` and `a` to `z`
30+
- Digits `0` to `9`, provided that top-level domain names are not all-numeric (.com, .net, .org, etc.)
31+
- Hyphen `-`, provided that it is not the first or last character
32+
33+
**Examples**
34+
35+
The general format is described in [RFC5322 Section 3.4.1](https://www.rfc-editor.org/rfc/rfc5322#section-3.4.1).
36+
These examples are taken from [WikiPedia](https://en.wikipedia.org/wiki/Email_address#Examples), which is also based off of [RFC5322 Section 3.4.1](https://www.rfc-editor.org/rfc/rfc5322#section-3.4.1).
37+
38+
These are valid eamples:
39+
40+
| String | Explanation |
41+
| ------------------------------------------------ | --------------------------------------------------------------------- |
42+
| `[email protected]` | An EmailAddress without any special characters. |
43+
| `[email protected]` | An EmailAddress with a dot inside the local part. |
44+
| `[email protected]` | An EmailAddress with dots and a plus sign inside the local part. |
45+
| `[email protected]` | An EmailAddress with a dot and hyphens inside the local part. |
46+
| `[email protected]` | An EmailAddress with hypehns inside the local part. |
47+
| `[email protected]` | An EmailAddress with a dot and plus signs inside the local part |
48+
| `[email protected]` | An EmailAddress with a single character in the local part. |
49+
| `[email protected]` | An EmailAddress with a hyphen in both the local and domain parts. |
50+
| `test/[email protected]` | An EmailAddress with a slash in the local part. |
51+
| `admin@mailserver1` | An EmailAddress with no top-level domain. This is highly discouraged. |
52+
| `[email protected]` | An EmailAddress with a dot in the domain part. |
53+
| `[email protected]` | An EmailAddress with a bang in the local part. |
54+
| `user%[email protected]` | An EmailAddress with a percent sign in the local part. |
55+
| `[email protected]` | An EmailAddress with a hyphen in the local part. |
56+
57+
These are invalid examples:
58+
| String | Explanation |
59+
| -------------------------------------------------------------------------------- | -------------------------------------------------------------- |
60+
| `Abc.example.com` | No `@` sign seperating the local and domain components. |
61+
| `A@b@[email protected]` | Only one is allowed to divide the local and domain components. |
62+
| `a"b(c)d,e:f;g<h>i[j\k][email protected]` | The local part contains invalid characters. |
63+
| `just"not"[email protected]` | Quotes are not allowed in the local component. |
64+
| `this is"not\[email protected]` | Spaces and backslashes are not allowed in the local component. |
65+
| `this\ still\"not\\[email protected]` | Spaces and backslashes are not allowed in the local component. |
66+
| `1234567890123456789012345678901234567890123456789012345678901234+x@example.com` | The local component is longer than 64 characters. |
67+
| `i_like_underscore@but_its_not_allowed_in_this_part.example.com` | Underscores are not allowed in the domain component. |
68+
| `QA[icon]CHOCOLATE[icon]@test.com` | Non UTF-8 characters are not allowed in the local component. |
69+
70+
71+
# Name
72+
73+
The recommended name is `EmailAddress`. Alternatives may be `Email`, `E-Mail`, `MailAddress`.
74+
75+
# Result
76+
77+
Every result must follow the valid String formats as described above.
78+
79+
# Input
80+
81+
Every input following the valid String formats as described above must be accepted.
82+
83+
# References
84+
85+
[RFC 5322](https://www.rfc-editor.org/rfc/rfc5322)
86+
87+
[RFC 6531](https://www.rfc-editor.org/rfc/rfc6531)
88+
89+
[Wikipedia](https://en.wikipedia.org/wiki/Email_address)

0 commit comments

Comments
 (0)