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;
|
isSubmitted = false;
|
||||||
isLoading = 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 router: Router = inject(Router);
|
||||||
private readonly authService: AuthService = inject(AuthService);
|
private readonly authService: AuthService = inject(AuthService);
|
||||||
|
|
||||||
@@ -90,14 +95,14 @@ export class RegisterComponent implements OnDestroy {
|
|||||||
password: ['', [
|
password: ['', [
|
||||||
Validators.required,
|
Validators.required,
|
||||||
Validators.minLength(8),
|
Validators.minLength(8),
|
||||||
Validators.maxLength(20),
|
Validators.maxLength(50),
|
||||||
Validators.pattern('^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$')
|
Validators.pattern(this.passwordPattern)
|
||||||
]],
|
]],
|
||||||
confirmPassword: ['', [
|
confirmPassword: ['', [
|
||||||
Validators.required,
|
Validators.required,
|
||||||
Validators.minLength(8),
|
Validators.minLength(8),
|
||||||
Validators.maxLength(20),
|
Validators.maxLength(50),
|
||||||
Validators.pattern('^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$')
|
Validators.pattern(this.passwordPattern)
|
||||||
]],
|
]],
|
||||||
termsAndConditions: [false, Validators.requiredTrue]
|
termsAndConditions: [false, Validators.requiredTrue]
|
||||||
}, {validators: this.passwordMatchValidator});
|
}, {validators: this.passwordMatchValidator});
|
||||||
|
|||||||
Reference in New Issue
Block a user