Skip to content

array field infers strange errors object #178

@kerosan

Description

@kerosan

Hi =)
image

this kind of zod schema dont work as expected


const schema = z.object({
  title: z
    .string()
    .regex(/^[A-Za-z0-9_]+$/, "wrong pattern")
    .nonempty("Required"),

  someArray: z.array(z.string().nonempty()).min(1)
});

Steps to reproduce the behavior:

    1. fill title input
    1. press submit
    1. fill array input
    1. press submit
    1. clear array input
  • in console errors changes shape of field someArray from Object to Array

https://codesandbox.io/s/gifted-hopper-k4ndp?file=/src/App.tsx

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