This package has been deprecated

Author message:

No longer maintained

@ryanburnette/validator-factory

2.0.2 • Public • Published

@ryanburnette/validator-factory

npm version

Description

An implementation of Validate.js as a factory for creating JavaScript object validators.

This library is structured for use in Node.js, but should work fine in the browser if it is packaged with Webpack.

Usage

npm install @ryanburnette/validator-factory
var ValidatorFactory = require('@ryanburnette/validator-factory');

var validate = ValidatorFactory.create({
  constraints: {
    foo: {
      presence: true,
      length: {
        minimum: 3
      }
    },
    email: {
      presence: true,
      email: true
    }
  },
  options: {
    fullMessages: false
  }
});

validate({
  email: 'lois.griffin'
})
// => { body: { email: 'lois.griffin' }, validation: { foo: [ "can't be blank" ], email: [ 'is not a valid email' ] } }

validate({
  foo: 'abc',
  email: 'lois.griffin@gmail.com'
})
// => { body: { foo: 'abc', email: 'lois.griffin@gmail.com' }, validation: false } 

Readme

Keywords

none

Package Sidebar

Install

npm i @ryanburnette/validator-factory

Weekly Downloads

0

Version

2.0.2

License

ISC

Unpacked Size

3.67 kB

Total Files

5

Last publish

Collaborators

  • ryanburnette