public function registerRuleExtension($rule, string $slug = '')
    {
        if ($rule instanceof IRule) {
            $slug = $rule->getSlug();
        }

        if (is_callable($rule)) {
            $callback = $rule;
            $rule = new CallbackRule();
            $rule->setArgs([$callback]);
        }

        if (!$rule instanceof IRule) {
            throw new InvalidArgumentException('Rule must either be a callback or implement IRule');
        }

        $this->extensions[$slug] = $rule;
    }