unreal - Hello, i have this schema tsconst som...
Hello, i have this schema and the guy of the front-end is sending
{ description: null }
, but zod is giving me the error of the image, any ideia?5 Replies
The issue is that the
.nullable()
and .optional()
methods are being applied to the value associated with the "description" key only. The original z.object()
that's wrapping your keys is still required to be provided to properly validate.
Here is the code that works based on your schema above:
wait... isn't that the same thing?
The OP schema absolutely should be able to parse
{ description: null }
@Scott Trinh Wow, I misread OP. I missed the curly braces originally and understood the problem to be that only
null
was being sent. That's my mistake. Looks like I need a nap hahaIt's usually me that transposes some issue like that, so no worries at all 😅
yea this def should work
@unreal are you using this schema directly? Or is it used in another schema