/** * TASK-0106 §3 — form create/update DTOs. * * `config` is validated by the SHARED `FORM_CONFIG_SCHEMA` in the service * (single source of truth); the DTO only bounds gross shape. `questions` * is the inline array (create) / optional rebuild (update) — per-question * authoring lives in `question.dto.ts`. */ import { z } from "zod"; import { CreateQuestionDto, type CreateQuestionInput } from "./question.dto.js"; export const CreateFormDto = z.object({ name: z.string().min(1).max(100), slug: z .string() .min(2) .max(50) .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/) .optional(), description: z.string().max(500).optional(), config: z.record(z.unknown()).optional(), questions: z.array(CreateQuestionDto).max(50).optional() }); export type CreateFormInput = z.infer & { questions?: CreateQuestionInput[]; }; export const UpdateFormDto = z .object({ name: z.string().min(1).max(100).optional(), description: z.string().max(500).nullable().optional(), status: z.enum(["DRAFT", "PUBLISHED", "CLOSED"]).optional(), slug: z.string().min(2).max(50).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional(), config: z.record(z.unknown()).optional(), questions: z.array(CreateQuestionDto).max(50).optional() }) .refine((f) => Object.keys(f).length > 0, { message: "nothing to update" }); export type UpdateFormInput = z.infer & { questions?: CreateQuestionInput[]; };