Feature errorFieldOnly option in zod catch #3664
TakhyunKim
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Feature
hello. I'm really using your library very well.
I write them because I use catch and there is a feature that I think would be nice to have in zod.
I would be grateful if you could take a look at it.
If the ZOD schema validation fails, it would be nice to have an option in the catch to update only the failed fields.
The example code and expected results are shown below.
Why I needed this feature
The purpose is to update only the failed fields when schema validation fails, as described above.
The existing code for this is shown below.
I've applied a catch for each field in the object.
Right now we only have two fields, title and contents,
but we actually have quite a few fields, so it wasn't easy to set this up.
I'd declare some sort of default value separately and approach it as follows.
errorOnlyField
would be really useful.Note
If you provide the
errorOnlyField
as an optional type and default to false, you can use theI think we can guarantee the existing catch behaviour.
Beta Was this translation helpful? Give feedback.
All reactions