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

Upload package

# Set your user with python keyring
python3 -m keyring set https://upload.pypi.org/legacy/ $username
# substitue $username with your actual username

# Update packaging tools
python3 -m pip install --user --upgrade setuptools wheel twine

# Remove dist folder
rm -rf dist/*

# Create a new dist
python3 setup.py sdist bdist_wheel
# Above command creates
# dist/
#  schema-validator-halpa-0.0.5-py3-none-any.whl
#  schema-validator-halpa-0.0.5.tar.gz
# where "0.0.1" is equivalent to value in "version" from setup.py

# Upload the package
python3 -m twine upload dist/*

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.6rc4.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file schema-validator-halpa-0.0.6rc4.tar.gz.

File metadata

  • Download URL: schema-validator-halpa-0.0.6rc4.tar.gz
  • Upload date:
  • Size: 3.9 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.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

File hashes

Hashes for schema-validator-halpa-0.0.6rc4.tar.gz
Algorithm Hash digest
SHA256 5e2ef61fb1f1691ea9f334ca51a1f40dec66dac7f244347b8c34bc87a7c08eca
MD5 eb3e07ff18ec99c9566fa7713075f6b3
BLAKE2b-256 0a14896425ff271a774e4db8f6f59a14efb466eab9e813f621388710fd053723

See more details on using hashes here.

File details

Details for the file schema_validator_halpa-0.0.6rc4-py3-none-any.whl.

File metadata

  • Download URL: schema_validator_halpa-0.0.6rc4-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

File hashes

Hashes for schema_validator_halpa-0.0.6rc4-py3-none-any.whl
Algorithm Hash digest
SHA256 3bc80728faed7901b27545494c8341f3a42eca36d7b94aba301e2f841d07f2c5
MD5 65531900022498e5fab873a96eb7e656
BLAKE2b-256 2ad128003251ba5182247f317cae110fe82c846a437fd0a7e7a40fde6702c7f8

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