src/validator.js
function (passes, fails) {
    var _this = this;
    passes = passes || function () {};
    fails = fails || function () {};

    var failsOne = function (rule, message) {
      _this._addFailure(rule, message);
    };

    var resolvedAll = function (allPassed) {
      if (allPassed) {
        passes();
      } else {
        fails();
      }
    };

    var asyncResolvers = new AsyncResolvers(failsOne, resolvedAll);

    var validateRule = function (inputValue, ruleOptions, attribute, rule) {
      return function () {
        var resolverIndex = asyncResolvers.add(rule);
        rule.validate(inputValue, ruleOptions.value, attribute, function () {
          asyncResolvers.resolve(resolverIndex);
        });
      };
    };

    for (var attribute in this.rules) {
      var attributeRules = this.rules[attribute];
      var inputValue = this._objectPath(this.input, attribute);

      if (this._hasRule(attribute, ['sometimes']) && !this._suppliedWithData(attribute)) {
        continue;
      }

      for (var i = 0, len = attributeRules.length, rule, ruleOptions; i < len; i++) {
        ruleOptions = attributeRules[i];

        rule = this.getRule(ruleOptions.name);

        if (!this._isValidatable(rule, inputValue)) {
          continue;
        }

        validateRule(inputValue, ruleOptions, attribute, rule)();
      }
    }

    asyncResolvers.enableFiring();
    asyncResolvers.fire();
  }
function (passes, fails) {
    var _this = this;
    passes = passes || function () {};
    fails = fails || function () {};

    var failsOne = function (rule, message) {
      _this._addFailure(rule, message);
    };

    var resolvedAll = function (allPassed) {
      if (allPassed) {
        passes();
      } else {
        fails();
      }
    };

    var asyncResolvers = new AsyncResolvers(failsOne, resolvedAll);

    var validateRule = function (inputValue, ruleOptions, attribute, rule) {
      return function () {
        var resolverIndex = asyncResolvers.add(rule);
        rule.validate(inputValue, ruleOptions.value, attribute, function () {
          asyncResolvers.resolve(resolverIndex);
        });
      };
    };

    for (var attribute in this.rules) {
      var attributeRules = this.rules[attribute];
      var inputValue = this._objectPath(this.input, attribute);

      if (this._hasRule(attribute, ['sometimes']) && !this._suppliedWithData(attribute)) {
        continue;
      }

      for (var i = 0, len = attributeRules.length, rule, ruleOptions; i < len; i++) {
        ruleOptions = attributeRules[i];

        rule = this.getRule(ruleOptions.name);

        if (!this._isValidatable(rule, inputValue)) {
          continue;
        }

        validateRule(inputValue, ruleOptions, attribute, rule)();
      }
    }

    asyncResolvers.enableFiring();
    asyncResolvers.fire();
  }
function ( passes , fails ) { var _this = this ; passes = passes || function ( ) { } ; fails = fails || function ( ) { } ; var failsOne = function ( rule , message ) { _this . _addFailure ( rule , message ) ; } ; var resolvedAll = function ( allPassed ) { if ( allPassed ) { passes ( ) ; } else { fails ( ) ; } } ; var asyncResolvers = new AsyncResolvers ( failsOne , resolvedAll ) ; var validateRule = function ( inputValue , ruleOptions , attribute , rule ) { return function ( ) { var resolverIndex = asyncResolvers . add ( rule ) ; rule . validate ( inputValue , ruleOptions . value , attribute , function ( ) { asyncResolvers . resolve ( resolverIndex ) ; } ) ; } ; } ; for ( var attribute in this . rules ) { var attributeRules = this . rules [ attribute ] ; var inputValue = this . _objectPath ( this . input , attribute ) ; if ( this . _hasRule ( attribute , [ 'sometimes' ] ) && ! this . _suppliedWithData ( attribute ) ) { continue ; } for ( var i = 0 , len = attributeRules . length , rule , ruleOptions ; i < len ; i ++ ) { ruleOptions = attributeRules [ i ] ; rule = this . getRule ( ruleOptions . name ) ; if ( ! this . _isValidatable ( rule , inputValue ) ) { continue ; } validateRule ( inputValue , ruleOptions , attribute , rule ) ( ) ; } } asyncResolvers . enableFiring ( ) ; asyncResolvers . fire ( ) ; }
Run async validator

@param {function} passes
@param {function} fails
@return {void}
Run async validator