OpenQuizz
Une application de gestion des contenus pédagogiques
FormatChecker Class Reference
Inheritance diagram for FormatChecker:
Collaboration diagram for FormatChecker:

Public Member Functions

def __init__ (self, formats=None)
 
def __repr__ (self)
 
def checks (self, format, raises=())
 
def check (self, instance, format)
 
def conforms (self, instance, format)
 

Static Public Attributes

 checkers
 
 cls_checks
 

Detailed Description

A ``format`` property checker.

JSON Schema does not mandate that the ``format`` property actually do any
validation. If validation is desired however, instances of this class can
be hooked into validators to enable format validation.

`FormatChecker` objects always return ``True`` when asked about
formats that they do not know how to validate.

To check a custom format using a function that takes an instance and
returns a ``bool``, use the `FormatChecker.checks` or
`FormatChecker.cls_checks` decorators.

Arguments:

    formats (~collections.Iterable):

        The known formats to validate. This argument can be used to
        limit which formats will be used during validation.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  formats = None 
)

Member Function Documentation

◆ __repr__()

def __repr__ (   self)

◆ check()

def check (   self,
  instance,
  format 
)
Check whether the instance conforms to the given format.

Arguments:

    instance (*any primitive type*, i.e. str, number, bool):

The instance to check

    format (str):

The format that instance should conform to


Raises:

    FormatError: if the instance does not conform to ``format``

◆ checks()

def checks (   self,
  format,
  raises = () 
)
Register a decorated function as validating a new format.

Arguments:

    format (str):

The format that the decorated function will check.

    raises (Exception):

The exception(s) raised by the decorated function when an
invalid instance is found.

The exception object will be accessible as the
`jsonschema.exceptions.ValidationError.cause` attribute of the
resulting validation error.

◆ conforms()

def conforms (   self,
  instance,
  format 
)
Check whether the instance conforms to the given format.

Arguments:

    instance (*any primitive type*, i.e. str, number, bool):

The instance to check

    format (str):

The format that instance should conform to

Returns:

    bool: whether it conformed

Field Documentation

◆ checkers

checkers
static

◆ cls_checks

cls_checks
static

The documentation for this class was generated from the following file: