vtypes-string

1.0.0 • Public • Published

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

name type default description
message string must be of type string Error message

License

vtypes-string is MIT licensed

Package Sidebar

Install

npm i vtypes-string

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • geraldyeo