Skip to content

Correctness

Keep bad data out and keep objects consistent when something goes wrong halfway.

  • Validation


    validate_args, check_type and enforce_types: reject bad input with an error that names the parameter.

  • State safety


    revert_on_failure, Transaction and transactional: undo changes when a call fails.

Which one?

You want to Use
Check a business rule (amount > 0, not empty) validate_args
Check that an argument is an int or str check_type
Make your type hints true at runtime enforce_types
Restore an object's attributes if a method fails revert_on_failure
Undo side effects (files, payments) when a step fails transactional

See also