Validators.email should allow null/empty values
See original GitHub issueI’m submitting a … (check one with “x”)
[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior Controls using the email validator are invalid if no value is present.
Expected behavior The email validator should allow null/empty values.
Minimal reproduction of the problem with instructions http://plnkr.co/edit/tsQ3C5tg3ba9xYAWHdLO?p=preview
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
-
Angular version: 4.x.x
-
Browser: all
-
Language: all
Issue Analytics
- State:
- Created 6 years ago
- Reactions:47
- Comments:19 (4 by maintainers)
Top Results From Across the Web
Angular Validators.email allow null value - Stack Overflow
It's simply because the null /empty value will not match against the expected shape (regexp). This is the current regular expression used ...
Read more >[Solved]-Angular Validators.email allow null value-angular.js
It's simply because the null /empty value will not match against the expected shape (regexp). This is the current regular expression used with...
Read more >Validation - Laravel - The PHP Framework For Web Artisans
Because of this, you will often need to mark your "optional" request fields as nullable if you do not want the validator to...
Read more >JavaScript : HTML form - Checking for non empty - w3resource
The following function can be used to check whether the user has entered anything in a given field. Blank fields indicate two kinds...
Read more >validate.js
Important! One thing that is a bit unorthodox is that most validators will consider undefined values ( null and undefined ,) valid values....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

For reactive forms this validator works for me:
A workaround in template driven forms (set [email] to false, when value is empty. Ensure to initialize the model value with an empy string):
<input [(ngModel)]="model.email" [email]="model.email!==''">