validator.js
629 Bytes
var stats = require('../helper/stats.js');
module.exports = function (req,mandatoryList,api){
var err = [];
for(var i=0;i<mandatoryList.length;i++)
{
if(typeof req.query[mandatoryList[i]] === 'undefined')
{
var errDes = {
Param : mandatoryList[i],
Reason : "Missing"
}
err.push(errDes);
}else
{
// invaild
}
}
if(err.length > 0)
stats.reciveRequest(api,false);
else
stats.reciveRequest(api,true);
// console.log(err);
return err;
};