docs: fix UniqueAlterEgoValidatorDirective (#44764)

PR Close #44764
This commit is contained in:
Tim Bowersox
2022-01-21 19:18:11 -05:00
committed by Andrew Kushnir
parent 4948ab9ee5
commit 9f4b46796e
@@ -37,15 +37,12 @@ export class UniqueAlterEgoValidator implements AsyncValidator {
]
})
export class UniqueAlterEgoValidatorDirective implements AsyncValidator {
constructor(private heroesService: HeroesService) {}
constructor(private validator: UniqueAlterEgoValidator) {}
validate(
control: AbstractControl
): Observable<ValidationErrors | null> {
return this.heroesService.isAlterEgoTaken(control.value).pipe(
map(isTaken => (isTaken ? { uniqueAlterEgo: true } : null)),
catchError(() => of(null))
);
this.validator.validate(control);
}
}
// #enddocregion async-validator-directive