added custom ErrorStateMatcher to show feedback von Password Confirmation

This commit is contained in:
2020-07-21 15:22:43 +02:00
parent d69ed8082e
commit 3eff2af69d
2 changed files with 18 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
import { PasswordErrorStateMatcher } from './password-error-state-matcher';
describe('PasswordErrorStateMatcher', () => {
it('should create an instance', () => {
expect(new PasswordErrorStateMatcher()).toBeTruthy();
});
});

View File

@@ -0,0 +1,11 @@
import { ErrorStateMatcher } from '@angular/material/core';
import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
export class PasswordErrorStateMatcher implements ErrorStateMatcher {
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const invalidControl = !!(control && control.invalid && control.parent.touched);
const invalidParent = !!(control && control.parent && control.parent.invalid && control.parent.touched);
return invalidControl || invalidParent;
}
}