Search⌘ K

Asynchronous Validators

Explore how to create asynchronous validators in Angular by implementing the AsyncValidator interface and using APIs to validate user input. Understand how to generate validator classes, define the validate method, and handle asynchronous responses like checking password safety with an external service. This lesson equips you to build custom validations that depend on server responses in reactive Angular forms.

We’re going to create another validator. The next validator we’ll create will demonstrate how to write asynchronous validators. Every validator we’ve worked with and written has run synchronously.

In some cases, we may need to make a request to a server to validate a value. Requests are asynchronous. We’ll need to wait until a response is given before we can allow the user to proceed.

Asynchronous validators are created similarly to synchronous validators. Here are the steps we’ll take to create one:

  1. Generate a new class for
...