vtypes-array
v1.0.0
Published
Array checking constraint for validate.js
Downloads
10
Maintainers
Readme
vtypes-array
"array" validation for validate.js
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