-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: supports optional tuple elements #2708
feat: supports optional tuple elements #2708
Conversation
✅ Deploy Preview for guileless-rolypoly-866f8a ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
@colinhacks I think this one is a small footprint, no new features, just a fix. It adds functionality that many might presume already exists of the z.tuple() method. |
Thanks! I'm merging this as a starting point, but it'll undergo a lot of change before then. Some variant of this will land in Zod 4 but it'll be a while. |
c2ce970
to
d3fedb1
Compare
This reverts commit 32e05cf.
* feat: supports optional tuple elements * fix: adds type assertions for optional elements in tuple * fix: minItems equals num elements before only optionals * fix: adds findMinItems() for tuple.minItems * Build deno --------- Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
This reverts commit 32e05cf.
I see that the last test on tuples for this feature was commented out... hopefully just for want of a little more work?
Let me know?! Forgive me if there are any instructions I should have followed in creating this PR.
Also see the type assertions. I'm trying to use tuples as a schema for the params of a function with optional parameters. So
[number | undefined]
won't match, it has to be something like[number?]
.