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