28 lines
939 B
TypeScript
28 lines
939 B
TypeScript
import { z } from 'zod';
|
|
import { THEME_IDS } from '../../../common/types/theme-ids';
|
|
|
|
export const GeneralSettingsSchema = z
|
|
.object({
|
|
pageTitle: z.string().min(1).max(120),
|
|
logo: z.string().max(2048),
|
|
welcomeMarkdown: z.string().max(64_000),
|
|
themeKey: z.enum(THEME_IDS as unknown as [string, ...string[]]),
|
|
eventStartUtc: z.string(),
|
|
eventEndUtc: z.string(),
|
|
defaultChallengeIp: z.string().min(1).max(255),
|
|
registrationsEnabled: z.boolean(),
|
|
})
|
|
.superRefine((val, ctx) => {
|
|
const start = Date.parse(val.eventStartUtc);
|
|
const end = Date.parse(val.eventEndUtc);
|
|
if (Number.isFinite(start) && Number.isFinite(end) && end <= start) {
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: ['eventEndUtc'],
|
|
message: 'eventEndUtc must be strictly after eventStartUtc',
|
|
});
|
|
}
|
|
});
|
|
|
|
export type GeneralSettingsPayload = z.infer<typeof GeneralSettingsSchema>;
|