velite icon indicating copy to clipboard operation
velite copied to clipboard

Body content is not generating with s.mdx().optional()

Open dgknca opened this issue 1 year ago • 1 comments

If you use s.mdx().optional() instead of s.mdx(), the body is never generated.

dgknca avatar Nov 03 '24 09:11 dgknca

Yes, this is a known issue because transform inside s.mdx() does not work when it is modified as optional.

This is related to the internal design of upstream zod, e.g.

z.string().transform(() => {
  // not execute if input undefined
}).optional() // => ZodOptional
z.string().optional().transform(() => {
  // always execute
}) // => ZodEffect

I will try to solve this issue when I have time.

zce avatar Nov 25 '24 11:11 zce