From 6b2c9945b7fb5772c439378e5f0c02bcc22d3cfb Mon Sep 17 00:00:00 2001 From: Trevin Chow Date: Wed, 1 Apr 2026 22:21:03 -0700 Subject: [PATCH] fix(core): preserve runtime fields in validate() with passthrough Zod's default parse mode strips unknown keys. Element runtime fields (on, repeat, watch, state) aren't in the validation schema, so they were silently removed. Use .passthrough() on object and record schemas so unknown keys survive validation while known fields are still checked. Fixes #222 --- packages/core/src/schema.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/src/schema.ts b/packages/core/src/schema.ts index c5824454..f4131341 100644 --- a/packages/core/src/schema.ts +++ b/packages/core/src/schema.ts @@ -499,11 +499,14 @@ function buildZodType(schemaType: SchemaType, catalogData: unknown): z.ZodType { } zodShape[key] = zodType; } - return z.object(zodShape); + return z.object(zodShape).passthrough(); } case "record": { const inner = buildZodType(schemaType.inner as SchemaType, catalogData); - return z.record(z.string(), inner); + return z.record( + z.string(), + inner instanceof z.ZodObject ? inner.passthrough() : inner, + ); } case "ref": { // Reference to catalog key - create enum of valid keys