-
Notifications
You must be signed in to change notification settings - Fork 27.5k
REGEX for Email Address validates with incomplete email addresses #10052
Comments
We have received many issues such as this. The issue you're having is, you (mistakenly) believe that a valid email address requires a top-level-domain label (at least one "." character in the portion of the email address following the "@"). This is in fact not correct, either in the RFC or in the recomendations of the WHATWG or W3C (see https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address or http://www.w3.org/TR/html-markup/input.email.html for details). You can easily write a custom validator to require a dot in the email domain label, but this does not match what is required by the specification, nor what web browsers do with native validation, so it does not seem appropriate that angular's email validator should do this. |
Thanks for the clarification. |
(There is also an example of how to overwrite the built-in validator in the Forms Guide.) |
Yes, an email address like "jslagle@math" is valid (for applications running INSIDE private domains). OUTSIDE such domains, the likes of "[email protected]" are required. |
How multiples email address validate? |
Is there a way to validate sub addresses with a + in between words and use a . in the address in any combination? Basically, the most liberal possible email validation in angular? |
When using the REGEX included in Angular for validating email addresses, it validates addresses without a finished domain (
user@domain
will validate the same as[email protected]
). Therefore an incomplete email address passes validation when it shouldn't.Steps to reproduce:
angular.js
, a<input type="email" required>
, and some form of validation using$error
or$invalid
. Example is below.user@domain
into the input field.Live Example on Plunkr
Code Example:
Current REGEX used:
Proposed REGEX change. This conforms to REGEX standard RFC 5322. Live Example:
I tried changing the EMAIL_REGEXP to the proposed value above but when I ran the test suite, I received the following error:
I am not knowledgeable enough about tests or Angular to figure out a fix that validates the test suite. Recommendations?
Thanks Angular team!!
The text was updated successfully, but these errors were encountered: