edit validation, add new validation message

This commit is contained in:
smanylov
2026-01-09 19:46:59 +07:00
parent 9f880f71d1
commit 2350ac8a5d
5 changed files with 75 additions and 14 deletions
+1
View File
@@ -161,6 +161,7 @@ export async function registration(
password,
confirm_password,
agree,
companyName
});
if (!validatedFields.success) {
+37 -10
View File
@@ -23,15 +23,13 @@ export const SignupFormSchema = z
fullName: z
.string()
.min(2, { error: 'register-error-name' })
.regex(/^[^0-9]*$/, { message: 'register-error-no-digits' })
/* .refine(
(value) => !/\p{Emoji}/u.test(value),
{ message: 'no-emoji-allowed' }
) */
.max(100, { error: 'register-error-max-name' })
.regex(/^[a-zA-Zа-яА-ЯёЁ\s\-'.]*$/, { message: 'register-error-no-digits' })
.trim(),
email: z
.string()
.trim()
.max(254, { error: 'register-error-max-email' })
.refine(
(value) => value === value.toLowerCase(),
{ message: 'email-no-uppercase' }
@@ -48,16 +46,45 @@ export const SignupFormSchema = z
.min(8, { error: 'register-error-password-symbols' })
.regex(/[a-zA-Zа-яёА-ЯЁ]/, { error: 'register-error-password-one-letter' })
.regex(/[0-9]/, { error: 'register-error-password-one-digit' })
/* .refine(
(value) => !/\p{Emoji}/u.test(value),
{ message: 'no-emoji-allowed' }
) */
.max(124, { error: 'register-error-max-passowrd' })
.trim(),
confirm_password: z
.string(),
agree: z
.string()
.min(2, { error: 'register-error-agree' })
.min(2, { error: 'register-error-agree' }),
companyName: z
.string()
.optional()
.nullable()
.refine(
(value) => {
if (!value || value.trim().length === 0) return true;
return value.trim().length >= 2;
},
{ message: 'register-error-company-name' }
)
.refine(
(value) => {
const trimmed = value ? value.trim() : '';
return trimmed.length === 0 || trimmed.length <= 200;
},
{
message: 'register-error-company-name-max',
path: ['companyName']
}
)
.refine(
(value) => {
if (!value || value.trim().length === 0) return true;
const regex = /^[a-zA-Zа-яА-ЯёЁ0-9\s\-&.,'"()]+$/;
return regex.test(value);
},
{
message: 'companyName-invalid-chars',
path: ['companyName']
}
),
})
.refine((data) => data.password === data.confirm_password, {
message: 'repeat-password',