洪 民憙 (Hong Minhee) :nonbinary:'s avatar
洪 民憙 (Hong Minhee) :nonbinary:

@hongminhee@hollo.social

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.

https://github.com/dahlia/optique/issues/39

Mike Roberts's avatar
Mike Roberts

@mikebroberts@hachyderm.io · Reply to 洪 民憙 (Hong Minhee) :nonbinary:'s post

@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!

洪 民憙 (Hong Minhee) :nonbinary:'s avatar
洪 民憙 (Hong Minhee) :nonbinary:

@hongminhee@hollo.social · Reply to 洪 民憙 (Hong Minhee) :nonbinary:'s post

Update: Just added automatic metavar inference!

The help text now gets smarter labels based on your Zod schema:

  • z.string().email()EMAIL
  • z.coerce.number().int()INTEGER
  • z.enum([…])CHOICE

No manual configuration needed.

https://github.com/dahlia/optique/commit/d4903dfdb88727a488dedb6a73ad8997868246e1