Created
September 19, 2018 22:56
-
-
Save fr6nco/10bd11151ba0c74cd0b773b045251c0d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function emailExistsValidatorFn(userService: UserService, trueOnExists: boolean): AsyncValidatorFn { | |
console.log('validator triggered'); | |
return (control: AbstractControl): Promise<ValidationErrors | null> | Observable<ValidationErrors | null> => { | |
console.log(userService); | |
return userService.checkIfEmailExists(control.value, trueOnExists).pipe( | |
take(1), | |
map((result: boolean) => { | |
console.log(result); | |
console.log('psovi nic'); | |
return result ? null : {'emailexists': true}; | |
}) | |
); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment