validating

0.0.6 • Public • Published

Validating

Build Status

Installation

Via npm:

npm install --save validating

or bower:

bower install --save validating

Usage

Create a function which can validate objects

var validating = require('validating');
 
var userDescriptors = {
  name: {
    rules: [
      ['required'],
      ['regexp', {pattern: /^[A-Za-z][A-Za-z0-9]*$/}]
    ]
  },
  email: {
    rules: [
      {name: 'email'},
      {name: 'required'}
    ]
  }
};
 
 
var validateUser = validating.forDescriptors(userDescriptors);
 
var result = validateUser({
  name: null,
  email: 'not a valid email address...'
});
 
console.log(result.valid);
console.log(result.errors);
 

Running the tests

First, npm install, then npm test. Code coverage generated with npm run coverage.

License

MIT, see LICENSE.md.

Package Sidebar

Install

npm i validating

Weekly Downloads

7

Version

0.0.6

License

MIT

Last publish

Collaborators

  • charlespick