File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/src/app/modules/my-error-state-matcher.module.ts
import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { UntypedFormControl, FormGroupDirective, NgForm } from "@angular/forms";
import { ErrorStateMatcher } from "@angular/material/core";
@NgModule({
declarations: [],
imports: [CommonModule],
})
export class MyErrorStateMatcher implements ErrorStateMatcher {
isErrorState(
control: UntypedFormControl | null,
form: FormGroupDirective | NgForm | null
): boolean {
const isSubmitted = form && form.submitted;
return !!(
control &&
control.invalid &&
(control.dirty || control.touched || isSubmitted)
);
}
}