vtypes-array

1.0.0 • Public • Published

vtypes-array

"array" validation for validate.js

npm package vtypes

About

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

Installation

Using npm:

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

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

Usage

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

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

validate({attr: [], {attr: {array: 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 array Error message

License

vtypes-array is MIT licensed

/vtypes-array/

    Package Sidebar

    Install

    npm i vtypes-array

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • geraldyeo