vantezzen / auto-form

🌟 A React component that automatically creates a @shadcn/ui form based on a zod schema.
https://vantezzen.github.io/auto-form/
2.27k stars 81 forks source link

if object is .optional() auto-form breaks #36

Closed grmkris closed 8 months ago

grmkris commented 8 months ago

if i have a form like:

// ❌
const schema = z.object({
  a: z.string(),
  b: z.object({
    x: z.string(),
  }).optional(),
});

autoform breaks, if i remove .optional it works

 // ✅
export const testSchema = z.object({
  a: z.string(),
  b: z.object({
    x: z.string(),
  }),
});