Skip to content

Instantly share code, notes, and snippets.

@jjvillavicencio
Forked from djabif/password.validator.ts
Created April 23, 2019 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjvillavicencio/3357f41189d806d535297f315ea01b66 to your computer and use it in GitHub Desktop.
Save jjvillavicencio/3357f41189d806d535297f315ea01b66 to your computer and use it in GitHub Desktop.
Password Validator for ionic apps
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