Another JSON-Schema Validator
Project description
jacobs-json-schema
This package is yet another JSON Schema validator. I wrote it because I needed something small to run in Python 3.5.
Most data validation features are supported without any dependencies (see "Conformance").
Documentation
Is available at Read the Docs.
Usage
Before using this library, the schema dna data must already be parsed into a Python data structure. This can be as simple as using json.loads()
.
from jacobsjsonschema.draft7 import Validator
schema = { "type": "string" }
validator = Validator(schema)
data = "Hello world"
validator.validate(data)
# Will throw if there are any validation errors
Lazy error reporting is also supported. This means that as much of the data as possible is evaluated, and errors are collected instead of raising an exception.
schema = { "type": "string" }
validator = Validator(schema, lazy_error_reporting=True)
data = "Hello world"
if validator.validate(data):
print("Validated")
else:
for error in validator.get_errors():
print(error)
Conformance
There are two ways of running the validator:
- Passing a JSON-deserialized Python dictionary as the schema. There are no additional external dependencies needed. Straightforward
$ref
references (no usage of$id
) within the same schema are supported. - Parse the schema using utility from the
jacobs-json-doc
python package, and pass the wrapped schema to the validator. Several external dependencies are required. Full$id
and$ref
functionality is supported.
Where "Mostly" is specified, it passes all tests excluding those from ref.json
, id.json
, defintions.json
, refRemote.json
and unknownKeyword.json
.
Specification | Standalone | using jacobs-json-doc |
---|---|---|
Python Version | 3.5+ | 3.7+ |
Draft-04 | Mostly | Passed |
Draft-06 | Mostly | Passed |
Draft-07 | Mostly | Passed |
Draft-2019-09 | Untested | Untested |
Draft-2020-12 | Untested | Untested |
License
MIT License. If you modify the source, please publish your modifications.
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
Built Distribution
File details
Details for the file jacobs-json-schema-0.4.2.tar.gz
.
File metadata
- Download URL: jacobs-json-schema-0.4.2.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12e6e88b59b80eef751339e11d2e289d6dd5620505f5abdb2964c78a5a459a6c |
|
MD5 | 7f2048cddf590a31e180427c7f50530f |
|
BLAKE2b-256 | ca39f1fb580e7a6242417a2dd73625b4224218d8731d1094ffd5022918359ac7 |
File details
Details for the file jacobs_json_schema-0.4.2-py3-none-any.whl
.
File metadata
- Download URL: jacobs_json_schema-0.4.2-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf4f13a32fe3a74f5f4b8898f206a5d80d7d21f14772e95d4c70a8efeaa33a8e |
|
MD5 | f724548a912d722130ad8c5da332c9b7 |
|
BLAKE2b-256 | 0f5134cc3290b13b3e7526b95887453de179343f854a52a8bfaca4bff9c26216 |