diff options
Diffstat (limited to 'client/src/app/shared/forms/form-validators/email.validator.ts')
-rw-r--r-- | client/src/app/shared/forms/form-validators/email.validator.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/client/src/app/shared/forms/form-validators/email.validator.ts b/client/src/app/shared/forms/form-validators/email.validator.ts new file mode 100644 index 000000000..6a2c3bdca --- /dev/null +++ b/client/src/app/shared/forms/form-validators/email.validator.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | import { FormControl } from '@angular/forms'; | ||
2 | |||
3 | export function validateEmail(c: FormControl) { | ||
4 | // Thanks to http://emailregex.com/ | ||
5 | /* tslint:disable */ | ||
6 | const EMAIL_REGEXP = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | ||
7 | |||
8 | return EMAIL_REGEXP.test(c.value) ? null : { | ||
9 | email: { | ||
10 | valid: false | ||
11 | } | ||
12 | }; | ||
13 | } | ||