ng2-validation
ng2-validation copied to clipboard
Multiple Validators for the same input field.
I believe that it would be very useful to have a note about multiple validators for the same field.
I was able to accomplish this with:
this.myForm = fb.group({
'cardNumber': new FormControl('', Validators.compose([Validators.required, CustomValidators.creditCard]))
});
@phixMe I agree that this is missing in the documentation. In addition, the view is like this
<input type="text" formControlName="cardNumber" placeholder="cardNumber"/>
<p *ngIf="myForm.controls.cardNumber.errors?.creditCard || myForm.controls.cardNumber.errors?.required">invalid card</p>
Validation works but the ngIf doesn't