Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support enumDescriptions #3673

Open
remcohaszing opened this issue Jul 25, 2024 · 0 comments
Open

Support enumDescriptions #3673

remcohaszing opened this issue Jul 25, 2024 · 0 comments

Comments

@remcohaszing
Copy link

The VSCode JSON schema integration supports a custom field enumDescriptions to describe each enum value individually. This is used by various other editors as well. It would be neat if Zod supports this field too, for example:

const kin = z
  .enum([
    'elf',
    'dwarf',
    'human'
  ])
  .describe('Your character lineage', [
    'Elves are a magical people of otherworldly grace',
    'Bold and hardy, dwarves are known as skilled warriors, miners, and workers of stone and metal',
    'Humans are the most adaptable and ambitious people among the common kin'
  ])

console.log(kin.enumDescriptions)
// [
//   'Elves are a magical people of otherworldly grace',
//   'Bold and hardy, dwarves are known as skilled warriors, miners, and workers of stone and metal',
//   'Humans are the most adaptable and ambitious people among the common kin'
// ]
@remcohaszing remcohaszing changed the title Support enumDescriptions. Support enumDescriptions Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant