Create the rule template.

@param  string $rule
@return boolean
549129
private function ruleTemplate($rule)
    {
        $file = __DIR__ . "/../templates/validator/rule.php.dist";

        if (file_exists($file))
        {
            $template = strtr(file_get_contents($file), [
                '{{namespace}}' => get_app_namespace(),
                '{{rule}}' => $rule
            ]);

            if (!file_exists(app_path("Validation/Rules")))
            {
                mkdir(app_path("Validation/Rules"), 0755, true);
            }

            $file_path = app_path("Validation/Rules/{$rule}.php");

            $file = fopen($file_path, "w");
            fwrite($file, $template);
            fclose($file);

            return file_exists($file_path);
        }

        return false;
    }
171733
private function validateRule($rule): bool
    {
        if ($rule instanceof \Closure || $rule instanceof RuleInterface) {
            return true;
        }

        if (is_array($rule)) {
            return is_callable($rule, true);
        }

        if (is_string($rule) && class_exists($rule)) {
            try {
                $reflection = new \ReflectionClass($rule);
            } catch (\ReflectionException $e) {
                return false;
            }

            return $reflection->isSubclassOf(RuleInterface::class);
        }

        return false;
    }
985992
protected function method($value, $rule)
    {
        $method=Request::instance()->method();
        return strtoupper($rule) == $method;
    }
209672
static protected function parseRule($rule)
    {
        switch (gettype($rule)) {
            case 'string':
                $type = $rule;
                $target = null;
                $types = [];
                break;
            case 'array':
                $type = isset($rule['type']) ? $rule['type'] : [];
                $target = isset($rule['target']) ? $rule['target'] : [];
                $types = isset($rule['types']) ? $rule['types'] : [];
                break;
            case 'object':
                $type = isset($rule->type) ? $rule->type : null;
                $target = isset($rule->target) ? $rule->target : null;
                $types = isset($rule->types) ? $rule->types : [];
                break;
            default:
                $type = null;
                $target = null;
                $types = [];
        }
        return compact('type', 'target', 'types');
    }
267851
private function isRule($rule) {

		if(false === is_string($rule)) {
			return false;
		}

		$class = $this -> getRuleClass($rule);

		return true === class_exists($class);
	}
938225
public function regex($rule) {
        $this->check_role = 'regex';
        $this->rule = $rule;
        $result = $this->checkRegex($this->value, $rule);
        $this->checkResult($result);
        return $this;
    }
583737
protected function resolveRule($rule)
    {

        $validation = [];
        if (is_array($rule)) {
            return $validation;
        }
        switch ($rule) {
            case 'required':
                $validation['required'] = 'required';
                break;
            default:
                if (str_contains($rule, ':') && !str_contains($rule, 'unique')) {
                    list($name, $value) = explode(':', $rule);
                    $validation["data-{$name}length"] = $value;
                }
                break;
        }
        return $validation;
    }
771270
public static function createFromRule(Rule $rule): self
    {
        return new static(
            $rule->getSubject(),
            [],
            $rule->getDefinition(),
            $rule->hasEofMark(),
            $rule->getTag()
        );
    }
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;
    }
437576
public function add(FilterRule $rule)
    {
        $this->rules[$rule->getName()] = $rule;

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

        return $this;
    }
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;
    }
1342937
private function parseRule($rule) {
		$parsed = [false];
		if (preg_match('#^([a-z][a-z\d_]+)\s*\((.+)\)\s*$#i', $rule, $ms)) {
			$method = trim($ms[1]);
			$ops    = trim($ms[2]);
		} else {
			$method = trim($rule);
			$ops    = '';
		}
		$parsed[0] = $method;
		$parsed[1] = $ops;

		return $parsed;
	}
1181399
protected function parseRule($rule)
	{
		$parameters = array();

		// The format for specifying validation rules and parameters follows an
		// easy {rule}:{parameters} formatting convention. For instance the
		// rule "Max:3" states that the value may only be three letters.
		if (strpos($rule, ':') !== false)
		{
			list($rule, $parameter) = explode(':', $rule, 2);

			$parameters = $this->parseParameters($rule, $parameter);
		}

		return array(studly_case($rule), $parameters);
	}
362190
public function apply(Rule $rule, $value)
    {
        $type = $rule->getInputType();

        if ($type == CallbackRule::SELF_METHOD_TYPE) {
            return $this->useObjectMethod($rule->callback, $value);
        }

        if ($type == CallbackRule::CALLABLE_TYPE) {
            return $this->useCallable($rule->callback, $value);
        }

        if ($type == CallbackRule::CLOSURE_TYPE) {
            return $this->useClosure($rule->callback, $value);
        }

        throw new InvalidCallbackException("Unsupported callback provided, failed to filter property");
    }
230634
public function view($rule, $template = '', array $vars = [], array $option = [], array $pattern = [])
    {
        return $this->rule($rule, $template, 'GET', $option, $pattern)->view($vars);
    }
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;
    }
832542
public function withRule(Rule $rule): RulesCollection
    {
        $rules = array_merge($this->rules, [$rule]);

        return new RulesCollection($rules);
    }