boolify
Convert true/false strings to booleans
Example
var boolify =// true// false// "A string"var obj =// {// t: true,// f: false,// s: 'Another string',// n: 5// }// true// true
Usage
boolify
is case-insensitive and will convert any string of "true"
or "false"
in to the
appropriate boolean.
This is helpful for handling checkboxes in express' req.body
app
boolify(object | string)
If provided an object, boolify
will recursively convert all values.
var result =console// true
Install
With npm do:
npm install boolify
See also
- yn supports additional values for booleans, both uppercase and lowercase, and returns null when a value is recognized is neither
true
orfalse
License
MIT