Is there anyway to do 'Either Or, one or the other validation in Angular Reactive Forms?
Currently, want form to be valid, (a) if City and State is inputted Or (b) Zip Code is inputted, either group, and form is valid. If both groups are empty, then form is invalid.
This is the base start form, currently both city and zip are optional, trying to incorporate this correct logic.
public editAddressForm: FormGroup;
this.editAddressForm = this.formBuilder.group({
'name': [null, [Validators.maxLength(100)]],
'phonenumber': [null, [Validators.maxLength(50)]],
'city': [null, [Validators.maxLength(32)]],
'state': [null,[Validators.maxLength(4)]],
'zipcode': [null, [Validators.maxLength(16)]]
})
Trying to use this resource, however it requires city and zip to be nested, which is not what is required.
Angular, How to set validation for either of two field should validate in reaction form approach