From: Chocobozzz Date: Sun, 16 Apr 2017 17:52:06 +0000 (+0200) Subject: Client: use builtin email validator X-Git-Tag: v0.0.1-alpha~467 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c689fcdca23e8693b6b6386fff779f9330f7f1c4;p=oweals%2Fpeertube.git Client: use builtin email validator --- 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.',