mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-01-15 05:58:52 +01:00
feat(register): add angular 2 form logic
This commit is contained in:
parent
2ba18109cd
commit
1a2512daaf
6 changed files with 84 additions and 15 deletions
14
src/app/theme/validators/email.validator.ts
Normal file
14
src/app/theme/validators/email.validator.ts
Normal 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
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
16
src/app/theme/validators/equalPasswords.validator.ts
Normal file
16
src/app/theme/validators/equalPasswords.validator.ts
Normal 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
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
2
src/app/theme/validators/index.ts
Normal file
2
src/app/theme/validators/index.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export * from './email.validator';
|
||||
export * from './equalPasswords.validator';
|
||||
Loading…
Add table
Add a link
Reference in a new issue