vtypes-bool
v1.0.0
Published
Additional constraints for validate.js
Downloads
2
Maintainers
Readme
vtypes-bool
"boolean" validation for validate.js
About
The bool
validator attempts to ensure that the field is a valid boolean.
Installation
Using npm:
$ npm i --save vtypes-bool
const validate = require('validate.js');
const bool = require('vtypes-bool');
// you can then proceed to register the required validators.
validate.validators.bool = bool;
Usage
validate({}, {attr: {bool: true}});
// => undefined
validate({attr: 'foo'}, {attr: {bool: true}});
// => {attr: ["Attr must be of type boolean"]}
validate({attr: true, {attr: {bool: true}});
// => undefined
validate({attr: false, {attr: {bool: true}});
// => undefined
For more examples, check out the test files in this package's source folder.
Available Options
| name | type | default | description |
| ------- | ------ | ------------------------- | ------------- |
| message | string | must be of type boolean
| Error message |
License
vtypes-bool
is MIT licensed