Files
no-copy-frontend/src/app/actions/definitions.ts
T

58 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-11-27 21:33:53 +07:00
import * as z from 'zod'
2025-11-28 15:28:15 +07:00
export type FormState =
| {
errors?: {
name?: string[]
email?: string[]
password?: string[]
}
message?: string
}
| undefined
export type FormAction = (
state: FormState,
formData: FormData
) => Promise<FormState>
2025-11-28 12:38:14 +07:00
export const SignupFormSchema = z
.object({
full_name: z
.string()
2025-12-10 16:39:13 +07:00
.min(3, { error: 'register-error-name' })
2025-11-28 12:38:14 +07:00
.trim(),
2025-12-10 16:39:13 +07:00
email: z.email({ error: 'register-error-valid-email' }).trim(),
phone: z
.string()
2025-12-10 16:39:13 +07:00
.min(12, { error: 'register-error-phone' }),
2025-11-28 12:38:14 +07:00
password: z
.string()
2025-12-10 16:39:13 +07:00
.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' })
2025-11-28 12:38:14 +07:00
.trim(),
confirm_password: z
.string(),
agree: z
2025-11-28 12:38:14 +07:00
.string()
2025-12-10 16:39:13 +07:00
.min(2, { error: 'register-error-agree' })
2025-11-28 12:38:14 +07:00
})
.refine((data) => data.password === data.confirm_password, {
2025-12-10 16:39:13 +07:00
message: 'repeat-password',
2025-11-28 12:38:14 +07:00
path: ['confirm_password'],
});
2025-11-27 21:33:53 +07:00
2025-11-28 15:28:15 +07:00
export const loginFormSchema = z
.object({
email: z
.string()
2025-12-10 16:39:13 +07:00
.min(1, { error: 'login-error-email' })
2025-11-28 15:28:15 +07:00
.trim(),
password: z
.string()
2025-12-10 16:39:13 +07:00
.min(1, { error: 'login-error-password' })
2025-11-28 15:28:15 +07:00
.trim(),
2025-12-03 21:02:31 +07:00
})
2025-12-04 17:10:51 +07:00
export const localDevelopmentUrl = 'http://localhost:80';