zod
zod copied to clipboard
Add 'convert' effect to ZodType
Add a convert method to ZodType, to allow for transforms that may fail
Closes https://github.com/colinhacks/zod/issues/1223
Hopefully the examples in the README make the use case clear
Deploy Preview for guileless-rolypoly-866f8a ready!
Built without sensitive environment variables
Name | Link |
---|---|
Latest commit | 76263105950b1224e8769c64ca7dcfbfe6bb76ff |
Latest deploy log | https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/631794928b40320009af1203 |
Deploy Preview | https://deploy-preview-1224--guileless-rolypoly-866f8a.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
Definitely an interesting solution. I believe all of this can already by accomplished with ctx.addIssue
inside a transform, right? Admittedly that API is a bit odd, since you still need to return a value after calling ctx.addIssue
but I'm not sure it's worth introducing a new "conversion" concept. https://github.com/colinhacks/zod#validating-during-transform
@colinhacks You're right, it's already possible to achieve equivalent functionality. This PR was really about introducing a cleaner API for combining refinements and transforms.
If you feel this will add an unnecessary maintenance burden, that's fair enough.
@colinhacks This PR appears to be stale, so I've submitted an alternative solution in a new PR https://github.com/colinhacks/zod/pull/1389