@param FilterRule $rule

@return $this
437576
public function add(FilterRule $rule)
    {
        $this->rules[$rule->getName()] = $rule;

        if (!\is_null($rule->getValue())) {
            $this->hasDefaults = true;
        }

        return $this;
    }
1265354
public function addRule(RuleAbstract $rule)
    {
        // Check for allowed instances
        if ($rule instanceof RuleGroupableInterface) {
            $this->rules[] = $rule;
        } else {
            // Invalid rule instance, because only nested statements can be added to conditional group rules.
            $parentClassName = get_class($this);
            $childClassName = get_class($rule);
            $rule->setIsValid(false);
            $rule->addValidationError(
                "Rule instance of type '$childClassName' not allowed " .
                "in conditional group rule of type '$parentClassName'."
            );
            $this->rules[] = $rule;
        }

        return $this;
    }
441012
public function merge(Set $rules): self
    {
        $this->rules = array_merge($this->rules, $rules->rules);
        return $this;
    }
1145907
public function define($pattern, $controller, $filters = array())
    {
        $rule = clone $this->rulePrototype;

        $rule->setPattern($pattern)->setController($controller)->setFilters($filters);

        array_push($this->rules, $rule);

        return $this;
    }
808297
public function setFilter($filter = null)
    {
        $this->filter = is_callable($filter) ? $filter : null;

        return $this;
    }
1102741
protected function addRule(AbstractRule $rule, $category = self::CATEGORY_NONE) {
        $rule->setRuleSet($this);

        $this->rules[] = $rule;
        $this->categories[$category][] = $rule;

        return $this;
    }
960899
public function rules($rules)
    {
        foreach ($rules as $rule => $field) {
            if (is_array($field) && is_array($field[0])) {
                foreach ($field as $params) {
                    array_unshift($params, $rule);
                    call_user_func_array([$this, 'rule'], $params);
                }
            } else {
                $this->rule($rule, $field);
            }
        }
        return $this;
    }
669067
private function setRule($rules)
    {
        $this->rules = array_merge_recursive(
            $this->rules, $this->explodeExplicitRule($rules)->rules
        );
    }
128964
public function setRule($fieldName, Rule $rule)
    {
        $this->rules[$fieldName][get_class($rule)] = $rule;
        
        $rule->setValidator($this);
        
        return $this;
    }
354520
public function removeObservedCssRule($rule)
    {
        if (isset($this->observedCssRules[$rule])) {
            unset($this->observedCssRules[$rule]);
        }

        return $this;
    }
687893
public function getFilterForRule(Rule $rule)
    {
        $filterIdentifier = $rule->getFilter();

        if ($this->container === null || !$this->container->has($filterIdentifier)) {
            return parent::getFilterForRule($rule);
        }

        return $this->container->get($filterIdentifier);
    }
142742
public function add(\Caridea\Validate\Rule ...$rules): self
    {
        $this->rules = array_merge($this->rules, $rules);
        return $this;
    }
283528
public function rule($name, $rule = '')
    {
        if (is_array($name)) {
            $this->rule = $name + $this->rule;
            if (is_array($rule)) {
                $this->field = array_merge($this->field, $rule);
            }
        } else {
            $this->rule[$name] = $rule;
        }

        return $this;
    }
574403
private function filterAllOf(AllOf $rule)
    {
        $rules = $rule->getRules();
        if (count($rules) != 1) {
            throw new ComponentException('AllOf rule must have only one Attribute rule');
        }

        return current($rules);
    }
235815
public function configureRule(Rule $rule)
    {
        if ($config = $this->getRuleConfig($rule)) {
            
            if (isset($config['type'])) {
                $rule->setType($config['type']);
            }
            
            if (isset($config['format'])) {
                $rule->setFormat($config['format']);
            }
            
            if (isset($config['attribute'])) {
                $rule->setAttribute($config['attribute']);
            }
            
        }
        
        return $rule;
    }
109770
public function set_message($rule, $message)
	{
		if ($message !== null)
		{
			$this->error_messages[$rule] = $message;
		}
		else
		{
			unset($this->error_messages[$rule]);
		}

		return $this;
	}
219405
public function rule($name, $rule='')
    {
        if (is_array($name)) {
            $this->rule=array_merge($this->rule, $name);
        } else {
            $this->rule[$name]=$rule;
        }
        return $this;
    }