Open gerardolima opened 1 year ago
hi, I'd like to work on this
hi, I'd like to work on this
if this feat should be accepted to add to Zod, I'd be available to work on this too
I'm using zod to validate my app's configuration and it could be useful to automatically generate a help message, e.g. display which values correspond to which environment variables.
I wonder if instead, it wouldn't be better to have something more generic like meta
which other tools could use to retrieved metadata.
x.meta({
example: "some example",
help: "Some help message, e.g. this value corresponds to this ENV_VARIABLE"
});
x.meta()
Motivation
Zod schemas can be leveraged to automatically generate API information (ie, nestjs-zod). This is very convenient because it allows defining the validation schema and the API documentation in a single place. As Zod does not have the concept of an
.example
value, these toolings rely on.default
values to present sample values. Unfortunately, though, this breaks the semantics of.default
, on.parse
.Goal
Create the new method
.example()
onZodType
.Suggestion