lib/validator.js
function validate(rules, args, cb) {
  try {
    _known(rules, args);
    _required(rules, args);

    Object.keys(args).forEach(function (arg) {

      var value = args[arg],
        ruleSet = rules[arg];

      try {
        ruleSet.forEach(function (rule) {
          if (rule !== 'required') {
            exports.checks[rule](value || '');
          }
        });
      } catch (e) {
        throw new Error(util.format(
          'Validation error - arg: %s, value: %s, desc: %s',
          arg, value, e.message));
      }
    });
    cb();
  } catch (e) {
    cb(e);
  }
}
function validate(rules, args, cb) {
  try {
    _known(rules, args);
    _required(rules, args);

    Object.keys(args).forEach(function (arg) {

      var value = args[arg],
        ruleSet = rules[arg];

      try {
        ruleSet.forEach(function (rule) {
          if (rule !== 'required') {
            exports.checks[rule](value || '');
          }
        });
      } catch (e) {
        throw new Error(util.format(
          'Validation error - arg: %s, value: %s, desc: %s',
          arg, value, e.message));
      }
    });
    cb();
  } catch (e) {
    cb(e);
  }
}
function validate ( rules , args , cb ) { try { _known ( rules , args ) ; _required ( rules , args ) ; Object . keys ( args ) . forEach ( function ( arg ) { var value = args [ arg ] , ruleSet = rules [ arg ] ; try { ruleSet . forEach ( function ( rule ) { if ( rule !== 'required' ) { exports . checks [ rule ] ( value || '' ) ; } } ) ; } catch ( e ) { throw new Error ( util . format ( 'Validation error - arg: %s, value: %s, desc: %s' , arg , value , e . message ) ) ; } } ) ; cb ( ) ; } catch ( e ) { cb ( e ) ; } }
Validate arguments against a set of rules.

@param {Object} rules: argument name-ruleset pair, ruleset is an array of check functions
@param {Object} args: argument name-value pair
@param {Function} cb: standard cb(err, result) callback
Validate arguments against a set of rules .