Skip to main content

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": "",
    "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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for simple-schema-validator, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size simple_schema_validator-0.0.1-py2.py3-none-any.whl (4.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size simple_schema_validator-0.0.1.tar.gz (4.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page