vtypes-bool

1.0.0 • Public • Published

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

name type default description
message string must be of type boolean Error message

License

vtypes-bool is MIT licensed

Package Sidebar

Install

npm i vtypes-bool

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • geraldyeo