A custom json validator
Project description
[![Build Status](https://travis-ci.org/sonic182/json_validator.svg?branch=master)](https://travis-ci.org/sonic182/json_validator)
[![Coverage Status](https://coveralls.io/repos/github/sonic182/json_validator/badge.svg?branch=master)](https://coveralls.io/github/sonic182/json_validator?branch=master)
[![PyPI version](https://badge.fury.io/py/sonic182_json_validator.svg)](https://badge.fury.io/py/sonic182_json_validator)
# 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
* Constrain definitions with python types
```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'} # => True
```
See all rules for fields [here](https://github.com/sonic182/json_validator/blob/master/tests/test_validator.py).
# Install
```bash
pip install sonic182_json_validator
```
# Development
Install packages with pip-tools:
```bash
pip install pip-tools
pip-compile
pip-compile dev-requirements.in
pip-sync requirements.txt dev-requirements.txt
```
# TODO
* Documentation about rules.
# Contribute
1. Fork
2. create a branch `feature/your_feature`
3. commit - push - pull request
Thanks :)
[![Coverage Status](https://coveralls.io/repos/github/sonic182/json_validator/badge.svg?branch=master)](https://coveralls.io/github/sonic182/json_validator?branch=master)
[![PyPI version](https://badge.fury.io/py/sonic182_json_validator.svg)](https://badge.fury.io/py/sonic182_json_validator)
# 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
* Constrain definitions with python types
```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'} # => True
```
See all rules for fields [here](https://github.com/sonic182/json_validator/blob/master/tests/test_validator.py).
# Install
```bash
pip install sonic182_json_validator
```
# Development
Install packages with pip-tools:
```bash
pip install pip-tools
pip-compile
pip-compile dev-requirements.in
pip-sync requirements.txt dev-requirements.txt
```
# TODO
* Documentation about rules.
# Contribute
1. Fork
2. create a branch `feature/your_feature`
3. commit - push - pull request
Thanks :)
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
Built Distribution
Close
Hashes for sonic182_json_validator-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5f96a18863a505aa1f08c5d2b1d7238b7603b430c7a6ea60185e32081afac40 |
|
MD5 | e5d97d471ed98d8ebbd206e574025d3d |
|
BLAKE2b-256 | 6d49ae194981cf0c528bacb887f55613accc6a61006d95b23e6e94e7383669d4 |
Close
Hashes for sonic182_json_validator-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3be688a9551e102c15ef878ac9399719d09e2a08792ae61583a2d208bf7d7ec1 |
|
MD5 | a4d9ba20d22b908fce5fb378324db223 |
|
BLAKE2b-256 | b7aa36cf4a4e51c185fc82f8dcda0b3c84380e36f2b078592c3ffd46f3c7dd74 |