From c689fcdca23e8693b6b6386fff779f9330f7f1c4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 16 Apr 2017 19:52:06 +0200 Subject: [PATCH] Client: use builtin email validator --- .../shared/forms/form-validators/email.validator.ts | 13 ------------- .../src/app/shared/forms/form-validators/index.ts | 1 - client/src/app/shared/forms/form-validators/user.ts | 4 +--- 3 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 client/src/app/shared/forms/form-validators/email.validator.ts diff --git a/client/src/app/shared/forms/form-validators/email.validator.ts b/client/src/app/shared/forms/form-validators/email.validator.ts deleted file mode 100644 index 6a2c3bdca..000000000 --- a/client/src/app/shared/forms/form-validators/email.validator.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { FormControl } from '@angular/forms'; - -export function validateEmail(c: FormControl) { - // Thanks to http://emailregex.com/ - /* tslint:disable */ - 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,}))$/; - - return EMAIL_REGEXP.test(c.value) ? null : { - email: { - valid: false - } - }; -} diff --git a/client/src/app/shared/forms/form-validators/index.ts b/client/src/app/shared/forms/form-validators/index.ts index 669411a54..ab7c2df31 100644 --- a/client/src/app/shared/forms/form-validators/index.ts +++ b/client/src/app/shared/forms/form-validators/index.ts @@ -1,4 +1,3 @@ -export * from './email.validator'; export * from './host.validator'; export * from './user'; export * from './video-abuse'; diff --git a/client/src/app/shared/forms/form-validators/user.ts b/client/src/app/shared/forms/form-validators/user.ts index 0ad0e2a4b..259d2b868 100644 --- a/client/src/app/shared/forms/form-validators/user.ts +++ b/client/src/app/shared/forms/form-validators/user.ts @@ -1,7 +1,5 @@ import { Validators } from '@angular/forms'; -import { validateEmail } from './email.validator'; - export const USER_USERNAME = { VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(20) ], MESSAGES: { @@ -11,7 +9,7 @@ export const USER_USERNAME = { } }; export const USER_EMAIL = { - VALIDATORS: [ Validators.required, validateEmail ], + VALIDATORS: [ Validators.required, Validators.email ], MESSAGES: { 'required': 'Email is required.', 'email': 'Email must be valid.', -- 2.25.1