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
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 schema-validator-halpa-0.0.7.tar.gz
.
File metadata
- Download URL: schema-validator-halpa-0.0.7.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12258daa654a0e1871c729f966f829e0402c248018b83f2ffb71fb8bb485da31 |
|
MD5 | 156f3216ec617920380efebddec11467 |
|
BLAKE2b-256 | 8042c221e6e3ed5feed34d01bfe243ae41c198dd38c293f0fb6b0c71558a87d7 |
File details
Details for the file schema_validator_halpa-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: schema_validator_halpa-0.0.7-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe23783368709e2b33ba41e00d35d4815f3053c42bd502b5d0e7fa10d089a275 |
|
MD5 | 0e1a88d5fa671f0ec0cebfe507a1bc2c |
|
BLAKE2b-256 | b036dfc551867375a03a07660de8297db8544cebc3d4610fd40cba66f9185d84 |