[TASK] Add src/Tools.js containing small helper functions.
This commit is contained in:
1 parent
f63afa6c10
commit
eecbca2907
1 file changed
+13
@@ -0,0 +1,13 @@
|
||||
//check whether all given params exist in an object
|
||||
//var success = .reqParamsGiven(["username", "password"], req.body);
|
||||
exports.reqParamsGiven = function (keys, obj) {
|
||||
if(typeof(obj) != "object" || obj.length < 1) return false;
|
||||
for(k in keys) {
|
||||
var key = keys[k];
|
||||
var value = obj[key];
|
||||
if(value == undefined) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user