Created
September 19, 2018 22:56
Revisions
-
fr6nco created this gist
Sep 19, 2018 .There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ 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}; }) ); }; }