feat(register): add angular 2 form logic

This commit is contained in:
nixa 2016-06-16 12:50:49 +03:00
parent 2ba18109cd
commit 1a2512daaf
6 changed files with 84 additions and 15 deletions

View file

@ -0,0 +1,14 @@
import {Control} from '@angular/common';
export class EmailValidator {
public static validate(c: Control) {
let EMAIL_REGEXP = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;
return EMAIL_REGEXP.test(c.value) ? null : {
validateEmail: {
valid: false
}
};
}
}

View file

@ -0,0 +1,16 @@
import {Control, ControlGroup} from '@angular/common';
export class EqualPasswordsValidator {
public static validate(firstField, secondField) {
return (c: ControlGroup) => {
return (c.controls && c.controls[firstField].value == c.controls[secondField].value) ? null : {
passwordsEqual: {
valid: false
}
};
}
}
}

View file

@ -0,0 +1,2 @@
export * from './email.validator';
export * from './equalPasswords.validator';