Optique 0.7.0 will support Zod schemas as value parsers.
-
Optique 0.7.0 will support Zod schemas as value parsers.
Seemed like a natural fit—same validation logic for both CLI and app code.
-
@hongminhee I’m a recent zod convert. Still wrapping my head around when and when not to use transforms / codecs - but I very much like the combination of static and runtime type checking in one definition. I was using AJV in a couple of places before, but zod has won me over.
I don't have any CLI tools I'm working on at the moment, but will look at Optique if I do!
-
@hongminhee I’m a recent zod convert. Still wrapping my head around when and when not to use transforms / codecs - but I very much like the combination of static and runtime type checking in one definition. I was using AJV in a couple of places before, but zod has won me over.
I don't have any CLI tools I'm working on at the moment, but will look at Optique if I do!
@mikebroberts@hachyderm.io Zod's a solid choice! The transform stuff can be tricky at first but becomes second nature.
Let me know if you end up trying Optique—always curious to hear feedback.
-
Update: Just added automatic metavar inference!
The help text now gets smarter labels based on your Zod schema:
z.string().email()→EMAILz.coerce.number().int()→INTEGERz.enum([…])→CHOICE
No manual configuration needed.
https://github.com/dahlia/optique/commit/d4903dfdb88727a488dedb6a73ad8997868246e1