form: FormGroup = new FormGroup({
email: new FormControl('', [Validators.required], [this.customValidator()])
})
customValidator(): AsyncValidatorFn {
return (control: AbstractControl): Observable<ValidationErrors | null> => {
return this.loginService.checkUserExist({value: control?.value, type: 1})
.pipe(map((res: {status: boolean, message: string}) => {
return res?.status ? null : { duplicate: true };
})).pipe(first())
}
}
Created
October 30, 2022 18:11
-
-
Save raviagheda/44157d7986d0cbff4d5405f05f2e79d5 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment