Skip to content

Commit

Permalink
fixed linting, fixed coercion on undefined.
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Livingston committed Sep 19, 2014
1 parent d6e4a78 commit 4f3fc3a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
34 changes: 17 additions & 17 deletions lib/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 '&';
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swaggerize-builder",
"version": "2.0.0-rc.1",
"version": "2.0.0-rc.2",
"author": "Trevor Livingston <[email protected]>",
"description": "Swagger based route building.",
"main": "./lib/index",
Expand All @@ -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": [
{
Expand Down

0 comments on commit 4f3fc3a

Please sign in to comment.