Client: use builtin email validator

pull/71/head
Chocobozzz 2017-04-16 19:52:06 +02:00
parent 16a31eb741
commit c689fcdca2
3 changed files with 1 additions and 17 deletions

View File

@ -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
}
};
}

View File

@ -1,4 +1,3 @@
export * from './email.validator';
export * from './host.validator';
export * from './user';
export * from './video-abuse';

View File

@ -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.',