public function factory(string $name, $arg = null): Rule
    {
        if (!array_key_exists($name, $this->definitions)) {
            throw new \InvalidArgumentException("No rule registered with name: $name");
        }
        $vrule = is_array($arg) ?
            call_user_func_array($this->definitions[$name], $arg) :
            call_user_func($this->definitions[$name], $arg);
        if (!$vrule instanceof Rule) {
            throw new \UnexpectedValueException('Definitions must return Rule objects');
        }
        return $vrule;
    }