hyperion.ng
Classes | Functions | Variables
jsonschema Namespace Reference

Classes

class  Draft3Validator
 
class  ErrorTree
 
class  RefResolutionError
 
class  RefResolver
 
class  SchemaError
 
class  UnknownType
 
class  ValidationError
 

Functions

def validates (version)
 
def validate (instance, schema, cls=Draft3Validator, args, kwargs)
 

Variables

int PY3 = 3
 
 basestring = str
 
 iteritems = operator.methodcaller("items")
 
int FLOAT_TOLERANCE = 10 ** -15
 
dictionary validators = {}
 

Detailed Description

An implementation of JSON Schema for Python

The main functionality is provided by the validator classes for each of the
supported JSON Schema versions.

Most commonly, :func:`validate` is the quickest way to simply validate a given
instance under a schema, and will create a validator for you.

Function Documentation

§ validate()

def jsonschema.validate (   instance,
  schema,
  cls = Draft3Validator,
  args,
  kwargs 
)
Validate an ``instance`` under the given ``schema``.

    >>> validate([2, 3, 4], {"maxItems" : 2})
    Traceback (most recent call last):
        ...
    ValidationError: [2, 3, 4] is too long

:func:`validate` will first verify that the provided schema is itself
valid, since not doing so can lead to less obvious error messages and fail
in less obvious or consistent ways. If you know you have a valid schema
already or don't care, you might prefer using the ``validate`` method
directly on a specific validator (e.g. :meth:`Draft3Validator.validate`).

``cls`` is a validator class that will be used to validate the instance.
By default this is a draft 3 validator.  Any other provided positional and
keyword arguments will be provided to this class when constructing a
validator.

:raises:
    :exc:`ValidationError` if the instance is invalid

    :exc:`SchemaError` if the schema itself is invalid

§ validates()

def jsonschema.validates (   version)
Register the decorated validator for a ``version`` of the specification.

Registered validators and their meta schemas will be considered when
parsing ``$schema`` properties' URIs.

:argument str version: an identifier to use as the version's name
:returns: a class decorator to decorate the validator with the version