注册变量规则
@access public
@param  string|array $name 变量名
@param  string $rule 变量规则
@return $this
431342
public function pattern($name, $rule = '')
    {
        if (is_array($name)) {
            $this->pattern = array_merge($this->pattern, $name);
        } else {
            $this->pattern[$name] = $rule;
        }

        return $this;
    }
521200
public static function AppendRule ($rule_name, $rule) {
		$rule_list = static::GetValidateRuleList();
		$rule_list[$rule_name] = $rule;
		static::SetClassVar('_rule', $rule_list);
	}
1334442
public function set(string $name, $rule = null): RuleManager
    {
        if (empty($rule)) {
            $rule = $name;
        }

        if (!$this->validateRule($rule)) {
            throw new RuleException("Unable to set rule '{$name}', invalid rule body");
        }

        $this->rules[$name] = $rule;

        return $this;
    }
984147
public function setRule($rule)
	{
		if(null === $rule)
		{
			$rule = Dispatch::module() . '/' . Dispatch::control() . '/' . Dispatch::action();
		}
		$this->rule = $rule;
	}
294277
public function setRules($fieldNameOrArray, $rules = [])
    {
        // Determine Parameter Mode:
        
        if (is_array($fieldNameOrArray)) {
            
            // Define All Rules:
            
            foreach ($fieldNameOrArray as $fieldName => $rules) {
                $this->setRules($fieldName, $rules);
            }
            
        } else {
            
            // Define Rules for Specified Field:
            
            foreach ($rules as $rule) {
                $this->setRule($fieldNameOrArray, $rule);
            }
            
        }
        
        // Answer Self:
        
        return $this;
    }
1273334
public function setRule($rule)
    {
        if ('$' == substr($rule, -1, 1)) {
            // 是否完整匹配
            $rule = substr($rule, 0, -1);

            $this->option['complete_match'] = true;
        }

        $rule = '/' != $rule ? ltrim($rule, '/') : '';

        if ($this->parent && $prefix = $this->parent->getFullName()) {
            $rule = $prefix . ($rule ? '/' . ltrim($rule, '/') : '');
        }

        if (false !== strpos($rule, ':')) {
            $this->rule = preg_replace(['/\[\:(\w+)\]/', '/\:(\w+)/'], ['<\1?>', '<\1>'], $rule);
        } else {
            $this->rule = $rule;
        }

        // 生成路由标识的快捷访问
        $this->setRuleName();
    }
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;
    }
1284206
public function setRules( $rules )
    {
        $this->rules = array();

        foreach ( $rules as $rule )
        {
            $this->addRule( $rule );
        }

        return $this;
    }
1368639
public function & rules(array $rules){
      foreach ((array)$rules as $varname => $rule){
        $this->rules[$varname] = $rule;
      }
      $this->pattern         = $this->compilePatternAsRegex( $this->URLPattern, $this->rules );
      $this->matcher_pattern = $this->compilePatternAsRegex( $this->URLPattern, $this->rules, false );
      return $this;
    }
966655
public function addMatcher($name, MatcherInterface $rule)
    {
        if ($rule->hasValue()) {
            $this->rules[$name][] = $rule;
        }
    }
893503
protected function getRule($name)
    {
        return isset($this->rules[$name]) ? $this->rules[$name] : $this->defaultRule;
    }
1330599
public function setRules(array $rules) {
        /* Clear the stack */
        unset($this->rules);
        $this->rules = new \SplStack;

        /* Add the rules */
        foreach ($rules as $callable) {
            $this->addRule($callable);
        }

        return $this;
    }
1137447
public function addRule($name, callable $rule)
    {
        if (isset($this[self::rule($name)])) {
            throw new \RuntimeException("rule '$name' already exists'");
        }
        $this[self::rule($name)] = $this->protect($rule);
    }
660415
protected function addItem( $name, $rule = null, $msg = '' )
	{
		if( $rule || 0 === $rule ){
			$this->rule[$name] = $rule;
		} else{
			$this->rule[] = $name;
		}
		$this->message[] = $msg;
		return $this;
	}
804020
public function addRule(string $key, string $rule) : ValidatorInterface
    {
        $this->rules[$key] = $rule;

        return $this;
    }
387273
public function setRules(array $rules): self
    {
        assert(empty($rules) === false);

        $this->rules = $rules;

        return $this;
    }
838315
public function alias(string $name, $rules, ?string $error = null): self
    {
        $this->definitions[$name] = function () use ($rules, $error) {
            return $this->parser->parse($rules)->setError($error);
        };
        return $this;
    }