valee

0.0.3 • Public • Published

valee

Travis Build Coverage Status

A validator for (nested) objects with a simple API. For sanitizing objects, check out sanee.

Usage

Installation

$ npm install valee

Example

var valee = require('valee');

// define schema
var validate = valee({
	acceptAgreement: valee.isIn(['0', '1']),
	request: {
		ip: valee.isIP()
	},
	user: {
		firstName: valee.isLength(1).isUppercase(),
		email: valee.isEmail()
	}
});

// validate data
var errors = validate({
	acceptAgreement: '1',
	request: {
		ip: '192.168.0.1'
	},
	user: {
		firstName: 's',
		email: 'valid@email.com'
	}
});

// print errors
console.log(errors);

Output:

{
	user: {
		firstName: true
	}
}

Validators

All validators of valee currently map to the validators of validator.js.

Todo:

  • [x] Validation chaining
  • [x] Nested objects
  • [x] Sanitizers (sanee)
  • [ ] Custom validators
  • [ ] Automatic error messages
  • [ ] Custom error messages
  • [ ] required/notRequired

Readme

Keywords

none

Package Sidebar

Install

npm i valee

Weekly Downloads

0

Version

0.0.3

License

MIT

Last publish

Collaborators

  • maximilianschmitt