express-params-checker
Advanced tools
Comparing version 1.0.4 to 1.1.0
const _ = require('lodash') | ||
exports.has = (...requiredFields) => { | ||
module.exports = (...requiredFields) => { | ||
const checkFunc = (req) => { | ||
let para = _.extend({}, req.query, req.body, req.params) | ||
let parameters = _.extend({}, req.query, req.body, req.params) | ||
for(let i = 0; i < requiredFields.length; i++){ | ||
if(!_.has(para, requiredFields[i])){ | ||
if(!_.has(parameters, requiredFields[i])){ | ||
let err = new Error(`Missing parameter: ${requiredFields[i]}`) | ||
@@ -13,3 +13,4 @@ err.status = 400 | ||
} | ||
req.para = para | ||
req.parameters = parameters | ||
req.data = parameters | ||
} | ||
@@ -16,0 +17,0 @@ |
{ | ||
"name": "express-params-checker", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
861
19