1.0.0 • Published 8 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-funcconst 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}});
// => undefinedFor 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
8 years ago