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: Add extra coercions #1736

Conversation

santosmarco-caribou
Copy link
Contributor

This PR adds the following extra coercions:

  1. Set -> Array in ZodArray
  2. Set -> Array in ZodTuple
  3. Array -> Set in ZodSet
  4. Object -> Map in ZodMap
  5. Map -> Object in ZodObject

@netlify
Copy link

netlify bot commented Dec 22, 2022

Deploy Preview for guileless-rolypoly-866f8a ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 3d5eba0
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/63a3d5714715cc000880eb9c
😎 Deploy Preview https://deploy-preview-1736--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 settings.

@colinhacks
Copy link
Owner

This is interesting but not worth the squeeze, in my opinion. We need to be conservative about what sorts of features make it into core as Zod gets larger, and this use case feels very niche and edge casey. It opens up Zod to a bunch of feature requests of the form "Why isn't there a coercion mode from X to Y?". Keeping z.coerce as primitive-only is the best way to draw a line in the sand.

@santosmarco-caribou
Copy link
Contributor Author

This is interesting but not worth the squeeze, in my opinion. We need to be conservative about what sorts of features make it into core as Zod gets larger, and this use case feels very niche and edge casey. It opens up Zod to a bunch of feature requests of the form "Why isn't there a coercion mode from X to Y?". Keeping z.coerce as primitive-only is the best way to draw a line in the sand.

Ok, I get what you are saying and agree with the decision.

Closing PR.

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.

None yet

3 participants