Skip to main content

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


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.tar.gz (8.2 kB view details)

Uploaded Source

File details

Details for the file validictory-0.4.tar.gz.

File metadata

  • Download URL: validictory-0.4.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for validictory-0.4.tar.gz
Algorithm Hash digest
SHA256 d6d25fe6b4272df80453f2516e1a626f556b1c10e14dc4b43bca10d370818856
MD5 740a4ee058eac883d10e0be2a40bbe46
BLAKE2b-256 63f1f9fccde074f93c7c67a3ee588415c4fbb87f68b3a588a0380f9cddf0d0af

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page