Trivial validation - when the full power of the JSON Schema is not needed
This library provides a simplistic way to validate a dictionary against something resembling a schema - a dictionary describing the desired data structure by example.
The main entry point is the validate() function, but the various
validate_*() functions may be invoked directly with appropriate
arguments.
The schema used for validation is a dictionary (the top-level object must
be a dictionary). For the present, the keys may only be strings.
A special case of a dictionary with a single key * means any value for
a key will be accepted. Otherwise, all keys with names not starting with
a ? character are mandatory, and any keys with names starting with
a ? character are optional.
The dictionary values may be any of:
- a Python type signifying that the value must be an instance thereof
- a single-element list signifying that the value must be a list with all the elements validated by the same rules as a dictionary value (i.e. one of a Python type, a single-element list, a set, or a dictionary)
- a set signifying that the value must be exactly equal to one of the set elements, i.e. an enumeration of the allowed values
- a dictionary with the same semantics as described above
For example, the following schema:
{
"name": str,
"id": int,
"address": [str],
"preferences": {
"meal": set(("breakfast", "lunch", "brunch")),
"colors": [{
"name": str,
"intensity": set(["dark", "light"])
}]
},
"possessions": {
"*": int
}
}
...may be used to validate the following dictionary:
{
"name": "A. N. Nymous",
"id": 13,
"address": [
"42 Nowhere Circle",
"Notown-at-all",
"Unnamed territory"
],
"preferences": {
"meal": "brunch",
"colors": [
{"name": "blue", "intensity": "light"},
{"name": "green", "intensity": "dark"}
]
},
"possessions": {
"pencil": 4,
"paper": 0
}
}
Metadata
Release files for trivval 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| trivval-1.1.2.tar.gz | 13.9 kB | Without provenance | Details for trivval-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trivval-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for trivval-1.1.2-py3-none-any.whl |
Total release size: 18.9 kB
Release files / trivval-1.1.2.tar.gz
| Download URL | trivval-1.1.2.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c50267a2542209a9de73a4c289fa03597d339f53f5379c17ac8e03a18644d71e
|
|
BLAKE2b-256 checksum How to use checksums |
aae0aefb77b14f446c9c30ec59238f260452b2790d736d4255a61e3db89c13c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / trivval-1.1.2-py3-none-any.whl
| Download URL | trivval-1.1.2-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc2cb572498b60eae8a0b93db96b1a5a553e52562e6425d7bae22751bccb74f1
|
|
BLAKE2b-256 checksum How to use checksums |
c7d9477d46425e966e2ecc9020e1b2ce1008afb84bb09b1ba2ed2aa3776f3c69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for trivval 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.