Constructor
@method Message
@param  {Object} rule object
@param  {Object} options options for bem-naming
@constructor
425116
function Message($, rule_id, options) {

    var rule = new ruleValidator($, rule_id, options),
        message = '';

    if ( typeof rule.valid === 'boolean' && !rule.valid ) {
        message = typeof rule.rule.message == 'function' ? rule.rule.message(options) : rule.rule.message;
    }

    this.text = message;
}
57505
function Rule (subrules, type, handler, props, groupProps, encoding) {
  var self = this
  var n = subrules.length

  this.props = props

  this.debug = false

  // Used for cloning
  this.subrules = subrules

  // Required by Atok#_resolveRules
  for (var p in groupProps)
    this[p] = groupProps[p]

  // Runtime values for continue props
  this.continue = this.props.continue[0]
  this.continueOnFail = this.props.continue[1]

  this.type = type
  this.handler = handler

  // For debug
  this.prevHandler = null
  this.id = this.type !== null ? this.type : handler
  // Id for debug
  this._id = (handler !== null ? (handler.name || '#emit()') : this.type)

  // Subrule pattern index that matched (-1 if only 1 pattern)
  this.idx = -1

  // Single subrule: special case for trimRight
  this.single = (n === 1)

  // First subrule
  var subrule = this.first = n > 0
    ? SubRule.firstSubRule( subrules[0], this.props, encoding, this.single )
    // Special case: no rule given -> passthrough
    : SubRule.emptySubRule

  // Special case: one empty rule -> tokenize whole buffer
  if (n === 1 && subrule.length === 0) {
    subrule = this.first = SubRule.allSubRule
    // Make infinite loop detection ignore this
    this.length = -1
  } else {
    // First subrule pattern length (max of all patterns if many)
    // - used in infinite loop detection
    this.length = this.first.length
  }

  // Instantiate and link the subrules
  // { test: {Function}
  // , next: {SubRule|undefined}
  // }
  var prev = subrule
  // Many subrules or none
  for (var i = 1; i < n; i++) {
    subrule = SubRule.SubRule( subrules[i], this.props, encoding )
    prev.next = subrule
    subrule.prev = prev // Useful in some edge cases
    prev = subrule
    if (this.length < subrule.length) this.length = subrule.length
  }

  // Last subrule (used for trimRight and matched idx)
  this.last = subrule

  // Set the first and last subrules length based on trim properties
  if (!this.props.trimLeft) this.first.length = 0
  if (!this.single && !this.props.trimRight) this.last.length = 0

  this.next = null
  this.nextFail = null
  this.currentRule = null
}
283148
private function processRule(Item $item, $ruleName, $options)
    {
        if ($item->stopRules()) {
            return;
        }

        $ruleName = '\NickStuer\EasyValidator\Rules\\' . $ruleName;

        if (!class_exists($ruleName)) {
            throw new RuleNotFoundException;
        }

        /**
         * @var \NickStuer\EasyValidator\RuleInterface $rule
         */
        $rule = new $ruleName;
        if (!$rule->validate($item->getItemValue(), $options)) {
            $this->setValidationStatus(false);
            $item->setValidationStatus(false);

            $message = $rule->getMessage();
            $message = str_replace('{label}', $item->getItemLabel(), $message);
            $message = str_replace('{option1}', $options, $message);
            $item->setMessage($message);
        }

        $item->incrementRuleCount();
    }
784254
public RuleImpl buildRule(VertexElement vertex, Rule type, Pattern when, Pattern then) {
        return getOrBuildConcept(vertex, (v) -> RuleImpl.create(v, type, when, then));
    }
490939
function Rules (options) {
  this.options = options;
  this._keep = [];
  this._remove = [];

  this.blankRule = {
    replacement: options.blankReplacement
  };

  this.keepReplacement = options.keepReplacement;

  this.defaultRule = {
    replacement: options.defaultReplacement
  };

  this.array = [];
  for (var key in options.rules) this.array.push(options.rules[key]);
}
731366
function prepareRules(options, rules, defaultDir) {
  rules = u.findRules(options, rules, defaultDir);
  var anyStartRules = [];
  var anyEndRules = [];
  var typeToRules = {'': anyStartRules, 'end': anyEndRules};

  rules.forEach(function (rule) {
    var ruleTypes = rule.type || [];
    ruleTypes = Array.isArray(ruleTypes) ? ruleTypes : [ruleTypes];
    if (ruleTypes.length === 0) {
      ruleTypes.push('');
    }
    ruleTypes.forEach(function (ruleType) {
      if (ruleType === '') {
        anyStartRules.push(rule);
        // add this any rule to the end of any typed start rule lists
        Object.keys(typeToRules).forEach(function (key) {
          if (key !== '' && key !== 'end' && key.substring(0,4) !== 'end-') {
            typeToRules[key].push(rule);
          }
        });
      } else if (ruleType === 'end') {
        anyEndRules.push(rule);
        // add this any rule to the end of any typed end rule lists
        Object.keys(typeToRules).forEach(function (key) {
          if (key !== '' && key.substring(0,4) === 'end-') {
            typeToRules[key].push(rule);
          }
        });
      } else {
        if (!(ruleType in typeToRules)) {
          typeToRules[ruleType] = [];
          if (ruleType.substring(0,4) !== 'end-') {
            // put all preceding any start rules first
            typeToRules[ruleType] = [].concat(anyStartRules);
          } else {
            // put all preceding any end rules first
            typeToRules[ruleType] = [].concat(anyEndRules);
          }
        }
        typeToRules[ruleType].push(rule);
      }
    });
  });

  return typeToRules;
}
228721
function (rule) {
    var msg = this.messages.render(rule);
    this.errors.add(rule.attribute, msg);
    this.errorCount++;
  }
