feat(zod): adds zx.convertCaseCodec, zx.deepCamelCaseCodec and zx.deepSnakeCaseCodec
#523
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #522
new features
zx.convertCaseCodeczx.deepCamelCaseCodec(experimental)zx.deepSnakeCaseCodec(experimental)This change adds a new transformer for the
@traversable/zodpackage that uses a new feature that was added in zod v4: codecs.Because of how easy
zx.foldis to work with, implementingzx.convertCaseCodecwas relatively simple, and took me about an hour.Usually I'd fuzz test the hell out of it before publishing, but this time I figured I'd release these early, to have a chance for users to use it and provide feedback before I go through the trouble.
Note
Currently there is no type-level support for these transformers. I'm still trying to decide if doing that would be a good idea.
My current thinking is that it would be better to implement
.writeablevariants (for example,zx.deepCamelCaseCodec.writeable) – if we did that, it would be trivial to also generate the to/from types as well usingzx.toType.If you use this and run into any problems, please don't hesitate to open an issue!