1.0.0 • Published 7 years ago

vtypes-bool v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

vtypes-bool

"boolean" validation for validate.js

npm package vtypes

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

nametypedefaultdescription
messagestringmust be of type booleanError message

License

vtypes-bool is MIT licensed