What validations/refinements should be in "core"? #536
Replies: 3 comments 3 replies
-
This is a really important topic! My bias is towards keeping core smallish, and make it easy to extend - provide code examples, etc. However in our own zod practice at Medzy we haven't yet found a pattern for extending zod that really resonated with us aesthetically. |
Beta Was this translation helpful? Give feedback.
-
I don't mind refine at all. I can see where people want a proper place to stash metadata though. I made a lib that uses a wrapper pattern and it's ok. But that's not going to be as great with |
Beta Was this translation helpful? Give feedback.
-
Having each consumer write their own refinements using |
Beta Was this translation helpful? Give feedback.
-
It seems like we get a lot of issues asking for extensions to the built-in class of validations, and I wondered what the general philosophy we want to take here is.
In my view, I feel like
refine
is the right level of abstraction to allow each consumer to define their own set of validations that they find useful, but I can sympathize with those whose usage of Zod include heavy usage of validation logic and it's slightly more ergonomic to have them as methods on the types.I'd love to be able to point issue authors and PR authors at some idea of our general feelings here, but I don't want to impose my minimalist view if I'm in the minority, or if there is a helpful heuristic as to which kinds of validations we want to encourage people to author.
Beta Was this translation helpful? Give feedback.
All reactions