Skip to content

malderete/django-jsonvalidator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

=============== django-jsonvalidator

django-jsonvalidator is a simple decorator that validates JSON data against a fixed SCHEMA.

I've copied and pasted this so often that I decided to create a reusable app.

Usage

Just import the decorator::

from jsonvalidator.decorators import json_validator

EXPECTED_SCHEMA = {
    "type": "object",
    "required": ["foo", "bar"],
    "properties": {
        "foo": {"type": "string"},
        "bar": {"type": "string"}
    }
}

@json_validator(EXPECTED_SCHEMA, lambda r: r.body)
def my_view(request):
    # Just enter here if request.body is valid against EXPECTED_SCHEMA

About

A simple decorator that validates JSON data against a fixed schema

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published