| 13 | /** Error state matcher that matches when a control is invalid and dirty. */ |
| 14 | @Service({autoProvided: false}) |
| 15 | export 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() |
nothing calls this directly
no outgoing calls
no test coverage detected