zod icon indicating copy to clipboard operation
zod copied to clipboard

FEATURE REQUEST: verboseErrors to log out the object when parsing fails

Open capaj opened this issue 1 year ago • 2 comments

please give me an ability to globally enable to console error the whole object which failed validation. Currently it logs out only the validation error like this:

  {
    "expected": "'equals' | 'contains' | 'icontains' | 'javascript' | 'LLM'",
    "received": "undefined",
    "code": "invalid_type",
    "path": [
      "type"
    ],
    "message": "Required"
  }
]

every time I am debugging this I typically need to go in and log it out this myself. Ideal API would be something like

z.verboseErrors()

this would apply to both regular and safeParse ideally

capaj avatar Apr 15 '24 07:04 capaj

How you see expected and received I only see https://github.com/colinhacks/zod/issues/3402.

cdtut avatar Apr 16 '24 18:04 cdtut

z.verboseErrors() isn't needed there can be new property like ZodError.data with object given to .parse or .safeParse.

cdtut avatar Apr 17 '24 19:04 cdtut