A dead-simple utility that validates if object has a certain structure.
Project description
Simple schema validator
A dead-simple utility that validates if object has a certain structure. Used in some of our projects.
An example:
Lets say we have an API that returns the following data:
{
"user": 1,
"profile": {
"email": "some@user.com",
"name": "Some User",
"age": 20
},
"tokens": {
"jwt": "...",
"refresh": "...",
"firebase": "...",
}
}
And we are writing a simple integration test, that wants to assure the response has a certain structure.
Then we can use the schema validator like so:
data = get_data_from_api()
schema = {
'user': None,
'profile': {
'email': None,
'name': None,
'age': None
},
'tokens': {
'jwt': None,
'refresh': None,
'firebase': None
}
}
valid, missing_keys, additional_keys = schema_validator(schema, data)
assert valid, f'Response not valid, missing: {missing_keys}, additional: {additional_keys}'
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 simple_schema_validator-0.0.1.tar.gz
.
File metadata
- Download URL: simple_schema_validator-0.0.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8527d3278bf51e78aab55110a11c367fa0b56aee9e907bab61048866768d1024 |
|
MD5 | 4b2123d2fbd307e9b92dc435fb1686b5 |
|
BLAKE2b-256 | 83a1a509c41a0ebf2eb2d94b137ab8515ce90d0551d80a783fad63825b567911 |
File details
Details for the file simple_schema_validator-0.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: simple_schema_validator-0.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56e528b0b4514eff3106a918d14cd56e3fe8e5c601276502ff5b9eb285a20ef8 |
|
MD5 | e8d5387887e913f11f72b60ff9c9a076 |
|
BLAKE2b-256 | 26e5b3e94a7e77535f6c45812001778611fc9cf380dfd51842ebb1c19dff6fa5 |