feat(editorial): validate publications and preserve partial event updates
CI / check (push) Successful in 57s
CI / deploy (push) Successful in 18s
CI / publish-container (push) Successful in 1m20s

This commit is contained in:
Simo committed 2026-09-11 00:36:55 +02:00
1 parent 76f0420d64
commit db4acbb46e
14 files changed
+613 -16

No files matched your search

+14 -2
View File
@@ -25,7 +25,11 @@ export const createEventSchema = z.object({
emptyToUndefined,
z.coerce.number().int().positive().nullable().optional(),
),
startsAt: z.coerce.date(),
startsAt: z.preprocess(
(value) =>
value == null || typeof value === "boolean" ? undefined : value,
z.coerce.date(),
),
endsAt: z.preprocess(emptyToUndefined, z.coerce.date().nullable().optional()),
maxPlayers: z.preprocess(
emptyToUndefined,
@@ -45,7 +49,15 @@ export const createEventSchema = z.object({
),
});
export const updateEventSchema = createEventSchema.partial();
// Zod applies defaults inside optional schemas; partial edits must not reset state.
export const updateEventSchema = createEventSchema.partial().extend({
status: createEventSchema.shape.status.removeDefault().optional(),
isRecurring: createEventSchema.shape.isRecurring.removeDefault().optional(),
image: z.preprocess(
(value) => (value === "" ? null : value),
z.string().max(500).nullable().optional(),
),
});
export const eventPrizeSchema = z.object({
eventId: z.coerce.number().int().positive(),