1.0.0 • Published 7 years ago
vtypes-func v1.0.0
vtypes-func
"function" validation for validate.js
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
name | type | default | description |
---|---|---|---|
message | string | must be of type function | Error message |
License
vtypes-func
is MIT licensed
1.0.0
7 years ago