Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sonic182/json_validator
A json validator focused on speed
https://github.com/sonic182/json_validator
python utility
Last synced: 1 day ago
JSON representation
A json validator focused on speed
- Host: GitHub
- URL: https://github.com/sonic182/json_validator
- Owner: sonic182
- License: mit
- Created: 2017-09-23T06:44:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-20T17:36:47.000Z (almost 4 years ago)
- Last Synced: 2025-02-12T18:19:59.976Z (9 days ago)
- Topics: python, utility
- Language: Python
- Homepage:
- Size: 47.9 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
|Build Status| |Coverage Status| |PyPI version|
Json Validator
==============A json validator focused on speed.
- Not recursion
- Works with Python 2.7.x, 3.4.x, 3.5.x, 3.6. It may work with 3.7.X
- Constrains based on python types.
- Lazy Validation.. code:: python
from json_validator import JsonValidator
constrain = {
'string': {}, # str by default.
'integer': {'type': int},
'float': {'type': float},
'boolean': {'type': bool},
'json': {'type': dict },
'list': {'type': list},
'extra_1': {},
'extra_2': {},
}
json = {
'string': 'foo',
'integer': 42,
'float': 1.10,
'boolean': True
}
# accepts json string, dict and lists.
res, err = JsonValidator(constrain).validate(json)
res == json # => True
err == {'extra_1': 'Missing field', 'extra_2': 'Missing field'} # => TrueSee all rules for fields `here`_.
Install
=======.. code:: bash
pip install sonic182_json_validator
Development
===========Install packages with pip-tools:
.. code:: bash
pip install pip-tools
pip-compile
pip-compile dev-requirements.in
pip-sync requirements.txt dev-requirements.txtTODO
====- Documentation about rules.
Contribute
==========1. Fork
2. create a branch ``feature/your_feature``
3. commit - push - pull requestThanks :)
.. _here: https://github.com/sonic182/json_validator/blob/master/tests/test_validator.py
.. |Build Status| image:: https://travis-ci.org/sonic182/json_validator.svg?branch=master
:target: https://travis-ci.org/sonic182/json_validator
.. |Coverage Status| image:: https://coveralls.io/repos/github/sonic182/json_validator/badge.svg?branch=master
:target: https://coveralls.io/github/sonic182/json_validator?branch=master
.. |PyPI version| image:: https://badge.fury.io/py/sonic182_json_validator.svg
:target: https://badge.fury.io/py/sonic182_json_validator