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.

break validation chain on first error

See original GitHub issue

I apologize in advanced if I missed this somewhere in the docs, but say I have the following code:

check('foo')
    .exists().withMessage('some message')
    .custom(...)

Is there a way that I can prevent custom from running if the exists check fails?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
gustavohenkecommented, Sep 8, 2018

It’s not possible yet. #500 implements a basic version of it.

2reactions
gustavohenkecommented, Aug 30, 2019

Hey all! This is out with v6.2.0! 🚢

Read more comments on GitHub >

github_iconTop Results From Across the Web

express-validator Break validator chain - node.js
The fix for this has finally landed in v3.0.0! req.getValidationResult().then( result => { var errors = result.useFirstErrorOnly().array(); // enjoy an ...
Read more >
Validation Chain API - express-validator
A validation chain created through check() or similar functions. If running that chain would produce errors, then the validation chain will stop.
Read more >
Validator Chains - Laminas Documentation
By setting $breakChainOnFailure to true , if the validator fails, it will short-circuit execution of the chain, preventing subsequent validators from executing.
Read more >
Advanced usage - Vuelidate
WARNING. BREAKING CHANGE: Since Vuelidate@2.0.0-alpha.9 the mixin has been removed. Instead, you have to use useVuelidate in your component's setup .
Read more >
Validation - Laravel - The PHP Framework For Web Artisans
Sometimes you may wish to stop running validation rules on an attribute after the first validation failure. To do so, assign the bail...
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