Im using Angular 7 and have created a Reactive Form. The input field email has two validators set on it see below:
email: ['', [Validators.email, Validators.pattern('^[\\w._]+@company(.com|.go|.jet)')]],
Both validators have 2 errors messages in the template:
<label for="email" class="error-msg" *ngIf="authForm.get('email').hasError('email') && hideFocus">Your email is invalid</label>
<label for="email" class="error-msg" *ngIf="authForm.get('email').hasError('pattern') && hideFocus">Only emails ending with .com .go and .jet are allowed</label>
When the user types in the input field both errors are displayed at the same time.
How can I display one error message at a time? Is it possible?