Skip to main content

Tiny tool for Django JSONField validation

Project description

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)])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page