1.0.0 • Published 7 years ago

vtypes-func v1.0.0

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

vtypes-func

"function" validation for validate.js

npm package vtypes

About

The function validator attempts to ensure that the field is a valid function.

Installation

Using npm:

$ npm i --save vtypes-func
const validate = require('validate.js');
const vFunc = require('vtypes-func');

// you can then proceed to register the required validators.
validate.validators.func = vFunc;

Usage

validate({}, {attr: {func: true}});
// => undefined

validate({attr: 'foo'}, {attr: {func: true}});
// => {attr: ["Attr must be of type function"]}

validate({attr: function(){}, {attr: {func: true}});
// => undefined

For more examples, check out the test files in this package's source folder.

Available Options

nametypedefaultdescription
messagestringmust be of type functionError message

License

vtypes-func is MIT licensed