There are some utilities I use locally for which I'm looking for a home. I'm happy to contribute them here or -- if you prefer -- create my own zod-contrib package.
[ ] timestamp.{ms,s}: z.numbers that are branded as a Timestamp<ms> and Timestamp<s> respectively to avoid confusion with other units. Sane defaults for min and max to ensure users don't try to parse ms as s and vice versa
[ ] color.{hex,hsl,hsla,lch,rgb,rgba}: branded z.strings, plus a color that's a union of them
[ ] response: validate status, headers of a Response; chains for parsing text or json body (requires parseAsync)
There are some utilities I use locally for which I'm looking for a home. I'm happy to contribute them here or -- if you prefer -- create my own
zod-contrib
package.timestamp.{ms,s}
:z.number
s that are branded as aTimestamp<ms>
andTimestamp<s>
respectively to avoid confusion with other units. Sane defaults formin
andmax
to ensure users don't try to parsems
ass
and vice versacolor.{hex,hsl,hsla,lch,rgb,rgba}
: brandedz.string
s, plus acolor
that's a union of themresponse
: validate status, headers of aResponse
; chains for parsingtext
orjson
body (requiresparseAsync
)jsonSchema
: the JSON type from the zod READMEjsonString
: az.string
that does a refining transform to a JSON object (input: string, output: jsonSchema); great for piping into other schemasThe end result is something you can use to validate & type responses from a CMS:
Would any of this be a good fit here?