vtypes-string
v1.0.0
Published
Additional constraints for validate.js
Downloads
9
Maintainers
Readme
vtypes-string
"string" validation for validate.js
About
The string
validator attempts to ensure that the field is a valid string.
Installation
Using npm:
$ npm i --save vtypes-string
const validate = require('validate.js');
const string = require('vtypes-string');
// you can then proceed to register the required validators.
validate.validators.string = string;
Usage
validate({}, {attr: {string: true}});
// => undefined
validate({attr: false}, {attr: {string: true}});
// => {attr: ["Attr must be of type string"]}
validate({attr: 'foo', {attr: {string: 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 string
| Error message |
License
vtypes-string
is MIT licensed