Fast Python JSON schema validation and normalization
Project description
Fast Python JSON schema validation and normalization
v = Validator({
'User': {
'items': {
'name': {'coerce': 'str'},
'gender': {
'map': {
'woman': 'female',
'man': 'male',
None: 'other' # Map everything else
},
'synonyms': ['sex']
},
'country': {
'default': '{GEOIP2_COUNTRY}'
}
}
}
})
args = {'GEOIP2_COUNTRY': 'UK'}
v['User']({
'name': 123,
'sex': 'woman'
}, args)
# Returns:
#
# ({
# 'name': '123',
# 'gender': 'female',
# 'country': 'UK'
# },
# None) # Error description
Features
Pycoercer was created to meet the actual production needs for web apps development - inspired by jsonschema and Cerberus, it also implements additional features: - Can validate, normalize (or coerce) dicts and lists - Fast - the schema is compiled into python code - Clean rules system with a predictable order of execution - Parametric default and if_null values - Keywords for data coercion: synonyms, map, and post_coerce - Check examples against the schema definition
Installation
$ pip install pycoercer
Documentation
Complete documentation will be [sometime][docs]
Testing
$ pytest
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
File details
Details for the file pycoercer-0.1.2.tar.gz.
File metadata
- Download URL: pycoercer-0.1.2.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f2c8705b6702852dfa287a7a9a130c2fba3ab06f5ae7121bcec463a8224f2eb
|
|
| MD5 |
bf9729d8540506ee4072ae896db21b96
|
|
| BLAKE2b-256 |
f58212634bc526b783a2d34cb772032bdc7fc0a306557bc4983125c92ab6e4fc
|