Utility for evaluate matching json with a template
Project description
Validation schema based of a json string or a dict
Schema:
- You must define a dict which will match with a json/dict under test
- add ! at begin fo key for to indicate a required field
- In value of that key you will need specify a validator for such field
- That validator have to be a valid default validator or you can add your own
EXAMPLE_SCHEMA = {
"!version": "string",
"!email": "email",
"!data": {
"!Id": "number",
"title": "string" # optional
},
}
Usage:
Example:
ok_json = {
"version": "1.0.1a",
"email": "test@test.com",
"data": {
"Id": 231,
"title": "description"
}
}
e = JSONEvaluator()
e.set_schema(EXAMPLE_SCHEMA)
e.evaluate(ok_json)
if e.ok:
print("Dict validate")
else:
print("errors found:")
print(e.errors)
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
File details
Details for the file json_pattern_validator-0.1.tar.gz
.
File metadata
- Download URL: json_pattern_validator-0.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f2be24f606f3cdaa9ebdf56f1bdd5383069fbc9fc369019848da9684c39f0b9 |
|
MD5 | 44be4e530600d0f0078ef10d179008ac |
|
BLAKE2b-256 | a120e454bf1d6be7a7eeb98fc6014f87053a558d54391136e88201191ece5b34 |
File details
Details for the file json_pattern_validator-0.1-py3-none-any.whl
.
File metadata
- Download URL: json_pattern_validator-0.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d707578cb0ee511df89801b0f6445595a0ee15bc98d5b984c2da9ac18a96e2c6 |
|
MD5 | d04e0b10393de828c42da6b58d83a027 |
|
BLAKE2b-256 | a33be092cb1a3982063e1a8f159f17987b343d242304a1c75431e5b3a13c3481 |