private function validateAndUpdateOptions(array $options, $type)
    {
        if (is_string($type)) {
            $type = $this->types->getType($type);
        }

        if (!($type instanceof InputTypeInterface)) {
            throw new InputTypeNotFoundException("Type should be an instance of InputTypeInterface or a string");
        }

        $defaults = $this->getDefaultOptions($type);
        foreach ($options as $key => $value) {
            if (!array_key_exists($key, $defaults)) {
                $allowed = implode(', ', array_keys($defaults));
                throw new InvalidInputException(
                    "Found non-default option '{$key}', only allowed to use one of {$allowed}."
                );
            }
        }
        return array_merge($defaults, $options);
    }