From e89211ab72ffa88a2b879c04e801f3b5c03dad59 Mon Sep 17 00:00:00 2001 From: oleg Date: Tue, 29 Dec 2015 23:31:05 +0300 Subject: [PATCH] add forgotten validate params module --- lib/validateParams.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/validateParams.js diff --git a/lib/validateParams.js b/lib/validateParams.js new file mode 100644 index 0000000..8f8bd8f --- /dev/null +++ b/lib/validateParams.js @@ -0,0 +1,19 @@ +'use strict'; + +var conform = require('conform'), + _ = require('underscore'); + +module.exports = function(params, schema, validateOptions) { + var defaultValidateOptions = { + additionalProperties: true, + failOnFirstError: true, + cast: true, + castSource: true, + applyDefaultValue: true + }; + + conform.validate(params, schema, _({}).extend( + defaultValidateOptions, validateOptions + )); + return params; +};