Validators composition in Angular / OR-ing two validators

Viewed 110

I have a login form in my Angular 4 application. In this form I have a "Login" field, which should accept either E-Mail address of the user or her phone number.

I have a built-in validator for E-Mail address (coming from Angular) and I also have a custom validator for phone numbers.

However, how do I apply both validators to the input field grouping them with OR function? i.e. the field should be considered valid if at least one of these validators is valid.

By default Angular requires all validators to be valid.

I'm using reactive forms.

0 Answers
Related