Better Validations
This commit is contained in:
11
src/app/shared/validators/validate-password.validator.ts
Normal file
11
src/app/shared/validators/validate-password.validator.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import {AbstractControl} from "@angular/forms";
|
||||
|
||||
export function ValidatePasswordValidator(control: AbstractControl) {
|
||||
var password = control.value;
|
||||
var passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/g;
|
||||
var passwordValid = passwordRegex.test(password);
|
||||
if (!passwordValid) {
|
||||
return { invalidPassword: true };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user