Skip to content

fix: Element visible field rejected as required under Zod 4.4 #287

@joshuaboys

Description

@joshuaboys

Hey I'm running into a validation failure after bumping zod 4.3.6 → 4.4.3 in our app.

Using @json-render/react@0.18.0 (also checked 0.19.0 on npm, same behaviour, and this is what made me notice the github release mismatch).

The visible field on elements is now being treated as required

  import { z } from 'zod';
  import { schema } from '@json-render/react';

  const catalog = schema.createCatalog({
    components: {
      Stack: { props: z.object({}), description: 'box', example: {} },
    },
    actions: {},
  });

  const result = catalog.validate({
    root: 'main',
    elements: {
      main: { type: 'Stack', props: {}, children: [] },
    },
  });

console.log(result);
  // {
  //   success: false,
  //   error: ZodError: [
  //     {
  //       code: 'invalid_type',
  //       expected: 'nonoptional',
  //       path: [ 'elements', 'main', 'visible' ],
  //       message: 'Invalid input: expected nonoptional, received undefined'
  //     }
  //   ]
  // }

On zod 4.3.6 the same call succeeds. Not sure if this is a zod 4.4 compatibility thing or something on our end.

Versions:

  • @json-render/core@0.18.0, @json-render/react@0.18.0, @json-render/shadcn@0.18.0, (about to install @json-render/react-email@0.18.0)
  • zod@4.4.3 (any 4.4.x reproduces)
  • Node 24, pnpm 10

Happy to dig in further if useful

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions