diff --git a/packages/forms/src/validators.ts b/packages/forms/src/validators.ts index 99200c8bca3..83dc8efe7d6 100644 --- a/packages/forms/src/validators.ts +++ b/packages/forms/src/validators.ts @@ -60,6 +60,26 @@ export const NG_VALIDATORS = new InjectionToken>('NgVa * * @see `NG_VALIDATORS` * + * @usageNotes + * + * ### Provide a custom async validator directive + * + * The following example implements the `AsyncValidator` interface to create an + * async validator directive with a custom error key. + * + * ```typescript + * @Directive({ + * selector: '[customAsyncValidator]', + * providers: [{provide: NG_ASYNC_VALIDATORS, useExisting: CustomAsyncValidatorDirective, multi: + * true}] + * }) + * class CustomAsyncValidatorDirective implements AsyncValidator { + * validate(control: AbstractControl): Promise { + * return Promise.resolve({'custom': true}); + * } + * } + * ``` + * * @publicApi */ export const NG_ASYNC_VALIDATORS =