'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'

def _check_model(self, model, model_types, name):

    if (not isinstance(model, dict)):
        raise web.HTTPError(400, ('Invalid    JSON    data:    %r' % model))
    if (not set(model).issubset(set(model_types))):
        raise web.HTTPError(400, ('Invalid    JSON    keys:    %r' % model))
    for (key, value) in model.items():
        if (not isinstance(value, model_types[key])):
            raise web.HTTPError(400, ('%s.%s    must    be    %s,    not:    %r' % (name, key, model_types[key], type(value))))
