I have a custom async validator in a reactive form that needs to call out to a service to validate whether a name is unique.
Since validators are pure functions, there doesn't seem to be a good way to inject a provider such as HTTP to make these calls.
The code I currently have is returning a function that passes the service but this feels a tad hacky...
export function nameValidator(platformService: PlatformService): ValidatorFn {
return (control: FormControl): { [key: string]: any } => {
return userService.getUnique(control.value)
};
}
my question is there a better way?