`.refine` is being short circuited since 3.9.6
See original GitHub issueIn our app we used to rely on the .refine
s execution being chained, e.g.
const objectSchema = zod
.object({
length: zod.number(),
size: zod.number(),
})
.refine(({ length }) => length > 5, { path: ['length'], message: "length greater than 5" })
.refine(({ size }) => size > 7, { path: ["size"], message: "size greater than 7" });
console.log(
objectSchema.and(objectSchema).safeParse({
length: 4,
size: 4,
})
);
would yield two errors for both length and size. However, this behaviour is broken by 3.9.6. Is there a way to execute all refines that are defined on the schema? Sandbox
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
No results found
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
I was seeing this issue as well and 3.10 beta seems to have resolved it. Thanks for all hard work @colinhacks
This was a total nightmare and led to me rewriting the entire parser. Classic.
Try the 3.10 beta and let me know how its working:
yarn add zod@beta