import { z } from "zod"; /** * Single source of truth for auth form shapes — shared between client * forms (react-hook-form + zodResolver) and their server actions. Every * flow here is now email-OTP-based (see src/lib/auth/otp.service.ts) — * there is no password field anywhere in this file. */ const otpCode = z .string() .trim() .regex(/^\d{6}$/, "Enter the 6-digit code"); export const emailOnlySchema = z.object({ email: z.email("Enter a valid email address"), }); export type EmailOnlyInput = z.infer; /** Step 2 of sign-in — email is re-sent alongside the code (not trusted from any earlier request) so a stale/forged form can't verify a code against a different address than the one it was requested for. */ export const signInVerifySchema = z.object({ email: z.email("Enter a valid email address"), code: otpCode, }); export type SignInVerifyInput = z.infer; export const registerRequestSchema = z.object({ firstName: z.string().trim().min(1, "First name is required"), lastName: z.string().trim().min(1, "Last name is required"), email: z.email("Enter a valid email address"), phone: z.string().trim().optional().or(z.literal("")), }); export type RegisterRequestInput = z.infer; export const registerVerifySchema = registerRequestSchema.extend({ code: otpCode, }); export type RegisterVerifyInput = z.infer;