import { z } from "zod"; export const contactSchema = z.object({ name: z.string().min(2).max(80).transform((v) => v.replace(/[\r\n]+/g, " ").trim()), email: z.string().email().max(254), topic: z.enum(["general", "honey-bees", "personal-training", "sourdough", "farm-to-table", "recreation-apps", "laser-engraving", "3d-printing"]).default("general"), message: z.string().min(10).max(5000), phone: z.string().optional().default(""), }); export const contactBodySchema = contactSchema.extend({ website: z.string().optional().default(""), company: z.string().optional().default(""), }); export type ContactInput = z.infer; export type ContactBody = z.infer; export function isHoneypotTriggered(body: { website?: string; company?: string }): boolean { const filled = (v?: string) => typeof v === "string" && v.trim().length > 0; return filled(body.website) || filled(body.company); } export function sanitizeHeaderValue(value: string): string { return value.replace(/[\r\n]+/g, " ").trim().slice(0, 200); }