Why does the formInit function call isPassValid when constructing the form to check for a valid password?
ngOnInit() {
this.formInit();
}
formInit() {
this.form = this.fb.group({
password: ['', [Validators.required, this.isPassVaid]]
});
}
isPassValid(control: FormControl) {
if (control.value) {
const regex = '^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[^\\da-zA-Z]).{6,10}$';
const regexp = new RegExp(regex, 'g');
if (regexp.test(control.value)) {
return;
} else {
return { invalidPass: true };
}
}
}