fix(forms): make Validators.email support optional controls (#20869)
Bring email validator in line with other validators so that empty values are ignored. PR Close #20869
This commit is contained in:

committed by
Miško Hevery

parent
941e88ff79
commit
140e7c00d1
@ -159,6 +159,12 @@ import {map} from 'rxjs/operator/map';
|
||||
});
|
||||
|
||||
describe('email', () => {
|
||||
it('should not error on an empty string',
|
||||
() => expect(Validators.email(new FormControl(''))).toBeNull());
|
||||
|
||||
it('should not error on null',
|
||||
() => expect(Validators.email(new FormControl(null))).toBeNull());
|
||||
|
||||
it('should error on invalid email',
|
||||
() => expect(Validators.email(new FormControl('some text'))).toEqual({'email': true}));
|
||||
|
||||
|
Reference in New Issue
Block a user