Validation and behavior in case of problems#
izulu may trigger native Python exceptions on invalid data during validation process.
By default you should expect following ones
TypeError: argument constraints issuesValueError: template and formatting issues
Some exceptions are raised from original exception (e.g. template formatting issues),
so you can check e.__cause__ and traceback output for details.
The validation behavior depends on the set of enabled toggles. Changing toggle set may cause different and raw exceptions being raised. Read and understand “Toggles” section to predict and experiment with different situations and behaviours.
izulu has 2 validation stages:
class definition stage
validation is made during error class definition
# when you import error module from izulu import root # when you import error from module from izulu.root import Error # when you interactively define new error classes class MyError(Error): pass
class attributes
__template__and__toggles__are validatedclass MyError(Error): __template__ = "Hello {}" # ValueError: Field names can't be empty
runtime stage
validation is made during error instantiation
root.Error()
kwargsare validated according to enabled togglesclass MyError(Error): __template__ = "Hello {name}" name: str MyError() # TypeError: Missing arguments: 'name'