Skip to content

docs(forms): expand e-mail validation description - #32961

Closed
gkalpak wants to merge 3 commits into
angular:masterfrom
gkalpak:docs-forms-email-validator
Closed

gkalpak wants to merge 3 commits into
angular:masterfrom
gkalpak:docs-forms-email-validator

Conversation

@gkalpak

@gkalpak gkalpak commented Oct 2, 2019

Copy link
Copy Markdown
Member

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.

@gkalpak gkalpak added action: merge The PR is ready for merge by the caretaker comp: docs refactoring Issue that involves refactoring or code-cleanup area: forms target: patch This PR is targeted for the next patch release labels Oct 2, 2019
@gkalpak
gkalpak requested a review from a team October 2, 2019 13:28
@ngbot ngbot Bot modified the milestone: needsTriage Oct 2, 2019
@mary-poppins

Copy link
Copy Markdown

@atscott atscott added the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 2, 2019

@jbogarthyde jbogarthyde left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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..

Comment thread packages/forms/src/validators.ts Resolved
Comment thread packages/forms/src/validators.ts Resolved
Comment thread packages/forms/src/validators.ts Resolved
Comment thread packages/forms/src/validators.ts Resolved
Comment thread packages/forms/src/validators.ts Resolved
Comment thread packages/forms/src/validators.ts Resolved
Comment thread packages/forms/src/validators.ts Resolved
Comment thread packages/forms/src/validators.ts Resolved
Comment thread packages/forms/src/validators.ts Resolved
Comment thread packages/forms/src/validators.ts Resolved
Comment thread packages/forms/src/validators.ts Resolved
@gkalpak
gkalpak requested a review from jbogarthyde October 4, 2019 09:14
@mary-poppins

Copy link
Copy Markdown

@gkalpak

gkalpak commented Oct 4, 2019

Copy link
Copy Markdown
Member Author

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):

I'm concerned that most of it exists only in the file [...]

The main points are also mentioned in the Validators.email() description (which is part of the API docs). What info from the EMAIL_REGEXP comment you think would be useful in the API docs?

There is the Validators.email() description, but no reference in that to make anyone go look at the file for more information.

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 Validators.email() implementation:

view-method-source

From there, getting to the EMAIL_REGEXP is really trivial (for someone intending to look at the source code).

Since the comments are formatted for processing by AIO, they are hard to read in the file.

Not sure what you mean 😕
The comments are formatted in Markdown, which is supposed to be human-readable 😉 (It is also not specific to AIO - in fact that is how I format my comments in any project 😁)
What exactly are you finding confusing? What would you format the comment for better readability?

@AndrewKushnir

Copy link
Copy Markdown
Contributor

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.

@AndrewKushnir AndrewKushnir added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: presubmit The PR is in need of a google3 presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 4, 2019
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.)
@gkalpak
gkalpak force-pushed the docs-forms-email-validator branch from 239ad95 to a651fae Compare October 5, 2019 15:23
@gkalpak gkalpak removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Oct 5, 2019
@mary-poppins

Copy link
Copy Markdown

@AndrewKushnir

AndrewKushnir commented Oct 6, 2019 •

Copy link
Copy Markdown
Contributor

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.

@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label Oct 7, 2019
@AndrewKushnir

Copy link
Copy Markdown
Contributor

FYI, VE presubmits (including global one) are successful. Thank you.

@alxhub alxhub closed this in 3c2770b Oct 7, 2019
alxhub pushed a commit that referenced this pull request Oct 7, 2019
…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
alxhub pushed a commit that referenced this pull request Oct 7, 2019
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
alxhub pushed a commit that referenced this pull request Oct 7, 2019
…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
@gkalpak
gkalpak deleted the docs-forms-email-validator branch October 8, 2019 08:21
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Nov 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: forms cla: yes refactoring Issue that involves refactoring or code-cleanup target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is email validation outdated? Request additional Validators.email documentation details

6 participants