public function set($key, $value)
    {
        if (is_array($key) && $value === null)
            $args = $key;
        else
            $args = func_get_args();

        $path = $args;
        $value = array_pop($path);
        $type = $this->types->dget($path);
        $kpath = implode('.', $path);

        // Key is undefined, but it may be in a untyped sub-array
        if ($type === null)
        {
            $cpy = $path;
            while (count($cpy))
            {
                $last = array_pop($cpy);
                $subtype = $this->types->dget($cpy);
                if ($subtype instanceof Validator && $subtype->getType() === Type::ARRAY)
                    return parent::set($args, null);
            }
        }

        if ($type === null)
            throw new \InvalidArgumentException("Undefined key: " . $kpath);

        if ($type instanceof Dictionary)
        {
            // Subfiltering required - extract values
            if (!Functions::is_array_like($value))
                throw new \InvalidArgumentException("Value must be array at: " . $kpath);

            foreach ($value as $subkey => $subval)
            {
                $nargs = $path;
                $nargs[] = $subkey;
                $nargs[] = $subval;
                $this->set($nargs, null);
            }
            return;
        }

        if (!$type->validate($value))
        {
            $error = $type->getErrorMessage($value);
            $msg = WF::fillPlaceholders($error['msg'], $error['context'] ?? []);
            throw new \InvalidArgumentException($msg);
        }

        return parent::set($args, null);
    }