Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dgknca opened this issue Nov 3, 2024 · 1 comment
Open

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

dgknca opened this issue Nov 3, 2024 · 1 comment

Comments

@dgknca
Copy link

dgknca commented Nov 3, 2024

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

@zce
Copy link
Owner

zce commented Nov 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants