From d3d7f7e19984b4db4f9fc076e64d1ff54c8858e4 Mon Sep 17 00:00:00 2001 From: BOHA Date: Sat, 6 Jun 2026 00:33:47 +0200 Subject: [PATCH] feat(plan): add plan category zod schemas Co-Authored-By: Claude Opus 4.8 (1M context) --- src/schemas/planCategory.schema.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/schemas/planCategory.schema.ts diff --git a/src/schemas/planCategory.schema.ts b/src/schemas/planCategory.schema.ts new file mode 100644 index 0000000..8327a42 --- /dev/null +++ b/src/schemas/planCategory.schema.ts @@ -0,0 +1,27 @@ +import { z } from "zod"; + +const hexColor = z + .string() + .regex(/^#[0-9a-fA-F]{6}$/, "Barva musí být ve formátu #RRGGBB"); + +export const CreatePlanCategorySchema = z.object({ + label: z + .string() + .trim() + .min(1, "Název je povinný") + .max(100, "Maximálně 100 znaků"), + color: hexColor, +}); + +export const UpdatePlanCategorySchema = z + .object({ + label: z.string().trim().min(1, "Název je povinný").max(100).optional(), + color: hexColor.optional(), + is_active: z.boolean().optional(), + }) + .refine((v) => Object.keys(v).length > 0, { + message: "Nic k aktualizaci", + }); + +export type CreatePlanCategoryInput = z.infer; +export type UpdatePlanCategoryInput = z.infer;