diff --git a/src/app/signup/core/password.matcher.ts b/src/app/signup/core/password.matcher.ts new file mode 100644 index 0000000000000000000000000000000000000000..8d9f40ed61fbbfc2adf88f6fdd2ad071e1681abe --- /dev/null +++ b/src/app/signup/core/password.matcher.ts @@ -0,0 +1,10 @@ +import { FormControl, FormGroupDirective, NgForm } from '@angular/forms'; +import { ErrorStateMatcher } from '@angular/material'; + +// From: https://stackoverflow.com/a/51606362 +export class PasswordErrorStateMatcher implements ErrorStateMatcher { + isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { + const invalidParent = !!(control && control.parent && control.parent.invalid && control.parent.dirty); + return (control && control.dirty && invalidParent); + } +}