general purpose python data validator
Project description
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 jsonschema >>> jsonschema.validate("simplejson", {"type":"string"}) Parsing a more complex JSON document:: >>> import simplejson >>> import jsonschema >>> >>> data = simplejson.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"} ... ] ... } ... } ... } ... ] ... } >>> jsonschema.validate(data,schema)
Handling validation errors ValueErrors are thrown when validation errors occur.:
>>> import jsonschema >>> try: ... jsonschema.validate("simplejson", {"type":"string","minLength":15}) ... except ValueError, e: ... print e.message ... Length of 'simplejson' must be more than 15.000000
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
validictory-0.4.1.tar.gz
(8.4 kB
view details)
File details
Details for the file validictory-0.4.1.tar.gz
.
File metadata
- Download URL: validictory-0.4.1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f75145505e5b8443ab79d202590f294cddad3f0fd9d1d44bfcd616e6d88ae166 |
|
MD5 | 2a4d1be48dc0e31d80fd686cd07eed2a |
|
BLAKE2b-256 | 75dc4f564c1b87e6012d389a2d420d39a3e94e1baccc2ad9d4cff85f00b6b441 |