src/core/validator/Validator.php
private function applyRuleToField(
        string $fieldName,
        string $ruleName,
        array $options = []
    ): void {
        if (!isset($this->rules[$ruleName])) {
            throw new Exception('Undefined rule name.');
        }
        $func = $this->rules[$ruleName][0];
        if (!$func($fieldName, $options)) {
            if (isset($this->rules[$ruleName][1])) {
                if (is_callable($this->rules[$ruleName][1])) {
                    // If message entity is function
                    $funcMsg = $this->rules[$ruleName][1];
                    $this->addError($funcMsg($fieldName, $options));
                } else {
                    // If message entity is string
                    $this->addError((string) $this->rules[$ruleName][1]);
                }
            } else {
                // If message entity isn't set
                $this->addDefaultError($fieldName);
            }
        }
    }
private function applyRuleToField(
        string $fieldName,
        string $ruleName,
        array $options = []
    ): void {
        if (!isset($this->rules[$ruleName])) {
            throw new Exception('Undefined rule name.');
        }
        $func = $this->rules[$ruleName][0];
        if (!$func($fieldName, $options)) {
            if (isset($this->rules[$ruleName][1])) {
                if (is_callable($this->rules[$ruleName][1])) {
                    // If message entity is function
                    $funcMsg = $this->rules[$ruleName][1];
                    $this->addError($funcMsg($fieldName, $options));
                } else {
                    // If message entity is string
                    $this->addError((string) $this->rules[$ruleName][1]);
                }
            } else {
                // If message entity isn't set
                $this->addDefaultError($fieldName);
            }
        }
    }
The method applies the validation rule to the validable field.
@param string $fieldName The field name. The name of the nested field is
formed by the path of the tree the tiers of which are separated by the point.
@param string $ruleName The validation rule name.
@param array $options The validation options.
@return void
@throws \extensions\validator\Exception