Skip to content

Commit

Permalink
remove schema strictness
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Zweig committed Jan 1, 2024
1 parent 812b475 commit b5595af
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/schemas/lichess/ExportGameByIdSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@ const LightUserSchema = z
name: z.string(),
title: z.enum(PLAYER_TITLES).optional(),
patron: z.boolean().optional(),
})
.strict();
});

const PlayerAnalysisSchema = z
.object({
inaccuracy: z.number(),
mistake: z.number(),
blunder: z.number(),
acpl: z.number(),
})
.strict();
});

export const PlayerSchema = z.union([
z.strictObject({
Expand Down Expand Up @@ -77,25 +75,22 @@ const AnalysisJudgementSchema = z
.object({
name: z.enum(["Inaccuracy", "Mistake", "Blunder"]),
comment: z.string(),
})
.strict();
});

const AnalysisObjectSchema = z
.object({
eval: z.number(),
best: z.string().optional(),
variation: z.string().optional(),
judgment: AnalysisJudgementSchema.optional(),
})
.strict();
});

const GameClockSchema = z
.object({
initial: z.number(),
increment: z.number(),
totalTime: z.number(),
})
.strict();
});

const GameSchema = z
.object({
Expand All @@ -111,19 +106,17 @@ const GameSchema = z
.object({
white: PlayerSchema,
black: PlayerSchema,
})
.strict(),
}),
initialFen: z.string().optional(),
winner: z.enum(["white", "black"]).optional(),
opening: OpeningSchema.strict().optional(),
opening: OpeningSchema.optional(),
moves: z.string().optional(),
pgn: z.string().optional(),
daysPerTurn: z.number().optional(),
analysis: z.array(AnalysisObjectSchema).optional(),
tournament: z.string().optional(),
swiss: z.string().optional(),
clock: GameClockSchema.optional(),
})
.strict();
});

export default GameSchema;

0 comments on commit b5595af

Please sign in to comment.