diff --git a/lib/validator.js b/lib/validator.js index 4e71c55..dd3b6a6 100644 --- a/lib/validator.js +++ b/lib/validator.js @@ -11,7 +11,7 @@ var thing = require('core-util-is'), * @returns {validate} */ module.exports = function validator(schemaValidator, parameter) { - var coerce, schemaValidator, validate, model; + var coerce, validate, model; if (parameter.in === 'body') { model = parameter.schema.$ref ? schemaValidator.getSchema(parameter.schema.$ref) : parameter.schema; @@ -24,7 +24,7 @@ module.exports = function validator(schemaValidator, parameter) { return function validate(data, callback) { var value, result, error, actual, type; - coerce && (data = coerce(data)); + coerce && data && (data = coerce(data)); if (data === undefined || data === null) { if (parameter.required) { @@ -91,21 +91,6 @@ function jsontype(type) { function coercion(parameter) { var fn; - function pathsep(format) { - switch (format) { - case 'csv': - return ','; - case 'ssv': - return ' '; - case 'tsv': - return '\t'; - case 'pipes': - return '|'; - case 'multi': - return '&'; - } - } - switch (parameter.type) { case 'array': fn = function (data) { @@ -152,3 +137,18 @@ function coercion(parameter) { return fn; } + +function pathsep(format) { + switch (format) { + case 'csv': + return ','; + case 'ssv': + return ' '; + case 'tsv': + return '\t'; + case 'pipes': + return '|'; + case 'multi': + return '&'; + } +} diff --git a/package.json b/package.json index b115e18..a0bc36e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "swaggerize-builder", - "version": "2.0.0-rc.1", + "version": "2.0.0-rc.2", "author": "Trevor Livingston ", "description": "Swagger based route building.", "main": "./lib/index", @@ -26,7 +26,7 @@ "scripts": { "test": "tape test/*.js", "cover": "istanbul cover tape -- test/*.js", - "lint": "jshint -c .jshintrc lib/**/*.js" + "lint": "jshint -c .jshintrc lib/*.js" }, "licenses": [ {