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

Descriptions from root schema carry over to schemas created with a chained .array() #3529

Open
EthanBehrends opened this issue May 25, 2024 · 0 comments

Comments

@EthanBehrends
Copy link
Contributor

Related to changes made in #1756.

The above PR addresses an issue where descriptions would not carry over to schemas created using the chaining helper methods, like .optional().

// Before the above changes
z.string().describe("a description").description // "a description"
z.string().describe("a description").optional().description // undefined

// After
z.string().describe("a description").description // "a description"
z.string().describe("a description").optional().description // "a description"

The changes to fix this issue were also applied to .array(), which results in some unexpected behavior.

// With this bug,
z.string().describe("a description").array()
// is equivalent to:
z.string().describe("a description").array().describe("a description")
// but this works as expected
z.array(z.string().describe("a description"))

The fix was super simple, I'll open a PR shortly!

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