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

Option for strict objects by default #3414

Open
cdtut opened this issue Apr 18, 2024 · 4 comments
Open

Option for strict objects by default #3414

cdtut opened this issue Apr 18, 2024 · 4 comments

Comments

@cdtut
Copy link

cdtut commented Apr 18, 2024

With deeply nested object .strict must be added on every .object to check all keys but is easy to forget that. Option should be on parse function to check all objects strict by default. Could disable that on a particular object with z.object().strict(false). As example joi allows such option.

@colinhacks
Copy link
Owner

This is coming in Zod 4.

@cdtut
Copy link
Author

cdtut commented Apr 18, 2024

Is there roadmap to follow what else is coming in zod 4?

@colinhacks
Copy link
Owner

Not currently, since it's still in flux, but I'll be working to communicate this more completely soon.

@cdtut
Copy link
Author

cdtut commented Apr 18, 2024

I suggest something like parser = z.parser(options) to pass options like strictObjects: true so you have reusable parser object you can use all over project and use it like parser.parse(schema, object) or schema.parse(parser, object). Can such design work?

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

2 participants