验证有效期
@access protected

@param mixed $rule 验证规则

@return $this
192298
protected function expire($rule) {
        $this->check_role = 'expire';
        if (is_string($rule)) {
            $rule = explode(',', $rule);
        }
        $this->rule = implode(',', $rule);
        list($start, $end) = $rule;
        if (!is_numeric($start)) {
            $start = strtotime($start);
        }

        if (!is_numeric($end)) {
            $end = strtotime($end);
        }
        $time = time();
        $result = $time >= $start && $time <= $end;
        $this->checkResult($result);
        return $this;
    }
402094
public function setRule($rule, $replacement)
    {
        if (is_array($rule)) {
            $this->rules = $rule;
            return $this;
        }

        $this->rules[$rule] = $replacement;
        return $this;
    }
1094342
public function fromForm($rule = 'default', $all = false)
	{
		// 获取规则
		if (! is_array($rule))
		{
			if (isset($this->rules[$rule]))
			{
				$rule = $this->rules[$rule];
			}
			else
			{
				return false;
			}
		}
		// 清空当前数据
		$this->data = array ();
		// 循环获取数据
		foreach ($rule as $value)
		{
			// 规则合法性判断
			if (isset($value['name']))
			{
				// 处理没有传入from的情况
				if (! isset($value['table']))
				{
					$value['table'] = '';
				}
			}
			else
			{
				// 判断数量是否正确
				if (count($value) < 3)
				{
					throw new Exception(Lang::get('MODEL_FORM_ARGS_LESS'));
					break;
				}
				$t = $value;
				$value = array ();
				// 直接传值处理
				$value['name'] = $t[0];
				if (isset($t[3]))
				{
					$value['table'] = $t[3];
				}
				else
				{
					$value['table'] = '';
				}
			}
			// 获取数据
			$d = Request::getAll($value['table'], $value['name']);
			// 判断获取是否成功
			if (false === $d)
			{
				// 判断是否有默认值
				if(array_key_exists('default',$value))
				{
					$this->data[$value['name']] = $value['default'];
				}
			}
			else
			{
				// 过滤器支持
				if(isset($value['filter']))
				{
					$this->data[$value['name']] = execFilter($d,$value['filter']);
				}
				else
				{
					$this->data[$value['name']] = execFilter($d,Config::get('@.DEFAULT_FILTER'));
				}
			}
		}
		// 开始验证
		$v = new Validator();
		// 保存验证结果
		$result = $v->validate($all, $this->data, $rule);
		if (array () === $result)
		{ // 验证通过
		  // 字段映射
			$this->data = $this->parseFieldsMap($this->data);
			return true;
		}
		else
		{
			// 清空数据
			$this->data = array ();
			// 返回验证结果
			return $result;
		}
	}
755224
public function addRule(RuleAbstract $rule)
    {
        // TODO Keyframes with duplicate identifiers do NOT cascade!
        // Last one overwrites previous ones.
        // @see https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#Duplicate_resolution

        if ($rule instanceof KeyframesRuleSet) {
            $this->rules[] = $rule;
        } else {
            throw new \InvalidArgumentException(
                "Invalid rule instance. Instance of 'KeyframesRuleSet' expected."
            );
        }

        return $this;
    }
432341
public function group($rule, $having = null){
		if($this->validateConditions())
			return $this;

		$this->resetState();
		$this->grouping = array($rule, $having);
		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();
    }
431342
public function pattern($name, $rule = '')
    {
        if (is_array($name)) {
            $this->pattern = array_merge($this->pattern, $name);
        } else {
            $this->pattern[$name] = $rule;
        }

        return $this;
    }
1196919
public function apply(Rule $rule, $value)
    {
        return $this->getZendInstance($rule->class, $rule->zendOptions)->filter($value);
    }
513981
public function addRules(array $rules)
    {
        foreach ($rules as $character => $replacement) {
            $this->addRule($character, $replacement);
        }

        return $this;
    }
720890
public function collectRule(Rule $rule): void
    {
        $this->data['rule'] = [
            'id' => $rule->getId(),
        ];

        foreach ($rule->getTargets() as $target) {
            $this->data['rule']['targets'][] = [
                'type' => $target->getTargetType()::getType(),
                'value' => $this->formatVar($target->getValue()),
            ];
        }

        foreach ($rule->getConditions() as $condition) {
            $this->data['rule']['conditions'][] = [
                'type' => $condition->getConditionType()::getType(),
                'value' => $this->formatVar($condition->getValue()),
            ];
        }
    }
445247
public function addRules(array $rules)
    {
        foreach ($rules as $rule) {
            if (is_array($rule)) {
                $this->addRules($rule);
            } else {
                $this->addRule($rule);
            }
        }

        return $this;
    }
1029827
public function addRule(AbstractRule $rule) {
        if (array_key_exists($rule->getName(), $this->rules)) {
            throw new ParserException('Rule with ' . $rule->getName() . ' name already exists');
        }

        $this->rules[$rule->getName()] = $rule;

        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;
    }
1142649
public function addMultiple($rules)
    {
        foreach ($rules as $singleRule) {
            // make sure the rule is an array (the parameters of subsequent calls);
            $singleRule = is_array($singleRule) ? $singleRule : array(
                $singleRule
            );
            call_user_func_array(
                array(
                    $this,
                    'add'
                ),
                $singleRule
            );
        }

        return $this;
    }
896345
public function setRules(array $rules)
    {
        $this->initialRules = $rules;

        $this->rules = [];

        $this->addRules($rules);

        return $this;
    }
666752
private function setupRules($rules)
    {
        // prepares filter for requiredIf
        $rules = Utils\HelperRequiredIf::prepare($this, $rules);

        // prepares filter for sameWith.
        $rules = Utils\HelperSameWith::prepare($this, $rules);

        return $rules;
    }
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;
    }