This method should not be called directly

@param string $rule
@param array $parameters

@return boolean
552705
public function verifyRule($ruleSpecification, array $parameters)
    {
        list($ruleName, $defaultParameters) = $this->extractRuleNameAndParameters($ruleSpecification);
        $ruleObject = $this->ruleProvider->getRule($ruleName);
        return $this->invoker->invoke($ruleObject, array_merge($defaultParameters,$parameters));
    }
1012642
private function _parseParams($rule)
    {
        $parsed = array();

        $split = explode("(", $rule);
        $name = $split[0];
        $str_params = rtrim($split[1], ")");
        // if empty string
        if ($str_params == '')
        {
            $parsed_params = array();
        }
        else
        {
            $parsed_params = explode(",", $str_params);
        }
        $parsed["params"] = $parsed_params;
        $parsed["name"] = $name;

        return $parsed;
    }
942761
protected function addError($attribute, $rule, $parameters)
    {
        $message = $this->getMessage($attribute, $rule);

        $message = $this->doReplacements($message, $attribute, $rule, $parameters);

        $this->messages->add($attribute, $message);
    }
1072673
public function update($rule)
    {
        $ruleId = "";

        if (is_array($rule)) {
            $ruleId = $rule["id"];
            unset($rule["id"]);
        }
        elseif (is_object($rule)) {
            $ruleId = $rule->id;
            unset($rule->id);
        }

        return $this->client->put("/validation-rules/" . rawurlencode($ruleId), $rule);
    }
472246
protected function removeRule($rule)
    {
        if (!is_string($this->rules)) {
            return;
        }

        $pattern = "/{$rule}[^\|]?(\||$)/";
        $this->rules = preg_replace($pattern, '', $this->rules, -1);
    }
315851
protected function normalizeParams($params, $rule, $value)
    {
        if (is_array($params)) {
            if (is_array($rule)) {
                $ref = new ReflectionMethod(...$rule);
            } elseif (is_string($rule) && strpos($rule, '::') !== false) {
                $ref = new ReflectionMethod($rule);
            } elseif ($rule instanceof Closure) {
                $ref = new ReflectionFunction($rule);
            }

            if (isset($ref)) {
                $parameters = $ref->getParameters();
                if (isset($parameters[1]) && $parameters[1]->isArray()) {
                    $params = [$params];
                }
            } else {
                $params = [$params];
            }
        } else {
            $params = is_null($params) ? [] : [$params];
        }

        array_unshift($params, $value);

        return $params;
    }
321123
protected function validateIn( $attribute, $value, $parameters )
	{
		if ( is_array( $value ) && $this->hasRule( $attribute, 'Array' ) )
		{
			return count( array_diff( $value, $parameters ) ) == 0;
		}

		return !is_array( $value ) && in_array( (string) $value, $parameters );
	}
165713
protected function _getRule($rule)
    {
        if ($rule instanceof FilterInterface) {
            return $rule;
        }

        $rule = (string) $rule;
        return $this->getPluginManager()->get($rule);
    }
1227192
public function validate(array $parameters = array()) {
        $validated= false;
        $this->reset();
        $stopOnFail= isset($parameters['stopOnFail']) && $parameters['stopOnFail']
                ? true
                : false;
        $stopOnRuleFail= isset($parameters['stopOnRuleFail']) && $parameters['stopOnRuleFail']
                ? true
                : false;
        if (!empty($this->object->_validationRules)) {
            foreach ($this->object->_validationRules as $column => $rules) {
                $this->results[$column]= $this->object->isValidated($column);
                if (!$this->results[$column]) {
                    $columnResults= array();
                    foreach ($rules as $ruleName => $rule) {
                        $result= false;
                        if (is_array($rule['parameters'])) $rule['parameters']['column'] = $column;
                        switch ($rule['type']) {
                            case 'callable':
                                $callable= $rule['rule'];
                                if (is_callable($callable)) {
                                     $result= call_user_func_array($callable, array($this->object->_fields[$column],$rule['parameters']));
                                    if (!$result) $this->addMessage($column, $ruleName, isset($rule['parameters']['message']) ? $rule['parameters']['message'] : $ruleName . ' failed');
                                } else {
                                    $this->object->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Validation function {$callable} is not a valid callable function.");
                                }
                                break;
                            case 'preg_match':
                                $result= (boolean) preg_match($rule['rule'], $this->object->_fields[$column]);
                                if (!$result) $this->addMessage($column, $ruleName, isset($rule['parameters']['message']) ? $rule['parameters']['message'] : $ruleName . ' failed');
                                if ($this->object->xpdo->getDebug() === true)
                                    $this->object->xpdo->log(xPDO::LOG_LEVEL_DEBUG, "preg_match validation against {$rule['rule']} resulted in " . print_r($result, 1));
                                break;
                            case 'xPDOValidationRule':
                                if ($ruleClass= $rule['rule']) {
                                    if (strpos($ruleClass, '\\') === false && strpos($ruleClass, '.') === false) {
                                        $ruleClass = __NAMESPACE__ . '\\' . $ruleClass;
                                    }
                                    if ($ruleObject= new $ruleClass($this, $column, $ruleName)) {
                                        $callable= array($ruleObject, 'isValid');
                                        if (is_callable($callable)) {
                                            $callableParams= array($this->object->_fields[$column], $rule['parameters']);
                                            $result= call_user_func_array($callable, $callableParams);
                                        } else {
                                            $this->object->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Validation rule class {$rule['rule']} does not have an isValid() method.");
                                        }
                                    }
                                } else {
                                    $this->object->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not load validation rule class: {$rule['rule']}");
                                }
                                break;
                            default:
                                $this->object->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Unsupported validation rule: " . print_r($rule, true));
                                break;
                        }
                        $columnResults[$ruleName]= $result;
                        if (!$result && $stopOnRuleFail) {
                            break;
                        }
                    }
                    $this->results[$column]= !in_array(false, $columnResults, true) ? true : false;
                    if (!$this->results[$column] && $stopOnFail) {
                        break;
                    }
                }
                if ($this->results[$column]) {
                    $this->object->_validated[$column]= $column;
                }
            }
            if (empty($this->results) || !in_array(false, $this->results, true)) {
                $validated = true;
                if ($this->object->xpdo->getDebug() === true)
                    $this->object->xpdo->log(xPDO::LOG_LEVEL_WARN, "Validation succeeded: " . print_r($this->results, true));
            } elseif ($this->object->xpdo->getDebug() === true) {
                $this->object->xpdo->log(xPDO::LOG_LEVEL_WARN, "Validation failed: " . print_r($this->results, true));
            }
        } else {
            if ($this->object->xpdo->getDebug() === true) $this->object->xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Validation called but no rules were found.");
            $validated = true;
        }
        return $validated;
    }
