feat(forms): add email validator (#13709)

Closes #13706

PR Close #13709
This commit is contained in:
Dzmitry Shylovich
2016-12-29 20:07:02 +03:00
committed by Miško Hevery
parent 00979838ef
commit d69717cf79
7 changed files with 120 additions and 2 deletions

View File

@ -64,6 +64,14 @@ export function main() {
() => expect(Validators.requiredTrue(new FormControl(true))).toBeNull());
});
describe('email', () => {
it('should error on invalid email',
() => expect(Validators.email(new FormControl('some text'))).toEqual({'email': true}));
it('should not error on valid email',
() => expect(Validators.email(new FormControl('test@gmail.com'))).toBeNull());
});
describe('minLength', () => {
it('should not error on an empty string',
() => { expect(Validators.minLength(2)(new FormControl(''))).toBeNull(); });