public function aliasDefinition($definition): self
    {
        if (is_object($definition)) {
            $definition = (array) $definition;
        }
        if (!is_array($definition)) {
            throw new \InvalidArgumentException("Invalid alias definition: must be an object or an associative array");
        }
        if (!isset($definition['name']) || !isset($definition['rules'])) {
            throw new \InvalidArgumentException("Invalid alias definition: must have 'name' and 'rules' fields");
        }
        return $this->alias($definition['name'], $definition['rules'], $definition['error'] ?? null);
    }