export class MustMatchDirective implements Validator {
@Input('mustMatch') mustMatch: string[] = [];
validate(formGroup: FormGroup): ValidationErrors {
return ValidateMatching(this.mustMatch[0], this.mustMatch[1])(formGroup); <-issue detected here
}
}
export function ValidateMatching(controlName: string, matchingControlName: string) {
return (formGroup: FormGroup) => {
const control = formGroup.controls[controlName];
const matchingControl = formGroup.controls[matchingControlName];
if (matchingControl.errors
&& !matchingControl.errors.matchingValidator) {
return;
}
if (control.value !== matchingControl.value) {
matchingControl.setErrors({ matchingValidator: true });
} else {
matchingControl.setErrors(null);
}
}
}
Can you help me identify the issue in the code provided above?