Metadata-Version: 2.1
Name: jsonfield-validation
Version: 0.3.0
Summary: Validator class for Django model JSON fields.
Home-page: https://github.com/chrislawlor/jsonfield-validation
Author: Chris Lawlor
Author-email: lawlor.chris@gmail.com
Keywords: jsonfield_validation
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Framework :: Django :: 1.11
Classifier: Framework :: Django :: 2.2
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Requires-Python: >=3.6
License-File: LICENSE.txt

==================================
Django JSON Schema Field Validator
==================================

.. image:: https://app.travis-ci.com/chrislawlor/jsonfield-validation.svg?branch=master
    :target: https://app.travis-ci.com/chrislawlor/jsonfield-validation

.. image:: https://readthedocs.org/projects/jsonfield-validation/badge/?version=latest
    :target: https://jsonfield-validation.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status

JSON Schema validation for Django JSONField.


Quickstart
----------

Installation
++++++++++++

.. code:: bash

    pip install jsonfield-validation

Usage
+++++

.. code:: python

    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:


.. code:: python

    >>> 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.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`pymetrics/cookiecutter-python-library`: https://github.com/pymetrics/cookiecutter-python-library
.. _`Read the Docs`: https://jsonfield-validation.readthedocs.io

=======
History
=======

0.3.0 (2022-06-15)
------------------

* Add path to invalid value to error_list message,

0.2.0 (2022-06-15)
------------------

* Add check method.


0.1.0 (2022-06-14)
------------------

* First release on PyPI.
