django-json-field-schema-validator

Tiny tool for Django JSONField validation


Keywords
django, json, field, schema, validator, tools
License
MIT
Install
pip install django-json-field-schema-validator==0.0.2

Documentation

django-json-field-schema-validator

Build Status Coverage Status Code style: black

Tiny tool for Django JSONField validation through JSON Schema

Installation

pip install django-json-field-schema-validator

Example

from django.db import models
from django_json_field_schema_validator.validators import JSONFieldSchemaValidator

schema = {
    '$schema': f'http://json-schema.org/draft-07/schema#',
    'type': 'object',
    'properties': {
        'foo': {'type': 'number'},
        'bar': {'type': 'string'}
    },
    'required': ['foo', 'bar']
}

class SomeModel(models.Model):
    some_field = models.JSONField(validators=[JSONFieldSchemaValidator(schema)])