Angular / OR Validator Composition - Including Two Validators

I have a login form for my Angular 4 application. In this form, I have a Login field that should accept the user's email address or her phone number .

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

However, how do you apply both validators to an input field, grouping them using the OR function ? that is, the field must be considered valid if at least one of these validators is valid.

By default Angular requires all validators to be valid.

I am using reactive forms.

+3


source to share





All Articles