update validation messages

This commit is contained in:
smanylov
2025-12-19 16:11:58 +07:00
parent c26c2ebc7f
commit a7467d486d
5 changed files with 85 additions and 37 deletions
+8 -4
View File
@@ -16,21 +16,25 @@ export type FormAction = (
formData: FormData
) => Promise<FormState>
const emailRegex = /^([a-zA-Z0-9.\-_]+|[аА-ЯёЁ0-9.\-_]+)@(([a-zA-Z0-9.\-]+)\.([a-zA-Z]{2,})|([a-zA-Z0-9.\-]+)\.([аА-ЯёЁ]{2,})|([аА-ЯёЁ0-9.\-]+)\.([a-zA-Z]{2,})|([аА-ЯёЁ0-9.\-]+)\.([аА-ЯёЁ]{2,}))$/i;
const emailRegex = /^([a-z0-9.\-_]+|[аё0-9.\-_]+)@(([a-z0-9.\-]+)\.([a-z]{2,})|([a-z0-9.\-]+)\.([аё]{2,})|([аё0-9.\-]+)\.([a-z]{2,})|([аё0-9.\-]+)\.([аё]{2,}))$/i;
export const SignupFormSchema = z
.object({
full_name: z
fullName: z
.string()
.min(3, { error: 'register-error-name' })
.min(2, { error: 'register-error-name' })
.regex(/^[^0-9]*$/, { message: 'register-error-no-digits' })
.trim(),
email: z
.string()
.trim()
.refine(
(value) => value === value.toLowerCase(),
{ message: 'email-no-uppercase' }
)
.refine(
(value) => emailRegex.test(value),
{ message: 'register-error-valid-email' }
{ message: 'email-invalid' }
),
phone: z
.string()