cic-staff-client/src/app/_helpers/custom-error-state-matcher.ts

10 lines
459 B
TypeScript
Raw Normal View History

2021-05-10 18:15:25 +02:00
import { ErrorStateMatcher } from '@angular/material/core';
import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
2021-05-10 18:15:25 +02:00
export class CustomErrorStateMatcher implements ErrorStateMatcher {
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const isSubmitted: boolean = form && form.submitted;
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
}
}