velite
velite copied to clipboard
Body content is not generating with s.mdx().optional()
If you use s.mdx().optional() instead of s.mdx(), the body is never generated.
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.