feat: initialize CalBook project with comprehensive scheduling, admin, and deployment infrastructure
This commit is contained in:
52
lib/validators/public.ts
Normal file
52
lib/validators/public.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { z } from "zod";
|
||||
import { isValidTimeZone } from "@/lib/date";
|
||||
|
||||
const tokenSchema = z
|
||||
.string()
|
||||
.trim()
|
||||
.regex(/^[a-zA-Z0-9]{32,128}$/, "Token ist ungültig");
|
||||
|
||||
const timezoneSchema = z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.max(100)
|
||||
.refine((value) => isValidTimeZone(value), "Zeitzone ist ungültig");
|
||||
|
||||
export const slotsQuerySchema = z.object({
|
||||
mitarbeiterId: z.string().trim().min(1).max(128).optional(),
|
||||
datum: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
||||
timezone: timezoneSchema.optional()
|
||||
});
|
||||
|
||||
export const monthSlotsQuerySchema = z
|
||||
.object({
|
||||
mitarbeiterId: z.string().trim().min(1).max(128).optional(),
|
||||
monat: z.string().regex(/^\d{4}-\d{2}$/),
|
||||
timezone: timezoneSchema.optional(),
|
||||
requireAll: z
|
||||
.string()
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.optional()
|
||||
.transform((value) => value === "1" || value === "true" || value === "yes")
|
||||
})
|
||||
.refine((input) => !(input.requireAll && input.mitarbeiterId), {
|
||||
message: "mitarbeiterId und requireAll dürfen nicht zusammen genutzt werden"
|
||||
});
|
||||
|
||||
export const createAppointmentSchema = z.object({
|
||||
date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
||||
time: z.string().regex(/^\d{2}:\d{2}$/),
|
||||
timezone: timezoneSchema.optional(),
|
||||
mitarbeiterId: z.string().trim().min(1).max(128).optional(),
|
||||
requireAll: z.boolean().optional(),
|
||||
rescheduleToken: tokenSchema.optional(),
|
||||
customerFirstName: z.string().trim().min(1, "Vorname ist erforderlich").max(120),
|
||||
customerLastName: z.string().trim().min(1, "Nachname ist erforderlich").max(120),
|
||||
customerEmail: z.string().trim().email("E-Mail ist ungültig").max(320),
|
||||
customerPhone: z.string().trim().max(64).optional(),
|
||||
notes: z.string().trim().max(2000).optional()
|
||||
});
|
||||
|
||||
export const cancelSchema = z.object({ token: tokenSchema });
|
||||
Reference in New Issue
Block a user