28 lines
772 B
TypeScript
28 lines
772 B
TypeScript
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<typeof CreatePlanCategorySchema>;
|
|
export type UpdatePlanCategoryInput = z.infer<typeof UpdatePlanCategorySchema>;
|