Adds data filtering rule.

@param string $name attribute name
@param MatcherInterface $rule
966655
public function addMatcher($name, MatcherInterface $rule)
    {
        if ($rule->hasValue()) {
            $this->rules[$name][] = $rule;
        }
    }
598547
public function addRule(Rule $rule)
    {
        $classname = $rule->getClass();
        if ($this->hasRule($classname) === true) {
            throw new Exception(
                "failed to add rule; the field {$this->name} already has an ".
                "instance of '$classname'"
            );
        }
        else if ($classname === Rule::REQUIRED) {
            $this->rules = [$classname => $rule] + $this->rules;
        }
        else {
            $this->rules[$classname] = $rule;
        }
        return $this;
    }
659264
public function addFilter($name, $callable) {
        $filter = new RouteFilter($name, $callable);
        $this->getRoutesMatcher()->getFiltersMatcher()
            ->addFilter($filter);

        return $this;
    }
1243978
public static function alpha(Validator $validator, $data, $pattern, $rule)
    {
        foreach (Validator::getValues($data, $pattern) as $attribute => $value) {
            if (null === $value || empty($value)) {
                continue;
            }
            if (preg_match('/^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖßÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i', $value) === 1) {
                continue;
            }

            $validator->addError($attribute, $rule);
        }
    }
225086
protected function _addInput(array $data, $name = null)
    {
        $this->_inputFilter->add($this->_newInput($data, $name));
    }
695735
public function storeRule($field, $name, $rule = null)
    {
        self::validateFieldName($field);
        if (is_array($name)) {
            foreach ($name as $k => $v) {
                $this->storeRule($field, $k, $v);
            }

            return;
        }
        if ($rule === null && is_string($name)) {
            $rule = $name;
            $name = null;
        }
        if (empty($name) || !is_string($name)) {
            $name = Util::pathOfUrl(URL::current(), function ($e) use ($field) {
                throw new LaravelSmsException("Expected a name for the dynamic rule which belongs to field `$field`.");
            });
        }
        $allRules = $this->retrieveRules($field);
        $allRules[$name] = $rule;
        $key = $this->generateKey(self::DYNAMIC_RULE_KEY, $field);
        self::storage()->set($key, $allRules);
    }
1125246
public function add($type, Rule $rule)
    {
        if (!isset($this[$type])) {
            $this[$type] = [];
        }

        if ($rule->language === false) {
            $rule->language = $this->_language;
        }

        if ($rule->validator === false) {
            $rule->validator = $this->validator;
        }

        $rule->factory->setBase($type);

        if ($rule->name !== null) {
            if (isset($this[$type][$rule->name])) {
                throw new NameConflictException("Rule with '{$rule->name}' is already defined, name has to be unique!");
            }

            $this[$type][$rule->name] = $rule;
            return;
        }

        $this[$type][] = $rule;
    }
1003626
public function addFilter(BuilderInterface $filter, $name = '')
    {
        if ($this->anonymous === false && empty($name)) {
            throw new \LogicException('In not anonymous filters filter name must be set.');
        } elseif ($this->anonymous === false && !empty($name)) {
            $this->filters['filters'][$name] = $filter->toArray();
        } else {
            $this->filters['filters'][] = $filter->toArray();
        }

        return $this;
    }
574864
function construct($matchrule, $name, $arguments = null)
    {
        $res = parent::construct($matchrule, $name, $arguments);
        if (!isset($res['php'])) {
            $res['php'] = '';
        }
        return $res;
    }
413483
public function addFilter(string $name, string $filter): void{
        $this->filters[$name] = $filter;
    }
1324286
public function validateValue(array $attributes, string $name, array $rule): bool
    {
        // 删除开始的字段名
        array_shift($rule);
        // 取出校验器识别
        $validatorName = array_shift($rule);
        // 创建校验器
        $validator = $this->createValidator($validatorName);

        return $validator($attributes, $name, $rule);
    }
253844
private function check($matchType, $type, $name, $args)
    {
        $value = array_shift($args);

        if (!isset($args[0])) {
          $args[0] = ['rule' => Policy::ANY];
        }

        // see what other options we've been given
        if (is_string($args[0]) && ($args[0] === Policy::ANY || $args[0] === Policy::ALL) ) {
          $args['rule'] = $args[0];
          unset($args[0]);
        } elseif (is_array($args[0])) {
          $args = $args[0];
        }

        $this->checks[$type][] = new Check($matchType, $value, $args);
    }
684023
public static function in(Validator $validator, $data, $pattern, $rule, $parameters)
    {
        foreach (Validator::getValues($data, $pattern) as $attribute => $value) {
            if (null === $value) {
                continue;
            }
            if (in_array($value, $parameters)) {
                continue;
            }

            $validator->addError($attribute, $rule, ['%values' => implode(', ', $parameters)]);
        }
    }
993372
public function addFilter(AbstractQuery $filter, string $name = null): self
    {
        $filterArray = [];

        $type = self::NAMED_TYPE;

        if (null === $name) {
            $filterArray[] = $filter;
            $type = self::ANONYMOUS_TYPE;
        } else {
            $filterArray[$name] = $filter;
        }

        if ($this->hasParam('filters')
            && \count($this->getParam('filters'))
            && $this->_type !== $type
        ) {
            throw new InvalidException('Mix named and anonymous keys are not allowed');
        }

        $this->_type = $type;

        return $this->addParam('filters', $filterArray);
    }
1028922
public function setFilter($name, FilterInterface $filter = null)
    {
        $this->filters[$name] = $filter;

        return $this;
    }
1078731
protected function addRule(FilterRule $rule)
    {
        if ($this->keys === null) {
            $this->filter->addFilterRule($rule);
        }

        if (is_array($this->keys)) {
            foreach ($this->keys as $key) {
                $this->filter->addFilterRule($rule, $key);
            }
        } else {
            $this->filter->addFilterRule($rule, $this->keys);
        }

        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;
    }