Angular 2

Angular 2 – Async Validator – Username/email availability check

In this post I will show you, how we can create custom async validator to check for email availability, same logic you can apply for username or other async validations.

Lets create a component:

Here is my user service:

Backed server response for unregistered email will be null and for registered email address will be as shown below –

By Arjun

I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.

8 replies on “Angular 2 – Async Validator – Username/email availability check”

If Email address already register, server response – {
“statusCode”: 400,
“error”: “Bad Request”,
“message”: “Email address already registerd”
If email is new : just return null
Why http uses post request? -because it’s my preferred way.

Leave a Reply

Your email address will not be published. Required fields are marked *