def validate_schema(schema, **kwargs):
    def decorator(callback):
        def convert_to_dict(bottle_form):
            """
            Function for converting a bottle multiple non-unique keys
            dictionary to a normal python dictionary with lists automatically
            created where appropriate, according to the JSON schema.
            """
            d = {}
            for key, value in bottle_form.iterallitems():
                if key not in d:
                    d[key] = value
                    if key in schema.get('properties') and not isinstance(value, list):
                        if 'array' == schema['properties'][key].get('type') or 'array' in schema['properties'][key].get('type'):
                            d[key] = [value]
                else:
                    if isinstance(d[key], list):
                        d[key] += [value]
                    else:
                        d[key] = [d.get(key)] + [value]
            return d

        @wraps(callback)
        def wrapper(*args, **kwargs):
            if request.headers.get("Content-Type") in ("application/json", "application/javascript", "text/javascript"):
                data = request.json
                instance = data
            else:
                data = request.forms
                data.update(request.query)
                instance = convert_to_dict(data)
            request.cleaned_data = instance
            errors = jsonvalidation.get_error_dictionary(
                schema=schema, instance=instance)
            if errors:
                raise ValidationError(
                    message=_("There were errors validating your request."),
                    fields=errors)
            return callback(*args, **kwargs)
        return wrapper
    return decorator
Validate input according to some JSON-schema file,
dataset/ETHPy150Open gengo/decanter/decanter/lib/decorator.py/validate_schema