general purpose python data validator
Project Links
Meta
Author: James Turk
Classifiers
Development Status
- 4 - Beta
Intended Audience
- Developers
License
- OSI Approved :: MIT License
Natural Language
- English
Operating System
- OS Independent
Programming Language
- Python
- Python :: 3.8
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: Implementation :: CPython
- Python :: Implementation :: PyPy
Topic
- Software Development :: Libraries :: Python Modules
- warning:
:warning: As of 2018 this library is deprecated, please consider using jsonschema (https://pypi.python.org/pypi/jsonschema) instead.
A general purpose Python data validator.
Schema format based on JSON Schema Proposal (http://json-schema.org)
Contains code derived from jsonschema, by Ian Lewis and Yusuke Muraoka.
Usage
JSON documents and schema must first be loaded into a Python dictionary type before it can be validated.
Parsing a simple JSON document:
>>> import validictory
>>>
>>> validictory.validate("something", {"type":"string"})
Parsing a more complex JSON document:
>>> import json
>>> import validictory
>>>
>>> data = json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
>>> schema = {
... "type":"array",
... "items":[
... {"type":"string"},
... {"type":"object",
... "properties":{
... "bar":{
... "items":[
... {"type":"string"},
... {"type":"any"},
... {"type":"number"},
... {"type":"integer"}
... ]
... }
... }
... }
... ]
... }
>>> validictory.validate(data,schema)
Catch ValueErrors to handle validation issues:
>>> import validictory
>>>
>>> try:
... validictory.validate("something", {"type":"string","minLength":15})
... except ValueError, error:
... print(error)
...
Length of value 'something' for field '_data' must be greater than or equal to 15
You can read more in the official documentation at Read the Docs.
1.1.3
Jan 14, 2024
1.1.2
Dec 01, 2017
1.1.1
Apr 04, 2017
1.1.0
Oct 16, 2016
1.0.2
Jun 21, 2016
1.0.1
Sep 24, 2015
1.0.0
Jan 16, 2015
1.0.0a2
Jul 15, 2014
1.0.0a1
Jul 10, 2014
0.9.3
Nov 26, 2013
0.9.2
Nov 25, 2013
0.9.1
May 23, 2013
0.9.0
Jan 19, 2013
0.8.3
Mar 14, 2012
0.8.2
Mar 10, 2012
0.8.1
Mar 04, 2012
0.8.0
Mar 04, 2012
0.7.2
Sep 27, 2011
0.7.1
May 03, 2011
0.7.0
Mar 15, 2011
0.6.1
Jan 21, 2011
0.6.0
Jan 20, 2011
0.5.0
Jan 13, 2011
0.4.2
Oct 05, 2010
0.4.1
Aug 27, 2010
0.4
Aug 02, 2010