Prefix the zod validators with a Z #219
Replies: 3 comments 2 replies
-
I would prefer something more explicit like ZodAddress but I agree that it would make things simpler than having to do something like |
Beta Was this translation helpful? Give feedback.
-
Is this a common pattern across the Zod ecosystem? I don't use Zod often and it's not the core focus of this library. We could do this in a non-breaking way by exporting new names alongside deprecating the existing exports in a patch version (haven't hit 1.0 yet so patch === minor). |
Beta Was this translation helpful? Give feedback.
-
I thought about this more and I think you should get rid of the zod validators tbh next breaking release. If you wanted to provide this functionality instead using a well typed vanilla js function like const zAddress = z.object().refine(isBytes) <- Zod is smart enough to still infer the bytes type here |
Beta Was this translation helpful? Give feedback.
-
Because zod validators have the same name as the typescript type it is inconvenient to use both in the same file. Solution is to prefix them with a z like ZAddress. This would be a breaking change though for whenever there is going to be a major version bump
Beta Was this translation helpful? Give feedback.
All reactions