Skip to content
This repository has been archived by the owner on May 5, 2018. It is now read-only.

Commit

Permalink
Merge pull request #6 from phillip-hall/master
Browse files Browse the repository at this point in the history
Fix issue coercing boolean value
  • Loading branch information
jsdevel committed Mar 9, 2016
2 parents f932414 + 33a4bdb commit 9464880
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ var COERCION_STRATEGIES = {
},

boolean: function(input) {
if (typeof input === 'boolean') {
return input;
}

if (input === 'false') {
return false;
} else {
Expand Down
19 changes: 17 additions & 2 deletions test/data-driven/coerce-boolean-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@ module.exports = {
in: 'path',
name: 'path2',
type: 'boolean'
},

{
in: 'query',
name: 'query1',
type: 'boolean'
},

{
in: 'query',
name: 'query2',
type: 'boolean'
}
]
},

requestPath: '/true/false',
requestPath: '/true/false?query1=true&query2=false',

requestHeaders: null,

Expand All @@ -26,5 +38,8 @@ module.exports = {
path2: false
},

query: null
query: {
query1: true,
query2: false
}
};

0 comments on commit 9464880

Please sign in to comment.