Files
vitareba/lib/domain/programmes.ts
g-butandClaude Sonnet 4.6 ad628c6307 refactor(domain): extract remaining inline schemas to lib/domain
Completes the domain-schema consolidation pass:

- lib/domain/programmes.ts: new — programmeUpdateSchema (fixes magic 10
  → PROGRAMME_START_DATE_MAX_LENGTH constant added to lib/config/portal.ts)
- lib/domain/bookings.ts: new — bookingCreateSchema
- lib/domain/messages.ts: add replySchema alongside existing message utils

API routes now import from domain; no more inline z.object() definitions
in app/api/**. All routes thin; all validation logic has a single home.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 09:12:55 +02:00

12 lines
564 B
TypeScript

import { z } from "zod";
import { PROGRAMME_ENUM_VALUES, PHASE_ENUM_VALUES } from "@/lib/config/programmes";
import { PATIENT_NOTE_MAX_LENGTH, PROGRAMME_START_DATE_MAX_LENGTH } from "@/lib/config/portal";
/** Validates an admin PATCH body for programme assignment upserts */
export const programmeUpdateSchema = z.object({
programme: z.enum(PROGRAMME_ENUM_VALUES),
phase: z.enum(PHASE_ENUM_VALUES),
startDate: z.string().max(PROGRAMME_START_DATE_MAX_LENGTH).nullable().optional(),
notes: z.string().max(PATIENT_NOTE_MAX_LENGTH).nullable().optional(),
});