has no method checkBody
See original GitHub issueI am using express 4.11.1 and express-validator 2.8.0.
here is the code i used above post action:
var util = require('util');
var express = require('express');
var bodyParser = require('body-parser');
var expressValidator = require('express-validator');
var app = express();
and inside post action i gave
req.checkBody(‘postparam’, ‘Invalid postparam’).notEmpty().isInt();
i am getting has no method checkBody error, don know whether version is the problem so mentioned the versions above.
Issue Analytics
- State:
- Created 9 years ago
- Comments:6
Top Results From Across the Web
"req.checkBody is not a function"? - Stack Overflow
When I submit a form whose contents are validated using express-validator I keep getting the error "req.checkBody is not a function" (and if ......
Read more >How to use notEmpty function in Validator - Javascript - Tabnine
req.checkBody('password', 'Password is empty!!').notEmpty()
Read more >koa-validate - npm
checkBody (fieldName,[transFn]) - check POST body. ,transFn see json-path.it will not use json path if transFn is false . checkQuery(fieldName,[ ...
Read more >Legacy API - express-validator
It's based around setting a global middleware in your express app and decorating the request object with new methods. This API MUST NOT...
Read more >req.checkBody(…).optional(…).isDate is not a function” - Learn
Need help finding rootcause of “TypeError: req.checkBody(…).optional(…).isDate is not a function” I am trying to find the root cause of this error I...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just a clarifying comment on this issue: make sure you “use” your routers after you have added expressValidator. (Which makes sense but I had too look for this for a while)
Looks like you forgot to register the bodyParser and expressValidator middleware with the app (which will add the validation methods to the request object).
Try: