src/core/validator/Validator.php
public function addRule(string $name, callable $func, $errorMsg = null): self
    {
        $this->rules[$name] = array($func, $errorMsg);
        return $this;
    }
public function addRule(string $name, callable $func, $errorMsg = null): self
    {
        $this->rules[$name] = array($func, $errorMsg);
        return $this;
    }
The method adds a validation rule to the stack of validator rulesets.
@param string $name The name of rule.
@param callable $func The callback function that defines the functional
of the data validation rule. The first parameter is the name of the validated
field, the second optional parameter is the set of validation options,
and the context (closure) is the input data.
@param string|callable|null $errorMsg The error message or callable function
which generates this message. This parameter is optional.
@return self