Feature request: `.deepStrict`
See original GitHub issueLike .deepPartial
is to .partial
it would be beneficial to have a .deepStrict
function that ensures every level in an object, array, or tuple hierarchy is .strict
.
For example, this code does not generate a ZodError:
const person = z
.object({
name: z.string(),
meta: z.object({
born: z.string(),
}),
})
.strict();
person.parse({
name: "bob dylan",
meta: {
born: "a place",
extraKey: 61,
},
});
With .deepStrict
it would work like this:
const person = z
.object({
name: z.string(),
meta: z.object({
born: z.string(),
}),
})
.deepStrict();
person.parse({
name: "bob dylan",
meta: {
born: "a place",
extraKey: 61,
},
});
// => throws ZodError
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Feature request tracking: 3 strategies to do it better
Feature requests scattered across channels? Use these 3 PROVEN strategies for tracking and managing feature requests effortlessly.
Read more >How To Manage Feature Requests [Template included]
This guide will teach you everything about feature requests – how to process them, manage them, respond to them, prioritize them – so...
Read more >Feature Requests: How to Track, Prioritize, and Manage - Pipefy
Feature requests are demands for improvement in a company's product. Click to learn how to track and prioritize these requests efficiently!
Read more >Feature request: `.deepStrict` - PullAnswer
Feature request : `.deepStrict` ... deepStrict function that ensures every level in an object, array, or tuple hierarchy is .strict .
Read more >Feature requests that don't suck - Medium
TLDR Feature requests normally suck but can be powerful if done right. Get a feature request template that works here. Feature requests are ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
When using Joi there is kind of a “global” option you can enable so that the
strict
feature will be applied recursively across all your objects by default. For sure it is a challenge to make such configuration reflect statically in the types but maybe it is a really good improvement to Zod to introduce such feature in runtime only at least.Not sure about the implementation details but from the developer perspective it would be something like this:
This is very hard to do in the static domain. Currently
.deepPartial
is very limited and error-prone for similar reasons. I’ll leave this open but I recommend usingz.strictObject
if you want a shorthand for declaring lots of strict objects without needing a method.