a1d863ab477dffb0a53dd34fcef7f2fa863ed7d08df2c6a3c1c07ef79873616e.json 2.4 KB

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":{"version":3,"names":["MustMatch","controlName","matchingControlName","formGroup","control","controls","matchingControl","errors","mustMatch","value","setErrors"],"sources":["C:\\FatboarProject\\angular-client\\src\\app\\components\\shared\\validator\\confirm-password.validator.ts"],"sourcesContent":["import { FormGroup } from '@angular/forms';\r\n\r\n// custom validator to check that two fields match\r\nexport function MustMatch(controlName: string, matchingControlName: string) {\r\n return (formGroup: FormGroup) => {\r\n const control = formGroup.controls[controlName];\r\n const matchingControl = formGroup.controls[matchingControlName];\r\n\r\n if (matchingControl.errors && !matchingControl.errors.mustMatch) {\r\n // return if another validator has already found an error on the matchingControl\r\n return;\r\n }\r\n\r\n // set error on matchingControl if validation fails\r\n if (control.value !== matchingControl.value) {\r\n matchingControl.setErrors({ mustMatch: true });\r\n } else {\r\n matchingControl.setErrors(null);\r\n }\r\n }\r\n}\r\n"],"mappings":"AAEA;AACA,OAAM,SAAUA,SAASA,CAACC,WAAmB,EAAEC,mBAA2B;EACtE,OAAQC,SAAoB,IAAI;IAC5B,MAAMC,OAAO,GAAGD,SAAS,CAACE,QAAQ,CAACJ,WAAW,CAAC;IAC/C,MAAMK,eAAe,GAAGH,SAAS,CAACE,QAAQ,CAACH,mBAAmB,CAAC;IAE/D,IAAII,eAAe,CAACC,MAAM,IAAI,CAACD,eAAe,CAACC,MAAM,CAACC,SAAS,EAAE;MAC7D;MACA;;IAGJ;IACA,IAAIJ,OAAO,CAACK,KAAK,KAAKH,eAAe,CAACG,KAAK,EAAE;MACzCH,eAAe,CAACI,SAAS,CAAC;QAAEF,SAAS,EAAE;MAAI,CAAE,CAAC;KACjD,MAAM;MACHF,eAAe,CAACI,SAAS,CAAC,IAAI,CAAC;;EAEvC,CAAC;AACL"},"metadata":{},"sourceType":"module","externalDependencies":[]}