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

feat: supports optional tuple elements #2708

Merged
merged 5 commits into from
Apr 23, 2024

Conversation

morgs32
Copy link
Contributor

@morgs32 morgs32 commented Sep 5, 2023

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?].

@netlify
Copy link

netlify bot commented Sep 5, 2023

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c2ce970
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/64f7327fe8f23e00084a86d4
😎 Deploy Preview https://deploy-preview-2708--guileless-rolypoly-866f8a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@morgs32
Copy link
Contributor Author

morgs32 commented Sep 11, 2023

@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.
I'm sure you're busy - this'll be the only time I ping you!

@colinhacks
Copy link
Owner

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.

@colinhacks colinhacks changed the base branch from master to v4 April 23, 2024 22:19
@colinhacks colinhacks force-pushed the support-optional-tuple-elements branch from c2ce970 to d3fedb1 Compare April 23, 2024 22:22
@colinhacks colinhacks merged commit 32e05cf into colinhacks:v4 Apr 23, 2024
colinhacks added a commit that referenced this pull request Apr 23, 2024
colinhacks added a commit to ytsunekawa/zod that referenced this pull request May 3, 2024
* 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>
colinhacks added a commit to ytsunekawa/zod that referenced this pull request May 3, 2024
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

Successfully merging this pull request may close these issues.

2 participants