Repository navigation
Conversation
There was a problem hiding this comment.
The doc itself looks good, but I'm concerned that most of it exists only in the file (although it is formatted for inclusion in AIO) -- There is the Validators.email() description, but no reference in that to make anyone go look at the file for more information.
Since the comments are formatted for processing by AIO, they are hard to read in the file..
|
You can preview 239ad95 at https://pr32961-239ad95.ngbuilds.io/. |
|
Thx for the review, @jbogarthyde! I addressed the comments (either by making the suggested changes or commenting back). PTAL Also, my thoughts/questions regarding #32961 (review):
The main points are also mentioned in the
We should generally not point people to the source code as a means of documentation. Looking at the source code is a great way to find out what the code does (although not well suited for less experienced developers), but when someone is looking at the documentation they probably want to read an explanation in prose. That said, for people that decide they do want to look at the source code (to find out more details), there is the "View source" button on the top right of the method description, which they can use to get to the From there, getting to the
Not sure what you mean 😕 |
|
Thanks for the changes @gkalpak! It looks like this PR needs a rebase, could you please help with rebase? I'll start presubmit after rebase as well, just to make sure RegExp change doesn't trigger any issues in g3. Thank you. |
Previously, there was no documentation of what `Validators.email()` expects as a valid e-mail address, making it difficult for people to determine whether it covers their requirements or not. Even more so that the used pattern slightly deviates from the [WHATWG version](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address). One's only option was to look at the source code and try to decipher the regexp pattern. This commit adds a high-level description of the validator and mentions its similarity to and differences from the WHATWG version. It also adds a brief explanation of the regexp's behavior and references for more information in the source code to provide more context to maintainers/users trying to understand the implementation in the future. Fixes angular#18985 Fixes angular#25186 Closes angular#32747
…arison with WHATWG version As mentioned in the previous commit, the regexp used by `Validators.email()` is a slightly enhanced version of the [WHATWG one](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address). This commit refactors the regexp (without changing its behavior) to make it more closely match the format of WHATWG version, so that it is easier for people to compare it against the WHATWG one and understand the differences. The main changes were: - Changing the order of characters/character classes inside `[...]`; e.g. `[A-Za-z]` --> `[a-zA-Z]` - Mark all groups as non-capturing (since we do not use the captured values); e.g. `(foo)` --> `(?:foo)` (This could theoretically also have a positive performance impact, but I suspect JavaScript engines are already optimizing away capturing groups when they are not used.)
239ad95 to
a651fae
Compare
|
Thanks for rebasing this PR @gkalpak! I've started VE presubmit and also a global VE run (to make sure RegExp change doesn't affect any targets). Will keep you updated. Thank you. |
|
FYI, VE presubmits (including global one) are successful. Thank you. |
…arison with WHATWG version (#32961) As mentioned in the previous commit, the regexp used by `Validators.email()` is a slightly enhanced version of the [WHATWG one](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address). This commit refactors the regexp (without changing its behavior) to make it more closely match the format of WHATWG version, so that it is easier for people to compare it against the WHATWG one and understand the differences. The main changes were: - Changing the order of characters/character classes inside `[...]`; e.g. `[A-Za-z]` --> `[a-zA-Z]` - Mark all groups as non-capturing (since we do not use the captured values); e.g. `(foo)` --> `(?:foo)` (This could theoretically also have a positive performance impact, but I suspect JavaScript engines are already optimizing away capturing groups when they are not used.) PR Close #32961
Previously, there was no documentation of what `Validators.email()` expects as a valid e-mail address, making it difficult for people to determine whether it covers their requirements or not. Even more so that the used pattern slightly deviates from the [WHATWG version](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address). One's only option was to look at the source code and try to decipher the regexp pattern. This commit adds a high-level description of the validator and mentions its similarity to and differences from the WHATWG version. It also adds a brief explanation of the regexp's behavior and references for more information in the source code to provide more context to maintainers/users trying to understand the implementation in the future. Fixes #18985 Fixes #25186 Closes #32747 PR Close #32961
…arison with WHATWG version (#32961) As mentioned in the previous commit, the regexp used by `Validators.email()` is a slightly enhanced version of the [WHATWG one](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address). This commit refactors the regexp (without changing its behavior) to make it more closely match the format of WHATWG version, so that it is easier for people to compare it against the WHATWG one and understand the differences. The main changes were: - Changing the order of characters/character classes inside `[...]`; e.g. `[A-Za-z]` --> `[a-zA-Z]` - Mark all groups as non-capturing (since we do not use the captured values); e.g. `(foo)` --> `(?:foo)` (This could theoretically also have a positive performance impact, but I suspect JavaScript engines are already optimizing away capturing groups when they are not used.) PR Close #32961
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |

Previously, there was no documentation of what
Validators.email()expects as a valid e-mail address, making it difficult for people to determine whether it covers their requirements or not. Even more so that the used pattern slightly deviates from the WHATWG version. One's only option was to look at the source code and try to decipher the regexp pattern.This PR adds a high-level description of the validator and mentions its similarity to and differences from the WHATWG version. It also adds a brief explanation of the regexp's behavior and references for more information in the source code to provide more context to maintainers/users trying to understand the implementation in the future.
Finally, this PR also refactors `EMAIL_REGEXP (without changing its behavior) to make it more closely match the format of WHATWG version, so that it is easier for people to compare it against the WHATWG one and understand the differences.
Fixes #18985, fixes #25186, closes #32747.