Guest User

Untitled

a guest
Jan 27th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. FORM VALIDTION
  2. this.userform = this._formbuilder.group({
  3. first_name: [this.user.first_name, Validators.required],
  4. last_name: ['', Validators.required],
  5. username: ['', Validators.compose(
  6. [
  7. Validators.required,Validators.minLength(5)
  8. ]
  9. )],
  10. password: ['',Validators.compose([
  11. Validators.required,ValidationService.passwordValidator
  12. ])],
  13. email: ['', Validators.compose([
  14. Validators.required,ValidationService.emailValidator
  15. ])],
  16. role: ['', Validators.required],
  17.  
  18. })
  19.  
  20. constructor(private _http:Http){}
  21.  
  22. static passwordValidator(control) {
  23. if(control.value != undefined){
  24. if (!control.value.match(/^(?=.*[0-9])[a-zA-Z0-9!@#$%^&*]{6,100}$/)) {
  25. return { 'invalidPassword': true };
  26. }
  27. }
  28.  
  29. }
  30.  
  31. static emailValidator(){
  32.  
  33. return this._http. //this returns an error i would like to
  34. //query server to see if email exists
  35.  
  36. }
Add Comment
Please, Sign In to add comment