2.0.2 • Published 6 years ago

@ryanburnette/validator-factory v2.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

@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 } 
2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago