Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add a method to manually add errors #26

Closed
Prinzhorn opened this Issue · 3 comments

2 participants

@Prinzhorn

I'd like to manually add validation errors for cases were complex validation is needed.

E.g.

req.validationError('name', 'Your name doesn\'t validate against our complex, possibly asynchronous validation logic.')

I don't want to mess with req._validationErrors directly.

Does this sound reasonable?

Any chance this will get pulled if I create a PR?

@Prinzhorn

I found a much more elegant solution.

expressValidator.Validator.prototype.fail = function(str) {
    this.error(this.msg);
    return this;
};

Maybe this could be added as an example. Because the documentation lacks information about how to add a validator.

@Prinzhorn Prinzhorn closed this
@damianb

if that's the case, maybe keep this open so that the documentation can be added to fix the problem :p

@Prinzhorn

if that's the case, maybe keep this open so that the documentation can be added to fix the problem :p

I'll just create a PR for the documentation. Give me a sec.

Done #27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.