Custom validator

As we can see by looking at the highlighted lines, there are two new validators that we used to check the email and password given by the user: the Validators.email--which has obviously been attached to the Email form control--and the passwordConfirmValidator(), which we attached to the whole FormGroup.

The first one is built-in in Angular, while the latter is a custom validator that we put together to compare the Password and PasswordConfirm fields and keep the user informed of their respective value. As we can see, we chose to attach it to the whole form group, because it needs to check two controls at the same time; hence, we need it to trigger whenever either of them changes its value.

The validator itself does nothing ...

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.