From cc76cdd97b2483a8893891a8ce7b988d11a3ec18 Mon Sep 17 00:00:00 2001 From: Michael Moore Date: Tue, 9 Apr 2024 19:06:03 -0500 Subject: [PATCH] fix(parser): provide default for value UNKNOWN if name is missing --- src/renderer/src/lib/GameState.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/lib/GameState.ts b/src/renderer/src/lib/GameState.ts index 5448a8d..b66d883 100644 --- a/src/renderer/src/lib/GameState.ts +++ b/src/renderer/src/lib/GameState.ts @@ -28,17 +28,18 @@ export interface LocalizedText { value: LocalizedText; }[]; } -const localizedTextSchema: z.ZodType = z.object({ +const localizedTextSchemaNoDefault: z.ZodType = 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,