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
Close
Hashes for simple_schema_validator-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8527d3278bf51e78aab55110a11c367fa0b56aee9e907bab61048866768d1024 |
|
MD5 | 4b2123d2fbd307e9b92dc435fb1686b5 |
|
BLAKE2b-256 | 83a1a509c41a0ebf2eb2d94b137ab8515ce90d0551d80a783fad63825b567911 |
Close
Hashes for simple_schema_validator-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56e528b0b4514eff3106a918d14cd56e3fe8e5c601276502ff5b9eb285a20ef8 |
|
MD5 | e8d5387887e913f11f72b60ff9c9a076 |
|
BLAKE2b-256 | 26e5b3e94a7e77535f6c45812001778611fc9cf380dfd51842ebb1c19dff6fa5 |