fix(blocker): disallow blocker end times before start time
All checks were successful
container-scan / Container Scan (pull_request) Successful in 2m50s
docker-build / docker (pull_request) Successful in 6m16s
tests / Tests (pull_request) Successful in 3m50s

This commit is contained in:
Dominik 2025-07-01 14:40:41 +02:00
parent 6ae22a23c7
commit c014b77f9b
Signed by: dominik
GPG key ID: 06A4003FC5049644
2 changed files with 169 additions and 110 deletions

View file

@ -25,14 +25,6 @@ export const BlockedSlotsSchema = zod
created_at: zod.date(),
updated_at: zod.date(),
})
.refine(
(data) => {
return new Date(data.start_time) < new Date(data.end_time);
},
{
message: 'Start time must be before end time',
},
)
.openapi('BlockedSlotsSchema', {
description: 'Blocked time slot in the user calendar',
});
@ -47,11 +39,37 @@ export const BlockedSlotResponseSchema = zod.object({
blocked_slot: BlockedSlotsSchema,
});
export const createBlockedSlotSchema = BlockedSlotsSchema.omit({
id: true,
created_at: true,
updated_at: true,
});
export const createBlockedSlotSchema = zod
.object({
start_time: eventStartTimeSchema,
end_time: eventEndTimeSchema,
reason: zod.string().nullish(),
})
.refine(
(data) => {
return new Date(data.start_time) < new Date(data.end_time);
},
{
message: 'Start time must be before end time',
path: ['end_time'],
},
);
export const createBlockedSlotClientSchema = zod
.object({
start_time: zod.iso.datetime({ local: true }),
end_time: zod.iso.datetime({ local: true }),
reason: zod.string().nullish(),
})
.refine(
(data) => {
return new Date(data.start_time) < new Date(data.end_time);
},
{
message: 'Start time must be before end time',
path: ['end_time'],
},
);
export const updateBlockedSlotSchema = zod.object({
start_time: eventStartTimeSchema.optional(),