0Pricing
Angular Academy · Lesson

Async Validators

Validate against the server asynchronously.

Validation That Waits

Some validation needs a server, such as checking if a username is taken. Async validators return a Promise or Observable that resolves to an error map or null.

The AsyncValidatorFn Type

An async validator takes a control and returns Observable<ValidationErrors | null> (or a Promise).

const v: AsyncValidatorFn = (control) => {
  return checkAvailable(control.value);
};

All lessons in this course

  1. Typed Reactive Forms
  2. FormArray and Dynamic Fields
  3. Async Validators
  4. FormBuilder Patterns
← Back to Angular Academy