02779ee6499d9652499169c263b0f485f54b90d6d03b1497adf5797decd7a879.json 789 B

1
  1. {"ast":null,"code":"// custom validator to check that two fields match\nexport function MustMatch(controlName, matchingControlName) {\n return formGroup => {\n const control = formGroup.controls[controlName];\n const matchingControl = formGroup.controls[matchingControlName];\n if (matchingControl.errors && !matchingControl.errors.mustMatch) {\n // return if another validator has already found an error on the matchingControl\n return;\n }\n // set error on matchingControl if validation fails\n if (control.value !== matchingControl.value) {\n matchingControl.setErrors({\n mustMatch: true\n });\n } else {\n matchingControl.setErrors(null);\n }\n };\n}","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}