|
OpenQuizz
Une application de gestion des contenus pédagogiques
|


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 | |
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.
| def __init__ | ( | self, | |
formats = None |
|||
| ) |
| def __repr__ | ( | self | ) |
| 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``
| 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.
| 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
|
static |
|
static |