Skip to content

Commit

Permalink
fix(parser): provide default for value UNKNOWN if name is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMakesGames committed Apr 10, 2024
1 parent 2f754e1 commit cc76cdd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/renderer/src/lib/GameState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ export interface LocalizedText {
value: LocalizedText;
}[];
}
const localizedTextSchema: z.ZodType<LocalizedText> = z.object({
const localizedTextSchemaNoDefault: z.ZodType<LocalizedText> = z.object({
key: z.coerce.string(),
variables: z
.array(
z.object({
key: z.coerce.string(),
value: z.lazy(() => localizedTextSchema),
value: z.lazy(() => localizedTextSchemaNoDefault),
}),
)
.optional(),
});
const localizedTextSchema = localizedTextSchemaNoDefault.default({ key: 'UNKNOWN' });

const galacticObjectSchema = z.object({
name: localizedTextSchema,
Expand Down

0 comments on commit cc76cdd

Please sign in to comment.