0.1.1 • Published 12 years ago

super-valid v0.1.1

Weekly downloads
11
License
-
Repository
-
Last release
12 years ago

super-valid

Validation-framework for NodeJS

Installation

$ npm install super-valid

Usage

var SuperValid = require('super-valid');

var errors = SuperValid
                .assert("name", req.params.name)
                  .longerThan(5, "Name too short")
                  .shorterThan(15, "Name too long")
                .assert("age", req.params.age)
                  .isInt("Not a number")
                  .greaterThan(18, "Age too little")
                  .errors();
if(errors) {
  console.log(errors);
    /* Will produce
    {
      name : {
        value : '[the value supplied]',
        error : 'Name too long', // The most recent error
        errors : ['Name too short', 'Name too long'] // All the errors
      },
      age : {
        value : '[the value supplied]',
        errors : 'Age too little',
        errors : ['Not a number', 'Age too little']
      }
    } 
    */
}
0.1.1

12 years ago

0.1.0

12 years ago