I use express-validator customValidators to add some specific validtors:
middlewares.js
module.exports = function (app) {
console.log('to be sure that Im called');
return function (request, response, next) {
app.use(expressValidator({
customValidators: {
checkObjectId: function(name) {
return /^[0-9a-fA-F]{24}$/.test(name);
}
}
}));
next();
}
};
route.js
const middleware = require(__path + '/middlewares');
module.exports = function (app, passport) {
router.use(baseUrl, middleware(app));
// some codes
router.put(baseUrl + '/invoice/:invoiceId', api.invoices.invoices.update);
}
invoices.js
update: (request, response) => {
// some codes
request.checkBody('from', 'invalid Supplier Id').checkObjectId();
// some codes
},
My problem is checkObjectId is not recognized and I have this error:
TypeError: request.checkBody(...).checkObjectId is not a function
via medKHELIFI
No comments:
Post a Comment