Files
hackerspace.sh/lib/validations/contacts.ts
T
Moheeb ZaraandClaude Opus 4.8 18d5e22ad4 refactor(validations): split lib/validations.ts into a barrel'd folder (slice 1)
1141-line lib/validations.ts → lib/validations/<feature>.ts + primitives.ts +
an index.ts barrel. '@/lib/validations' now resolves to the barrel, so all 40
importers are untouched. Every one of the 143 exports is preserved verbatim
(verified by symbol-diff); schemas moved unchanged. tsc 0, 635 tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-08-02 04:19:11 -07:00

21 lines
817 B
TypeScript

import { z } from 'zod'
import { emailField } from './primitives'
export const createContactSchema = z.object({
name: z.string().min(1, 'Name is required').max(200),
contact_type: z.enum(['vendor', 'supplier', 'partner', 'landlord', 'city']),
email: emailField().optional().nullable(),
phone: z.string().max(20).optional().nullable(),
details: z.string().max(500).optional().nullable(),
note: z.string().max(2000).optional().nullable(),
group_label: z.string().max(100).optional().nullable(),
tags: z.array(z.string().max(50)).max(10).optional(),
code: z.string().max(50).optional().nullable(),
})
export const updateContactSchema = createContactSchema.partial().extend({
contactId: z.string().uuid('Invalid contact ID'),
})
export type CreateContactInput = z.infer<typeof createContactSchema>