    def _check_model(self, model, model_types, name):
        """Check a model provided by a REST API request

        Args:
            model (dict): user-provided model
            model_types (dict): dict of key:type used to validate types and keys
            name (str): name of the model, used in error messages
        """
        if not isinstance(model, dict):
            raise web.HTTPError(400, f"Invalid JSON data: {model!r}")
        if not set(model).issubset(set(model_types)):
            raise web.HTTPError(400, f"Invalid JSON keys: {model!r}")
        for key, value in model.items():
            if not isinstance(value, model_types[key]):
                raise web.HTTPError(
                    400,
                    f"{name}.{key} must be {model_types[key]}, not: {type(value)!r}",
                )
Check a model provided by a REST API request

Args:
model (dict): user-provided model
model_types (dict): dict of key:type used to validate types and keys
name (str): name of the model, used in error messages
jupyterhub/apihandlers/base.py