MCPcopy Create free account
hub / github.com/angular/components / ShowOnDirtyErrorStateMatcher

Class ShowOnDirtyErrorStateMatcher

src/material/core/error/error-options.ts:15–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13/** Error state matcher that matches when a control is invalid and dirty. */
14@Service({autoProvided: false})
15export class ShowOnDirtyErrorStateMatcher implements ErrorStateMatcher {
16 isErrorState(control: AbstractControl | null, form: FormGroupDirective | NgForm | null): boolean {
17 return !!(control && control.invalid && (control.dirty || (form && form.submitted)));
18 }
19
20 isSignalErrorState(field: Field<unknown> | null): boolean {
21 if (!field) {
22 return false;
23 }
24 const invalid = field().invalid();
25 const dirty = field().dirty();
26 return invalid && dirty;
27 }
28}
29
30/** Provider that defines how form controls behave with regards to displaying error messages. */
31@Service()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected