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

Add a method to manually add errors #26

Closed
Prinzhorn opened this issue Mar 27, 2013 · 4 comments
Closed

Add a method to manually add errors #26

Prinzhorn opened this issue Mar 27, 2013 · 4 comments

Comments

@Prinzhorn
Copy link

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
Copy link
Author

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.

@katanacrimson
Copy link

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

@Prinzhorn
Copy link
Author

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

@lock
Copy link

lock bot commented Jun 2, 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 2, 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