From 92d9e72af2118d3b8ff50cf31ba9c5bf3d4ee520 Mon Sep 17 00:00:00 2001 From: James Cross Date: Tue, 27 Jan 2026 15:37:52 +0000 Subject: [PATCH] feat(validation): make opening times optional when appointment only is selected --- src/schemas/organisationSchema.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/schemas/organisationSchema.ts b/src/schemas/organisationSchema.ts index 2d7b817..bfbbad7 100644 --- a/src/schemas/organisationSchema.ts +++ b/src/schemas/organisationSchema.ts @@ -48,13 +48,13 @@ export const AddressSchema = z.object({ Location: z.preprocess(preprocessJSON, LocationCoordinatesSchema.optional()), OpeningTimes: z.preprocess(preprocessJSON, z.array(OpeningTimeSchema).default([])), }).refine((data) => { - // If not open 24/7, must have at least one opening time - if (!data.IsOpen247) { + // If not open 24/7 and not appointment only, must have at least one opening time + if (!data.IsOpen247 && !data.IsAppointmentOnly) { return data.OpeningTimes.length > 0; } return true; }, { - message: 'At least one opening time is required when location is not open 24/7', + message: 'At least one opening time is required when location is not open 24/7 and not appointment only', path: ['OpeningTimes'] });