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.
Please merge this with a Merge Request to update master
v2.13.0
What's Changed
New Features 🎉
Introduce effectType by @samchungy in Introduce
same
effectType #217This library now has a new when dealing with Zod Effects. In most scenarios, our users were using to sanitise or transform while ensuring the type did not change, however, this library could not handle this.
The new option allows this library to pick the input schema to produce a schema while ensuring that the input and output remain the same type.
For example: when creating a response (output) schema for the following type this library cannot hook into the TypeScript
compiler at runtime to understand that you wanted a string schema generated:
which meant that you had to declare the following in order to get it to work:
However, in the first example this could be dangerous if a user was to change the transform to no longer be the same type:
The new type allows us to avoid this mistake:
Refactor Effect Handling by @samchungy in Refactor Effect Handling #211, Handle Lazy Effects #214
This library now validates that effects used within registered Lazy schemas are not included in both input and output schemas. This could possibly be a breaking change if you were accidentally doing this.
This library should also provide clearer errors when using Zod Effects with registered components which should make it easier to make dealing with effects more pleasant.
Before:
effectType
After:
effectTypesameinput.openapi({type: 'same'}).openapi({type: 'string'})
Add default as an effect by @samchungy in Default Effect Values #215, Add default effect type handling #216
fix: default should be nonoptional in output state #175 added a change which would generate differences in the schema for input and outputs for a default schema. This may be a breaking change if you were using in a registered schema which is referenced in both a request and response schema. As such, can now also be used to change the rendered type.
Other Changes
New Contributors
Full Changelog: v2.12.0...v2.13.0