NG.VI · Angular 22 practice question
A developer is writing a class-based custom asynchronous validator named UniqueRoleValidator in Angular. Which interface should the class implement?
Check answer and explanation
Correct answer: AsyncValidator
Explanation
A class-based asynchronous validator such as UniqueRoleValidator implements the AsyncValidator interface.
Common trap
Validator is the interface for synchronous class-based validators, not asynchronous ones. AsyncValidatorFn is a function type signature rather than the interface implemented by a validator class.
Source: Angular docs: Validating form input — Implementing a custom async validator
Checked against the cited text on 2026-11-25.