这是indexloc提供的服务,不要输入任何密码
Skip to content

*Feature Request* Example Values #5431

@Doogiemuc

Description

@Doogiemuc

Hello Zod Team!
First of all I would like to send some KUDOs. Zod is an awesome tool. Been looking for something like this for a long time.

I'd be missing one feature in zod. Wouldn't it make sense to have an .example() method to provide example values:

  zod.string(s).describe("This is the name of your customer").example("John Doe");

An example is something different than a default value. It will never be returned. It is just a guide to the caller of your API. Sure I could put the example values into the description. But think about where zod is used. For example to define a REST API. For example in Swagger/OpenAPI example values are seperate from descriptions. Same in MCP servers. Example values for api attributes are crucial for the LLM.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions