import { AbstractControl , ValidatorFn } from '@angular/forms' ; export class MatchValidator { static mustMatch ( controlName , matchingControlName ) { return ( formGroup ) : { [ key ] : boolean ; } | null => { const control = formGroup . get ( controlName ) ; const matchingControl = formGroup . get ( matchingControlName ) ; if ( control . value !== matchingControl . value ) { matchingControl . setErrors ( { mustMatch : true } ) ; } else { matchingControl . setErrors ( null ) ; } return null ; } ; } }