Skip to content

Fix visible validation depending on consumer zod version#299

Merged
ctate merged 2 commits into
mainfrom
fix/spec-optional-children-visible
Jun 10, 2026
Merged

Fix visible validation depending on consumer zod version#299
ctate merged 2 commits into
mainfrom
fix/spec-optional-children-visible

Conversation

@ctate

@ctate ctate commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

catalog.validate() behavior changed under consumers' zod resolution: z.any() object keys are optional on zod 4.3 but nonoptional on zod 4.4+, so a spec omitting an element's visible field validates on 4.3 and fails on 4.4. The core test suite (zod 4.3.6) asserts the optional behavior, so optional is the intent; pin it explicitly with .optional() so all zod 4.x agree.

children stays required (long-standing, zod-version-independent contract; relaxing it would change InferSpec types for consumers). Instead the default prompt rules now state explicitly that every element must include a children array, with [] for leaves, which benchmarking shows models otherwise omit on roughly a third of first attempts.

  • core: InferSpecObject honors SchemaType.optional at the type level (additive; no schema used optional before)
  • all framework schemas: visible marked ...s.optional()
  • framework prompt defaultRules: REQUIRED FIELDS rule for children
  • core: regression tests locking visible-optional and children-required

…children prompt rule

catalog.validate() behavior changed under consumers' zod resolution: z.any()
object keys are optional on zod 4.3 but nonoptional on zod 4.4+, so a spec
omitting an element's visible field validates on 4.3 and fails on 4.4. The
core test suite (zod 4.3.6) asserts the optional behavior, so optional is the
intent; pin it explicitly with .optional() so all zod 4.x agree.

children stays required (long-standing, zod-version-independent contract;
relaxing it would change InferSpec types for consumers). Instead the default
prompt rules now state explicitly that every element must include a children
array, with [] for leaves, which benchmarking shows models otherwise omit on
roughly a third of first attempts.

- core: InferSpecObject honors SchemaType.optional at the type level (additive;
  no schema used optional before)
- all framework schemas: visible marked ...s.optional()
- framework prompt defaultRules: REQUIRED FIELDS rule for children
- core: regression tests locking visible-optional and children-required
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
json-render Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-chat-demo Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-dashboard-demo Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-game-engine-demo Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-image-demo Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-no-ai Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-react-email-demo Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-react-pdf-demo Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-react-three-fiber-demo Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-remotion-demo Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-solid-demo Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-svelte-chat-demo Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-svelte-demo Ready Ready Preview, Comment Jun 10, 2026 7:41pm
json-render-vue Ready Ready Preview, Comment Jun 10, 2026 7:41pm

Comment thread packages/next/src/schema.ts
@ctate ctate merged commit c731a9c into main Jun 10, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant