Updating
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { z } from "zod";
|
||||
import { HANDEDNESS_OPTIONS, POSITIONS } from "@/lib/constants";
|
||||
|
||||
const optionalStat = z.union([z.coerce.number().int().min(0), z.null()]).optional();
|
||||
|
||||
export const playerSchema = z.object({
|
||||
firstName: z.string().trim().min(1, "First name is required."),
|
||||
lastName: z.string().trim().min(1, "Last name is required."),
|
||||
@@ -10,7 +12,22 @@ export const playerSchema = z.object({
|
||||
secondaryPosition: z.enum(POSITIONS).nullable().optional(),
|
||||
tertiaryPosition: z.enum(POSITIONS).nullable().optional(),
|
||||
isActive: z.boolean(),
|
||||
notes: z.string().max(500).optional().default("")
|
||||
notes: z.string().max(500).optional().default(""),
|
||||
stats: z
|
||||
.object({
|
||||
gamesPlayed: optionalStat,
|
||||
atBats: optionalStat,
|
||||
runs: optionalStat,
|
||||
hits: optionalStat,
|
||||
doubles: optionalStat,
|
||||
triples: optionalStat,
|
||||
homeRuns: optionalStat,
|
||||
runsBattedIn: optionalStat,
|
||||
walks: optionalStat,
|
||||
strikeouts: optionalStat,
|
||||
stolenBases: optionalStat
|
||||
})
|
||||
.optional()
|
||||
});
|
||||
|
||||
export const pitchingAppearanceSchema = z.object({
|
||||
@@ -52,3 +69,28 @@ export const saveLineupSchema = generateLineupSchema.extend({
|
||||
bench: z.array(z.string()),
|
||||
notes: z.array(z.string())
|
||||
});
|
||||
|
||||
export const saveGameSchema = z.object({
|
||||
gameDate: z.string().min(1),
|
||||
lineupId: z.string().min(1),
|
||||
opponent: z.string().max(120).optional().default(""),
|
||||
teamScore: z.union([z.coerce.number().int().min(0), z.null()]).optional(),
|
||||
opponentScore: z.union([z.coerce.number().int().min(0), z.null()]).optional(),
|
||||
notes: z.string().max(1000).optional().default(""),
|
||||
playerStats: z.array(
|
||||
z.object({
|
||||
playerId: z.string().min(1),
|
||||
playerName: z.string().min(1),
|
||||
atBats: optionalStat,
|
||||
runs: optionalStat,
|
||||
hits: optionalStat,
|
||||
doubles: optionalStat,
|
||||
triples: optionalStat,
|
||||
homeRuns: optionalStat,
|
||||
runsBattedIn: optionalStat,
|
||||
walks: optionalStat,
|
||||
strikeouts: optionalStat,
|
||||
stolenBases: optionalStat
|
||||
})
|
||||
)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user