Refactor password validation regex for consistency across application
- Updated password validation regex in ChangePasswordCommandValidator, RegisterCommandValidator, RegisterForm, and ChangePasswordForm to use Unicode property escapes for uppercase letters, ensuring consistent validation rules across both backend and frontend components.
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ public sealed class ChangePasswordCommandValidator : AbstractValidator<ChangePas
|
|||||||
RuleFor(x => x.NewPassword)
|
RuleFor(x => x.NewPassword)
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.MinimumLength(8)
|
.MinimumLength(8)
|
||||||
.Matches("^(?=.*[A-Z])(?=.*[0-9]).+$")
|
.Matches(@"^(?=.*\p{Lu})(?=.*\d).+$")
|
||||||
.WithMessage("Пароль должен содержать минимум одну заглавную букву и одну цифру.");
|
.WithMessage("Пароль должен содержать минимум одну заглавную букву и одну цифру.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public sealed class RegisterCommandValidator : AbstractValidator<RegisterCommand
|
|||||||
RuleFor(x => x.Password)
|
RuleFor(x => x.Password)
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.MinimumLength(8)
|
.MinimumLength(8)
|
||||||
.Matches("^(?=.*[A-Z])(?=.*[0-9]).+$")
|
.Matches(@"^(?=.*\p{Lu})(?=.*\d).+$")
|
||||||
.WithMessage("Пароль должен содержать минимум одну заглавную букву и одну цифру.");
|
.WithMessage("Пароль должен содержать минимум одну заглавную букву и одну цифру.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const schema = z.object({
|
|||||||
password: z
|
password: z
|
||||||
.string()
|
.string()
|
||||||
.min(8)
|
.min(8)
|
||||||
.regex(/^(?=.*[A-Z])(?=.*[0-9]).+$/),
|
.regex(/^(?=.*\p{Lu})(?=.*\d).+$/u),
|
||||||
})
|
})
|
||||||
|
|
||||||
type FormValues = z.infer<typeof schema>
|
type FormValues = z.infer<typeof schema>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const schema = z.object({
|
|||||||
newPassword: z
|
newPassword: z
|
||||||
.string()
|
.string()
|
||||||
.min(8)
|
.min(8)
|
||||||
.regex(/^(?=.*[A-Z])(?=.*[0-9]).+$/),
|
.regex(/^(?=.*\p{Lu})(?=.*\d).+$/u),
|
||||||
})
|
})
|
||||||
|
|
||||||
type FormValues = z.infer<typeof schema>
|
type FormValues = z.infer<typeof schema>
|
||||||
|
|||||||
Reference in New Issue
Block a user