mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Validation with min length and byte validation in reset added
This commit is contained in:
parent
18193db7bf
commit
5d90c4b9e4
@ -29,10 +29,15 @@ const RESET_PASSWORD_SCHEMA = yup.object().shape({
|
||||
defaultMessage: 'Password must be at least 8 characters',
|
||||
values: { min: 8 },
|
||||
})
|
||||
.max(70,{
|
||||
id: translatedErrors.maxLength.id,
|
||||
defaultMessage: "Password should be less than 70 characters"
|
||||
})
|
||||
.test(
|
||||
'required-byte-size',
|
||||
'Password must be between 8 and 70 bytes',
|
||||
(value) => {
|
||||
if (!value) return false;
|
||||
const byteSize = new TextEncoder().encode(value).length;
|
||||
return byteSize >= 8 && byteSize <= 70;
|
||||
}
|
||||
)
|
||||
.matches(/[a-z]/, {
|
||||
message: {
|
||||
id: 'components.Input.error.contain.lowercase',
|
||||
@ -114,9 +119,9 @@ const ResetPassword = () => {
|
||||
{isBaseQueryError(error)
|
||||
? formatAPIError(error)
|
||||
: formatMessage({
|
||||
id: 'notification.error',
|
||||
defaultMessage: 'An error occurred',
|
||||
})}
|
||||
id: 'notification.error',
|
||||
defaultMessage: 'An error occurred',
|
||||
})}
|
||||
</Typography>
|
||||
) : null}
|
||||
</Column>
|
||||
|
||||
@ -22,10 +22,11 @@ export const username = yup.string().min(1);
|
||||
|
||||
export const password = yup
|
||||
.string()
|
||||
.min(8)
|
||||
.test(
|
||||
'required-byte-size',
|
||||
'Password must be between 8 and 70 bytes',
|
||||
(value:string) => {
|
||||
(value) => {
|
||||
if (!value) return false;
|
||||
const byteSize = new TextEncoder().encode(value).length;
|
||||
return byteSize >= 8 && byteSize <= 70;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user