Overtrue\Validation\Validator::validate PHP Méthode

validate() protected méthode

Validate a given attribute against a rule.
protected validate ( string $attribute, string $rule )
$attribute string
$rule string
    protected function validate($attribute, $rule)
    {
        list($rule, $parameters) = $this->parseRule($rule);
        if ($rule === '') {
            return;
        }
        // We will get the value for the given attribute from the array of data and then
        // verify that the attribute is indeed validatable. Unless the rule implies
        // that the attribute is required, rules are not run for missing values.
        $value = $this->getValue($attribute);
        $validatable = $this->isValidatable($rule, $attribute, $value);
        $method = "validate{$rule}";
        if ($validatable && !$this->{$method}($attribute, $value, $parameters, $this)) {
            $this->addFailure($attribute, $rule, $parameters);
        }
    }
Validator