Adds a iso8601 helper function to parse a ISO Date String into a Date (#5039)
parent
0fc1449dd9
commit
d8489a662e
|
@ -58,6 +58,20 @@ export const recurringEventType = z
|
|||
})
|
||||
.nullable();
|
||||
|
||||
// dayjs iso parsing is very buggy - cant use :( - turns ISO string into Date object
|
||||
export const iso8601 = z.string().transform((val, ctx) => {
|
||||
const time = Date.parse(val);
|
||||
if (!time) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "Invalid ISO Date",
|
||||
});
|
||||
}
|
||||
const d = new Date();
|
||||
d.setTime(time);
|
||||
return d;
|
||||
});
|
||||
|
||||
export const bookingLimitsType = z
|
||||
.object({
|
||||
PER_DAY: z.number().optional(),
|
||||
|
|
Loading…
Reference in New Issue