# custom type checker for decimals def is_decimal(v): return isinstance(v, Decimal)
# add at the bottom of a file you want to auto-validate autovalidate( module="my_project.my_module", type_checkers={Decimal: is_decimal}, # custom checkers raise_exceptions=True, # raise on failure enforce_hints=False, # require type hints on all functions # decorator=my_custom_decorator, # optional: use your own decorator )
You can also use the autovalidate_package function to automatically validate the entire package. The decorator parameter enables you to swap the inbuilt decorator with one from another library or your own.If enforce_hints is set, exceptions will be raised once untyped functions are detected
pip install validatedata validatedata 0.6.1