This commit is contained in:
2026-02-04 20:29:42 -06:00
parent e37c64fb1d
commit 515ddb24d6
18 changed files with 921 additions and 19 deletions

40
validation/matches.js Normal file
View File

@@ -0,0 +1,40 @@
import { z } from 'zod';
export const MATCH_STATUS = {
SCHEDULED: 'scheduled',
LIVE: 'live',
FINISHED: 'finished',
};
export const listMatchesQuerySchema = z.object({
limit: z.coerce.number().int().positive().max(100).optional(),
});
export const matchIdParamSchema = z.object({
id: z.coerce.number().int().positive(),
});
export const createMatchSchema = z.object({
sport: z.string().min(1),
homeTeam: z.string().min(1),
awayTeam: z.string().min(1),
startTime: z.iso.datetime(),
endTime: z.iso.datetime(),
homeScore: z.coerce.number().int().nonnegative().optional(),
awayScore: z.coerce.number().int().nonnegative().optional(),
}).superRefine((data, ctx) => {
const start = new Date(data.startTime);
const end = new Date(data.endTime);
if (end <= start) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "endTime must be chronologically after startTime",
path: ["endTime"],
});
}
});
export const updateScoreSchema = z.object({
homeScore: z.coerce.number().int().nonnegative(),
awayScore: z.coerce.number().int().nonnegative(),
});