1.0.0 • Published 7 years ago

vtypes-array v1.0.0

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

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

nametypedefaultdescription
messagestringmust be of type arrayError message

License

vtypes-array is MIT licensed