question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`.refine` is being short circuited since 3.9.6

See original GitHub issue

In our app we used to rely on the .refines 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:closed
  • Created 2 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
bcinmancommented, Oct 13, 2021

I was seeing this issue as well and 3.10 beta seems to have resolved it. Thanks for all hard work @colinhacks

2reactions
colinhackscommented, Oct 12, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found