userExistsValidator
Anonymous
typescript
12/06/2022 8:02 PM
464 B
21
Indexable
import {AbstractControl, AsyncValidatorFn} from '@angular/forms';
export function userExistsValidator(user: UserService):AsyncValidatorFn {
return (control: AbstractControl) => {
return user.findUserByEmail(control.value)
.pipe(
map(user => user ? {userExists:true} : null)
);
}
}Editor is loading...