vtypes-func

1.0.0 • Public • Published

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

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

License

vtypes-func is MIT licensed

/vtypes-func/

    Package Sidebar

    Install

    npm i vtypes-func

    Weekly Downloads

    6

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • geraldyeo