Skip to main content

A utility to validate JSON schemas with jsonschema with simplejson

Project description

Package

This package is a wrapper for jsonschema and simplejson to simplyfy JSON schema validation specified by JSON Schema Draft 7 (link to IETF).

Example

from validator import validate

# Define the validation schema
schema = {
    "type": "object",
    "required": [
        "name",
        "age",
    ],
    "properties": {
        "name": { "type": "string" },
        "age": { "type": "number" },
    }
}

# Data to be validated
data = {
    "name": "Daniel",
    "age": 30,
}

# Validate and run
validation = validate(schema, data)
if validation==True:
    # do something with data, e.g. create a new friend
else:
    print(validation) # will show a well formated dict with errors

Note: More examples can be shown in the tests

Contribute

This package is intended to be used by private projects. But go ahead if you like and make comments and pull requests and I might look into it.

Install the package

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Run tests

python -m pytest -m validator -s

Project details


Download files

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

Source Distribution

schema-validator-halpa-0.0.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

schema_validator_halpa-0.0.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file schema-validator-halpa-0.0.1.tar.gz.

File metadata

  • Download URL: schema-validator-halpa-0.0.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

File hashes

Hashes for schema-validator-halpa-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c97616610025c2ae8a344cf6e4bf907b1101b6fdb0ce987f42cf82a8e891ac32
MD5 740bfda0203dc05ff756ec89105507ad
BLAKE2b-256 3e575ff6d6cc16332000c2ec52d936dc90d7516d8b3ca6efa0d1fe752379b82d

See more details on using hashes here.

File details

Details for the file schema_validator_halpa-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: schema_validator_halpa-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

File hashes

Hashes for schema_validator_halpa-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e662506b3e45b015e200458f74ca99ba718e65102d2e5f9da566465d5a208d5
MD5 5c5d608e35bdc06edd13ec211f65bf7d
BLAKE2b-256 c5f49fe7eaf6c72db294abd488cc5559fcecf4edfa30d47c7f21c224586347ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page