We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Currently validation middleware only works on req.body. It will be good if have an option to specify what needs to validated.
The text was updated successfully, but these errors were encountered:
@malavancs
If it is an option you specify, do you mean req.query, req.params?
Sorry, something went wrong.
Currently in plainToClass(type,req.body) is default. It should allow us to specify whether it is a body or query or params in function parameters.
Its a nice have option I guess.
function validationMiddleware(type: any, skipMissingProperties = false): RequestHandler { return (req, res, next) => { validate(plainToClass(type, req.body), { skipMissingProperties }) .then((errors: ValidationError[]) => { if (errors.length > 0) { const message = errors.map((error: ValidationError) => Object.values(error.constraints)).join(', '); next(new HttpException(400, message)); } else { next(); }snippets }); }; }
PS: I will make a pull request for this soon .
Thank you Bro.
Merge pull request #42 from malavancs/master
c45eaa6
#40 Added validationMiddleware support for query and params
Successfully merging a pull request may close this issue.
Currently validation middleware only works on req.body. It will be good if have an option to specify what needs to validated.
The text was updated successfully, but these errors were encountered: