Как стригерить валидатор не делая всю форму невалидной Angular Reactive forms?

Как стриггерить валидатор на делая всю форму не валидной?

<mat-form-field color="warn">
    <input placeholder="{{action}} InvoiceNumber" matInput formControlName="InvoiceNumber" minlength="10" required="true"
      (change)="isWarning($event)">

    <mat-error *ngIf="hasError('InvoiceNumber', 'required')">Invoice Number name is required</mat-error>
    <mat-error *ngIf="hasError('InvoiceNumber', 'min')">Invoice number should contain 10 symbols</mat-error>
    <!-- <mat-error *ngIf="errorMessage !== null">Invoice number should contain 10 symbols</mat-error> -->
  </mat-form-field>


userData: new FormControl('', [Validators.required, Validators.min(10)])

hasError = (controlName: string, errorName: string) => {
if (controlName === 'InvoiceNumber') {
  this.form.controls[controlName].updateValueAndValidity(/*{onlySelf: true, emitEvent: false}*/);
}
return this.form.controls[controlName].hasError(errorName);

}


Ответы (0 шт):