Last active
February 28, 2023 12:38
-
-
Save djabif/592b5fccc76d03d5c54b2f5c1ba69451 to your computer and use it in GitHub Desktop.
Password Validator for ionic apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FormControl, FormGroup } from '@angular/forms'; | |
export class PasswordValidator { | |
static areEqual(formGroup: FormGroup) { | |
let val; | |
let valid = true; | |
for (let key in formGroup.controls) { | |
if (formGroup.controls.hasOwnProperty(key)) { | |
let control: FormControl = <FormControl>formGroup.controls[key]; | |
if (val === undefined) { | |
val = control.value | |
} else { | |
if (val !== control.value) { | |
valid = false; | |
break; | |
} | |
} | |
} | |
} | |
if (valid) { | |
return null; | |
} | |
return { | |
areEqual: true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment