Return list of failures (if any) validating value against datatype.
value: Value to validate path: Used internally for location of failures.
>>> failures('int', 'foo')
['expected int, got str']
Return boolean representing validity of value against datatype.
The decorators module provides means for enforcing proper function return value datatypes.
Make decorators to watch return values of functions to ensure they match the given datatype definition.
>>> @returns('int')
... def myfunction():
... return "bad return value"
>>> myfunction()
Traceback (most recent call last):
BadReturnValueError
Validate output of iterator/generator function.
Note: exceptions for bad return datatypes will not be raised until the bad value of the iterator is consumed.
>>> @returns_iter('str')
... def myfunction():
... for x in range(3):
... yield "number %s" % x
>>> list(myfunction()) # no error
['number 0', 'number 1', 'number 2']