I am working on a custom async validator within a reactive form that requires validation of name uniqueness by making a call to a service.
Due to the purity of validators, I am struggling to find a proper way to inject a provider like HTTP to handle these validations.
The current implementation involves returning a function that includes the service, but it feels a bit like a workaround...
export function nameValidator(platformService: PlatformService): ValidatorFn {
return (control: FormControl): { [key: string]: any } => {
return userService.getUnique(control.value);
};
}
So, my question is: Is there a more efficient way to approach this?