import vine from '@vinejs/vine' const name = () => vine.string().minLength(2).maxLength(120) const email = () => vine.string().email().maxLength(254) // SIRET = 14 chiffres exactement (cf. INSEE). const siret = () => vine.string().regex(/^\d{14}$/) const phone = () => vine.string().maxLength(40) const address = () => vine.string().maxLength(500) const notes = () => vine.string().maxLength(2000) // Prénom/nom du contact dédié — utilisés comme variables dans les templates // custom ({{client.contactFirstName}}). Optionnels. const contactName = () => vine.string().minLength(1).maxLength(80) /** * Validator pour POST /clients. Email **requis** : sans email, Rubis ne * peut pas relancer (pivot produit, cf. CLAUDE.md → Principes). */ export const createClientValidator = vine.create({ name: name(), email: email(), contactFirstName: contactName().nullable().optional(), contactLastName: contactName().nullable().optional(), phone: phone().nullable().optional(), address: address().nullable().optional(), siret: siret().nullable().optional(), notes: notes().nullable().optional(), }) /** * Validator pour PATCH /clients/:id. Tous les champs optionnels. */ export const updateClientValidator = vine.create({ name: name().optional(), email: email().optional(), contactFirstName: contactName().nullable().optional(), contactLastName: contactName().nullable().optional(), phone: phone().nullable().optional(), address: address().nullable().optional(), siret: siret().nullable().optional(), notes: notes().nullable().optional(), })