1055012
protected function addFailure( $attribute, $rule, array $parameters )
	{
		$this->addError( $attribute, $rule, $parameters );

		$this->failedRules[ $attribute ][ $rule ] = $parameters;
	}
16531
private function parseRule($rule)
    {
        $parameters = [];

        if (strpos($rule, ':') !== false) {
            list($rule, $parameter) = explode(':', $rule, 2);
            $parameters = $this->parseParameters($rule, $parameter);
        }

        if (!Variable::ruleExists($rule)) {
            throw new \InvalidArgumentException("validation: rule '$rule' not supported.");
        }

        return [$rule, $parameters];
    }
884494
public function notSubmitterEmail($field, $value, $parameters)
    {
        if ($this->guard->guest()) {
            return true;
        }

        $userEmail = $this->guard->user()->email;
        $emails    = $this->bannedEmailService->getEmailTemplatesFromRepository()->push($value);

        foreach ($emails->all() as $emailTemplate) {
            $emailRule = new Email($emailTemplate);

            if ($emailRule->check($userEmail)) {
                return false;
            }
        }

        return true;
    }
182592
public function removeRuleFromItems($rule) {
		$result = $this->repository->removeRuleFromItems($rule);
		$this->domain->const->generateAll();
		return $result;
	}
124542
public function revokeRule($rule)
    {
        if ($this->hasRule($rule)) {
            unset($this->rules[$rule]);
            return true;
        } else {
            return false;
        }
    }
327769
public function makeReplacements($message, $attribute, $rule, $parameters)
    {
        $message = $this->replaceAttributePlaceholder(
            $message, $this->getDisplayableAttribute($attribute)
        );

        $message = $this->replaceInputPlaceholder($message, $attribute);

        if (isset($this->replacers[Str::snake($rule)])) {
            return $this->callReplacer($message, $attribute, Str::snake($rule), $parameters, $this);
        } elseif (method_exists($this, $replacer = "replace{$rule}")) {
            return $this->$replacer($message, $attribute, $rule, $parameters);
        }

        return $message;
    }
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)]);
        }
    }
846123
protected function __checkRule($rule) {
        $fields = explode(',', $rule[0]);
        if (is_string($rule[1])) {
            $conditions = explode(',', $rule[1]);
            foreach ($conditions as $k => $item) {
                $item = trim($item);
                $conditions[$k] = isset($this->aliases[$item]) ? $this->aliases[$item] : $item;
            }
        } else {
            $conditions = array($rule[1]);
        }
        $valid = true;
        foreach ($conditions as $condition) {
            foreach ($fields as $field) {
                $field = trim($field);
                $label = isset($this->labels[$field]) ? $this->labels[$field] : ucwords(str_replace('_', ' ', $field));
                $errorMessage = isset($rule['message']) ? $this->translate(str_replace(array('__VALUE__', '__LABEL__'), array((!is_null($this->getValue($field))) ? $this->getValue($field) : ' - no value -', $label), $rule['message'])) : null;
                if ('required' == $condition && ((is_null($this->getValue($field))) || (is_array($this->getValue($field)) && !count($this->getValue($field))) || (is_string($this->getValue($field)) && '' == trim($this->getValue($field))))) {
                    if (!isset($this->errors[$field])) {
                        $this->errors[$field] = array();
                    }
                    $this->errors[$field][] = $errorMessage ? $errorMessage : $this->translate($label . ' is required!');
                    $valid = false; // if it's required but not defined then the rule it's not valid.
                    continue;
                } elseif (is_null($fieldValue = $this->getValue($field)) || (is_array($fieldValue) ? !count($fieldValue) : !trim($fieldValue))) { // if it's not required and not defined then there is nothing to check
                    if (isset($rule['default_value'])){
                        $this->setValue($field, $rule['default_value']);
                    }
                    continue;
                }
                if ('required' == $condition || 'safe' == $condition) { // skip required as it was checked above also skip safe as it is a model condition and not implemented here
                    continue;
                }
                try {
                    // actually check conditions here (except for required which is an exception from the rule
                    if (is_string($condition)) { // check local condition
                        $valid = $valid && $this->{'filter' . ucwords($condition)}($field, $rule, $label, $errorMessage);
                    } elseif (is_callable($condition)) { // check method condition
                        $valid = $valid && $condition($this, $field, $rule, $label, $errorMessage);
                    }
                } catch (\Exception $e) {
                    $valid = false;
                    if (!isset($this->errors[$field])) {
                        $this->errors[$field] = array();
                    }
                    $this->errors[$field][] = is_array($e) ? $e['message'] : $e->getMessage();
                }
            }
        }
        return $valid;
    }