I'm building an Angular 5 form. I have a requirement for contact information on my form (email or phone). Either an email address OR a phone number is required, but not both. How would I create a custom validator for this scenario? From the docs it seems that validators are responsible for just one control, whereas my validator would need to be aware of multiple controls to check all their values.
ngOnInit() {
this.form = this.formBuilder.group({
'name': [null, [Validators.required]],
'email': [null, []], // A user can provide email OR phone, but
'phone': [null, []], // both are not required. How would you do this?
});
}