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.

[question] is it possible to stop parsing on the first error?

See original GitHub issue

I’m using Zod to validate HTTP payloads, some of which may be expensive to validate. Is it possible for schema.parse() and their friends to stop on the first error and return a single ZodIssue?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
irrelevationcommented, Dec 16, 2022

There is support for aborting early when using .superRefine. It is more work but might fit your use case.

2reactions
gerardolimacommented, Sep 12, 2022

hey, @colinhacks, first of all, thank you for the great work 💪🏽! I understand that’s not the intended original use case for Zod. I’m moving from Joi – which I like, but lacks the type inference Zod does so well – and my idea was to migrate all schemas. My problem is that I’ve been also using Joi to validate HTTP payloads on a Hapi service and some of those validations can be expensive.

Maybe my case is too specific, and it wouldn’t worth the changes, but maybe HTTP payload validation could be a new use case that Zod might also address 😃 Otherwise, and obviously, please, close the issue – I don’t want to bother you with things out of the scope of the project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Don't stop parsing after first exception - Stack Overflow
In general you should avoid TokenMgeErrors. Usually this can be accomplished with a "catch all" rule -- see the FAQ for details.
Read more >
TMF (Xtext) » Stop lexing and parsing ... - Eclipse Community Forums
Greetings everybody, Is it possible with Xtext 1.0.1 to tell the underlying ANTLR to stop the lexing and parsing process at the first...
Read more >
How to fix parse error there was a problem parsing ... - YouTube
How to fix Parse Error There was a problem parsing the package.1. Allow Apps Installation from Unknown Sources.2.Enable USB Debugging.3: ...
Read more >
Parse Error: What It Is and How to Fix It - Lifewire
When you get a parse error on your Android phone, it means the phone wasn't able to install your app. Check out our...
Read more >
How To Fix The WordPress Parse Error Easily - Muffin Group
A WordPress parse error is serious. It will block access to the website and readers will not be able to view the content....
Read more >

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