903332
function(message, title, options) {
        this.message = message;
        this.title = title || MessageBox.defaultTitle;
        this.options = options || MessageBox.defaultOptions;
    }
387958
def with_rule(self, rule):
        
        self.rules = self.rules if self.rules != None else []
        self.rules.append(rule)
        return self
34710
public function addRule(ValidatorRule $rule, $field, $flags = 0x00000) {
    $key = $this->getKey($field);
    $this->rules[$key][] = $rule;
    
    if ($rule instanceof FieldValidatorRule) {
      $rule->setField($field);
    }
    
    if ($flags & self::OPTIONAL) {
      $this->setOptional($field);
    }
  }
890549
function createRuleListeners(rule, ruleContext) {
    try {
        return rule.create(ruleContext);
    } catch (ex) {
        ex.message = `Error while loading rule '${ruleContext.id}': ${ex.message}`;
        throw ex;
    }
}
61203
function(next, rule, options) {
        var adapter = options.adapter;

        return function(elem) {
            return !adapter.getParent(elem) && next(elem);
        };
    }
862267
function addMessage($rule, $message, $element = null) {
        $this->messages[$rule . ($element ? '.' . $element : '')] = $message;

        return $this;
    }
995786
public function addRule($rule, $method = null, $params = [], $message = null)
    {

        // construction des paramètres
        array_unshift($params, $rule, $method);

        call_user_func_array([$this->getValidator(), 'addRule'], $params);

        if (!is_null($message)) {
            if(is_array($message)){
                foreach($message as $rule => $message){
                    $this->getValidator()->addMessage($rule, $message);
                }
            }else{
                $this->getValidator()->addMessage($rule, $message);
            }
        }

        return $this;
    }
1280795
function BusinessRules(Data) {
            this.Data = Data;
            this.InvoiceValidator = this.createInvoiceValidator().CreateRule("Data");

            this.ValidationResult = this.InvoiceValidator.ValidationResult;
        }
346717
function SpawnError (message, options) {
  return errorBase('SpawnError', function (message, options) {
    this.name = 'SpawnError'
    this.message = message
    this.code = options.code
    this.buffer = options.buffer
  }).call(this, message, options)
}
553020
function rule( context ) {
	/**
	* FUNCTION: validateLiteral( node )
	*	Validates a regular expression literal.
	*
	* @param {Node} node - AST node
	* @returns {Void}
	*/
	function validateLiteral( node ) {
		var token = context.getTokens( node )[ 0 ];
		if (
			token.type === 'RegularExpression' &&
			!safe( token.value )
		) {
			context.report( node, 'Unsafe regular expression' );
		}
	} // end FUNCTION validateLiteral()

	/**
	* FUNCTION: validateExpression( node )
	*	Validates a regular expression creating using the `RegExp` constructor.
	*
	* @param {Node} node - AST node
	* @returns {Void}
	*/
	function validateExpression( node ) {
		var args,
			len,
			re,
			i;

		if ( node.callee.name === 'RegExp' ) {
			len = node.arguments.length;
			args = new Array( node.arguments.length );
			for ( i = 0; i < len; i++ ) {
				// NOTE: we only support literals ATM. Otherwise, we may need to walk and implement an entire tree.
				if ( node.arguments[ i ].type !== 'Literal' ) {
					return;
				}
				args[ i ] = node.arguments[ i ].value;
			}
			re = RegExp.apply( null, args );
			if ( !safe( re ) ) {
				context.report( node, 'Unsafe regular expression' );
			}
		}
	} // end FUNCTION validateExpression()

	return {
		'Literal': validateLiteral,
		'NewExpression': validateExpression,
		'CallExpression': validateExpression
	};
}