| /** | |
| * Input validation helpers using Zod. | |
| * @module validators | |
| */ | |
| import { z } from 'zod'; | |
| export const emailSchema = z.string().email('Invalid email format'); | |
| export const passwordSchema = z | |
| .string() | |
| .min(8, 'Password must be at least 8 characters') | |
| .max(128, 'Password too long') | |
| .regex(/[A-Z]/, 'Must contain uppercase letter') | |
| .regex(/[a-z]/, 'Must contain lowercase letter') | |
| .regex(/[0-9]/, 'Must contain number'); | |
| export const userCreateSchema = z.object({ | |
| email: emailSchema, | |
| password: passwordSchema, | |
| name: z.string().min(1).max(100).optional(), | |
| }); | |
| export type UserCreate = z.infer<typeof userCreateSchema>; | |