-
Notifications
You must be signed in to change notification settings - Fork 9
Contributed EmailAddress Scalar #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Juke-Duke
wants to merge
16
commits into
graphql:main
Choose a base branch
from
Juke-Duke:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
90c9962
Contributed EmailAddress Scalar
Juke-Duke a92aff1
Grammer reformatting
Juke-Duke 71d1d32
Grammer reformatting
Juke-Duke 8dbbb8b
Grammer reformatting
Juke-Duke 2620e47
Invalid example for all numerical top level domain
Juke-Duke 4ff1753
Valid and Invalid example for top level domain
Juke-Duke c59a220
Reformatted
Juke-Duke 1dd80be
Grammer reformatting
Juke-Duke a6a4c7d
Removed double @ symbol
Juke-Duke e64684c
Grammer reformatting
Juke-Duke 4851bdc
Top level domain can not be all numeric
Juke-Duke 72ca51b
Top level domain example with number
Juke-Duke 09eca20
Added missing . to b2b top level domain example
Juke-Duke e1947bf
Reformatted
Juke-Duke 4936381
Provided regex that may be used for validation
Juke-Duke 95c6940
Refactored domain part and regex with explanation
Juke-Duke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# EmailAddress — GraphQL Custom Scalar | ||
|
||
Author - Juke-Duke | ||
|
||
Date - 2023-02-06 | ||
|
||
This is a String-based Scalar. | ||
|
||
**License and Copyright** | ||
|
||
Copyright © GraphQL contributors. This specification is licensed under | ||
[OWFa 1.0](https://www.openwebfoundation.org/the-agreements/the-owf-1-0-agreements-granted-claims/owfa-1-0). | ||
|
||
# Overview | ||
|
||
This Scalar represents a valid electronic mail address using a simplified version of [RFC 5322](https://www.rfc-editor.org/rfc/rfc5322). | ||
|
||
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 63 UTF-8 characters for the domain name and 63 UTF-8 characters for the top-level domain, and the two parts are separated by an `@` sign. | ||
|
||
Other formats, including using square-bracketed IP addresses in the domain part, and quoted-string local parts, are not supported for simplicity. | ||
|
||
The local component may contain any of the following ASCII characters: | ||
- Uppercase and lowercase Latin letters `A` to `Z` and `a` to `z`. | ||
- Digits `0` to `9`. | ||
- Printable characters ``!#$%&'*+-/=?^_`{|}~``. | ||
- Dot `.`, provided that it is not the first or last character and provided also that it does not appear consecutively. | ||
|
||
The domain component may contain any of the following ASCII characters: | ||
- Uppercase and lowercase Latin letters `A` to `Z` and `a` to `z`. | ||
- Digits `0` to `9`, provided that top-level domain names are non-all-numeric (.com, .net, .org, .b2b, etc.). | ||
- Hyphen `-`, provided that it is not the first or last character of the domain name. | ||
|
||
**Examples** | ||
|
||
The general format is described in [RFC5322 Section 3.4.1](https://www.rfc-editor.org/rfc/rfc5322#section-3.4.1). | ||
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). | ||
|
||
These are valid examples: | ||
|
||
| String | Explanation | | ||
| ------------------------------------------------ | ----------------------------------------------------------------- | | ||
| `[email protected]` | An EmailAddress without any special characters. | | ||
| `[email protected]` | An EmailAddress with a dot inside the local part. | | ||
| `[email protected]` | An EmailAddress with dots and a plus sign inside the local part. | | ||
| `[email protected]` | An EmailAddress with a dot and hyphens inside the local part. | | ||
| `[email protected]` | An EmailAddress with hyphens inside the local part. | | ||
| `[email protected]` | An EmailAddress with a dot and plus signs inside the local part | | ||
| `[email protected]` | An EmailAddress with a single character in the local part. | | ||
| `[email protected]` | An EmailAddress with a hyphen in both the local and domain parts. | | ||
| `test/[email protected]` | An EmailAddress with a slash in the local part. | | ||
| `[email protected]` | An EmailAddress with a dot in the domain part. | | ||
| `[email protected]` | An EmailAddress with a bang in the local part. | | ||
| `user%[email protected]` | An EmailAddress with a percent sign in the local part. | | ||
| `[email protected]` | An EmailAddress with a hyphen in the local part. | | ||
| `[email protected]` | An EmailAddress with a non-all-numerical top-level domain. | | ||
|
||
These are invalid examples: | ||
| String | Explanation | | ||
| -------------------------------------------------------------------------------- | ----------------------------------------------------------------- | | ||
| `Abc.example.com` | No `@` sign separating the local and domain components. | | ||
| `A@b@[email protected]` | Only one is allowed to divide the local and domain components. | | ||
| `a"b(c)d,e:f;g<h>i[j\k][email protected]` | The local part contains invalid characters. | | ||
| `just"not"[email protected]` | Quotes are not allowed in the local component. | | ||
| `this is"not\[email protected]` | Spaces and backslashes are not allowed in the local component. | | ||
| `this\ still\"not\\[email protected]` | Spaces and backslashes are not allowed in the local component. | | ||
| `1234567890123456789012345678901234567890123456789012345678901234+x@example.com` | The local component is longer than 64 characters. | | ||
| `i_like_underscore@but_its_not_allowed_in_this_part.example.com` | Underscores are not allowed in the domain component. | | ||
| `QA[icon]CHOCOLATE[icon]@test.com` | Non UTF-8 characters are not allowed in the local component. | | ||
| `[email protected]` | Top-level domains cannot be all numerical. | | ||
| `admin@mailserver1` | The top-level domain component is missing. | | ||
| `[email protected]` | The domain component can not have hyphes in the beginning or end. | | ||
|
||
This regex provided below follows the above examples: | ||
```regex | ||
^(?!\.)(?!.*\.\.)[a-zA-Z0-9!#$%&'*+-/=?^_`{|}~\.]{0,63}[^.]@(?!\-)[a-zA-Z0-9-]{0,62}[^-]\.(?![0-9]*$)[a-zA-Z0-9]{2,63}$ | ||
``` | ||
|
||
Regex Breakdown: | ||
- `^` Beginning of the string. | ||
- `(?!\.)(?!.*\.\.)` Look aheads that assert the local component does not start and contain consecutive dots. | ||
- `[a-zA-Z0-9!#$%&'*+-/=?^_`{|}~\.]` Asserts the local component may contain any of these characters. | ||
- `{0,63}` Asserts the length of the local component is between 1 and 64 characters inclusive. | ||
- `[^.]` Asserts that the local component does not end with a dot. | ||
- `@` Asserts that the local component is followed by an `@` sign. | ||
- `(?!\-)(?!.*\-\-)` Look aheads that assert the domain component name does not start or contain consecutive hyphens. | ||
- `[a-zA-Z0-9-]` Asserts the domain component name may contain any of these characters. | ||
- `{0,62}` Asserts the length of the domain component name is between 1 and 63 characters inclusive. | ||
- `[^-]` Asserts that the domain component name does not end with a hyphen. | ||
- `\.` Asserts that the domain component name is followed by a dot. | ||
- `(?![0-9]*$)` Look ahead that asserts the top-level domain does not only contain numbers. | ||
- `[a-zA-Z0-9]` Asserts the top-level domain may contain any of these characters. | ||
- `{2,63}` Asserts the length of the top-level domain is between 2 and 63 characters inclusive. | ||
- `$` End of the string. | ||
|
||
# Name | ||
|
||
The recommended name is `EmailAddress`. Alternatives may be `Email`, `E-Mail`, `MailAddress`. | ||
|
||
# Result | ||
|
||
Every result must follow the valid String formats as described above. | ||
|
||
# Input | ||
|
||
Every input following the valid String formats as described above must be accepted. | ||
|
||
# References | ||
|
||
[RFC 5322](https://www.rfc-editor.org/rfc/rfc5322) | ||
|
||
[RFC 6531](https://www.rfc-editor.org/rfc/rfc6531) | ||
|
||
[Wikipedia](https://en.wikipedia.org/wiki/Email_address) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.