0.0.3 • Published 9 years ago

valee v0.0.3

Weekly downloads
4
License
MIT
Repository
-
Last release
9 years ago

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:

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

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago