Creating a custom Angular validator is required if there is no built-in Angular validator to match a particular use-case in an application.
The following custom validator is used to compare and validate the value of an input field with the value of its relative confirm input field. In this article the values of email and confirm email, as well as password and confirm password fields are compared and validated.
See my demo application of both reactive and template-driven forms, with unit and e2e tests at GitHub.