Validator class for Django model JSON fields.
Project description
Django JSON Schema Field Validator
JSON Schema validation for Django JSONField.
Quickstart
Installation
pip install jsonfield-validation
Usage
from jsonfield_validation import JsonSchemaValidator
class MyModel(models.Model):
items = models.JSONField(
validators=[
JsonSchemaValidator({"maxItems": 2})
]
)
Like any Django model field validator, validation happens when clean_fields() is called on a model instance:
>>> instance = MyModel(items=[1, 2, 3])
>>> instance.clean_fields()
django.core.exceptions.ValidationError: {'items': ["[1, 2, 3] is too long"]}
Further documentation is gratiously hosted by Read the Docs
Credits
This package was created with Cookiecutter and the pymetrics/cookiecutter-python-library project template.
History
0.2.0 (2022-06-15)
Add check method.
0.1.0 (2022-06-14)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsonfield_validation-0.2.0.tar.gz
(13.1 kB
view hashes)
Built Distribution
Close
Hashes for jsonfield_validation-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdcf98df408f1563cf057fbec9407b2cbf123a66b76d6d91f641be4db006bd5d |
|
MD5 | 83e1216966b6d370989f8882f5c8d1f4 |
|
BLAKE2b-256 | d1141211f8c8885b0b2d51ec65e427117984811289e06b2f4853709db7b6a440 |
Close
Hashes for jsonfield_validation-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f1e76380a7f2d8d1b2e93f6d6796e825cb630dc78b58018ff44966595d508b9 |
|
MD5 | 3b6f4634f1dba70709002a499a90b98f |
|
BLAKE2b-256 | cf356fa3dd7c55d87ec4b16c1217d230fd372c15fee4cd68e74617e94340f96e |