Schema validation for Python data structures
Project description
Basic validation for Python data structures in a mostly declarative form (there is an escape hatch in “extraValidation” callables).
Validation errors are reported as both a path within the data structure (sequence of indices or keys) and a descriptive message (string).
Typical usage:
data = json.load(some_file) # or pickle, or ...
errors = dataschema.Validator(my_schema).validate(data)
if errors:
for path, message in errors:
# Report error `message` at path `path`.
else:
# Any data access or application-specific validation can now
# rely on properties of my_schema (e.g. minimum number of
# elements in a sequence, data types of elements, presence of
# certain keys in a dict, etc.).
See the unit tests for schema examples.
There are a few limitations (only string keys for any dictionaries in data) and a more fully Pythonic validator might focus on interfaces and abstract base classes over concrete types. However, dataschema is a great improvement over ad hoc validation code for many uses today.
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
File details
Details for the file dataschema-0.1.tar.gz.
File metadata
- Download URL: dataschema-0.1.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a7330c9e264a8aee4d1faa61337ae4f89fdba14ef50e8addac1a73f72c42b5f
|
|
| MD5 |
18d35697dab4b31d34b3e66f03d0067d
|
|
| BLAKE2b-256 |
382897a6609c6f3fde5e797cdde6bae9fd287e4eff66325ef68b7da4b8b8e382
|