JSON schema validator.
Project description
jsonvl
jsonvl is a JSON validator for Python. This project is intended to be a replacement for the jsonschema package which implements the JSON Schema standard. jsonvl's goal is to curate a rich set of constraints for JSON data types while remaining extensible to arbitrary data constraints.
Note: This package is a work in progress and contributions are welome.
Installation
Install the current PyPI release:
pip install jsonvl
Usage
Validate JSON from the command line
jsonvl data.json schema.json
Validate JSON in Python
from jsonvl import validate_file
validate_file('data.json', 'schema.json')
Roadmap
- JSON data type checking
- Number, string, boolean, and null primitives
- Array and object collections
- Number constraints
- lt
- gt
- eq
- String constraints
- in
- eq
- format
- regex
- phone
- Array constraints
- max_size
- min_size
- unique
- Path traversal for multi-level constraints
- Quantifiers for array traversal
- Union types (including nullable)
- Type definitions and references
- Custom constraints
Example
Data
{
"play": "A Midsummer Night's Dream",
"characters": [
{ "name": "Helena", "loves": ["Demitrius"] },
{ "name": "Demitrius", "loves": ["Hermia", "Helena"] },
{ "name": "Hermia", "loves": ["Lysander"] },
{ "name": "Lysander", "loves": ["Hermia", "Helena", "Hermia"] },
{ "name": "Titania", "loves": ["Oberon", "Bottom", "Oberon"] },
{ "name": "Oberon", "loves": ["Titania"] },
{ "name": "Bottom", "loves": [] },
{ "name": "Puck", "loves": [] }
]
}
Schema
{
"type": "object",
"attr": {
"play": "string",
"characters": {
"type": "array",
"cons": {
"unique": "@all.name"
},
"elem": {
"type": "object",
"attr": {
"name": "#name",
"loves": {
"type": "array",
"elem": "#name",
"cons": { "max_size": 4 }
}
}
}
}
},
"defs": {
"#name": {
"type": "string",
"cons": {
"format": { "type": "regex", "pattern": "[A-Z][a-z]{0,10}" }
}
}
}
}
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
jsonvl-0.1.0.tar.gz
(14.9 kB
view hashes)
Built Distribution
jsonvl-0.1.0-py3-none-any.whl
(21.7 kB
view hashes)