Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

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

Stars

16 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages