I have the following post request that validates some data:
app.post(
"/review",
[
// Add the middleware to validate email and restaurant info below:
check("email").isEmail(),
check("restaurant").notEmpty().blacklist("<>"),
check("rating").isNumeric(),
check("review").notEmpty().blacklist("<>")
],
// ...
The documentation for validator.js demonstrates to use the blacklist method as follows:
blacklist(input, '\\[\\]')
Considering the context of how i'm adding my middleware, it's a bit confusing to understand what exactly should be the input parameter. I'm already using the check method to look for the input field, what exactly should go in the blacklist method?
Since you are using [express-validator][1] which works as a wrapper over [validator.js][1], the input is injected to the blacklist method by the express-validator and in your case, since you are using check() method of express-validator the input will be the parameter with the label that you have provided as the argument to check() method which might exist in any of the following request objects:
req.bodyreq.cookiesreq.headersreq.paramsreq.queryIn your case for check("restaurant").notEmpty().blacklist("<>"), a parameter with the label of restaurant will be extract from either one of the aforementioned request objects and for check("review").notEmpty().blacklist("<>"), a parameter with the label review will be extracted.
So the only argument that should be provided for the check method is a regex string which specifies the characters that must get removed.