From eecbca2907706f54a2ff293a6305936a8355076a Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sun, 15 Sep 2013 13:45:54 +0200 Subject: [PATCH] [TASK] Add src/Tools.js containing small helper functions. --- src/Tools.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/Tools.js diff --git a/src/Tools.js b/src/Tools.js new file mode 100644 index 0000000..253254c --- /dev/null +++ b/src/Tools.js @@ -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; +} \ No newline at end of file