1.0.0 • Published 7 years ago

vtypes-string v1.0.0

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

vtypes-string

"string" validation for validate.js

npm package vtypes

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

nametypedefaultdescription
messagestringmust be of type stringError message

License

vtypes-string is MIT licensed