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

CreateParams get lost when calling any of the root-level methods #1743

Closed
santosmarco-caribou opened this issue Dec 22, 2022 · 2 comments · Fixed by #1756
Closed

CreateParams get lost when calling any of the root-level methods #1743

santosmarco-caribou opened this issue Dec 22, 2022 · 2 comments · Fixed by #1756
Labels
bug-confirmed Bug report that is confirmed

Comments

@santosmarco-caribou
Copy link
Contributor

const MySchema = z.string({ description: 'this is a string schema' }).optional()
// => No longer has the description associated with it

This is because we are not passing the CreateParams to these methods on the root-level ZodType class.

Instead of:

nullable() {
  ZodNullable.create(this);
}

We should find a way to pass the CreateParams as well.

nullable() {
  ZodNullable.create(this, /* => */ params);
}
@JacobWeisenburger
Copy link
Collaborator

Confirmed

const schema = z.string( { description: 'this is a string schema' } )
console.log( schema.description ) // this is a string schema
console.log( schema.optional().description ) // undefined

@JacobWeisenburger JacobWeisenburger added the bug-confirmed Bug report that is confirmed label Dec 24, 2022
@santosmarco-caribou
Copy link
Contributor Author

Here's a PR to fix that:

#1756

@JacobWeisenburger JacobWeisenburger linked a pull request Dec 31, 2022 that will close this issue
JacobWeisenburger added a commit that referenced this issue Dec 31, 2022
…rams

fix(#1743): Fix passing params in root class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-confirmed Bug report that is confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants