Enhance password validation in registration component with improved regex pattern and increased max length
This commit is contained in:
@@ -56,6 +56,11 @@ export class RegisterComponent implements OnDestroy {
|
||||
isSubmitted = false;
|
||||
isLoading = false;
|
||||
|
||||
private readonly passwordPattern: RegExp = new RegExp(
|
||||
'^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[\\p{P}\\p{S}]).{8,}$',
|
||||
'u'
|
||||
);
|
||||
|
||||
private readonly router: Router = inject(Router);
|
||||
private readonly authService: AuthService = inject(AuthService);
|
||||
|
||||
@@ -90,14 +95,14 @@ export class RegisterComponent implements OnDestroy {
|
||||
password: ['', [
|
||||
Validators.required,
|
||||
Validators.minLength(8),
|
||||
Validators.maxLength(20),
|
||||
Validators.pattern('^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$')
|
||||
Validators.maxLength(50),
|
||||
Validators.pattern(this.passwordPattern)
|
||||
]],
|
||||
confirmPassword: ['', [
|
||||
Validators.required,
|
||||
Validators.minLength(8),
|
||||
Validators.maxLength(20),
|
||||
Validators.pattern('^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$')
|
||||
Validators.maxLength(50),
|
||||
Validators.pattern(this.passwordPattern)
|
||||
]],
|
||||
termsAndConditions: [false, Validators.requiredTrue]
|
||||
}, {validators: this.passwordMatchValidator});
|
||||
|
||||
Reference in New Issue
Block a user