Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to stop cascade validation on first fail for performance purpose #696

Closed
singno opened this issue Mar 29, 2019 · 2 comments
Closed

Comments

@singno
Copy link

singno commented Mar 29, 2019

Consider this example:

const { check } = require('express-validator/check');

app.post('/user', [
check('password').custom((value, { req }) => {
    if (value !== req.body.passwordConfirmation) {
      throw new Error('Password confirmation is incorrect');
    }
  }),
  check('email').custom(value => {
    return User.findByEmail(value).then(user => {
      if (user) {
        return Promise.reject('E-mail already in use');
      }
    });
  })
], (req, res) => {
  // Handle the request somehow
});

I don't want the check('email') execute when check('password') has already fails.

@gustavohenke
Copy link
Member

Duplicate of #638

@gustavohenke gustavohenke marked this as a duplicate of #638 Apr 24, 2019
@lock
Copy link

lock bot commented Jun 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants