contract library

Classes

Invariant
Provides checks for object invariants, preconditions, and postconditions.

Enums

ContractCheckingMode
Selects how contract violations are handled.
ViolationKind
Identifies which part of a contract was violated.

Functions

runWithChecking<R>({required bool preCondition(), required R operation(), required bool postCondition(R result), ContractCheckingMode checkingMode = .assertionsOnly}) → R
Runs operation after checking preCondition and checks its result.
runWithCheckingAsync<R>({required bool preCondition(), required Future<R> operation(), required bool postCondition(R result), ContractCheckingMode checkingMode = .assertionsOnly}) → Future<R>
Runs operation after checking preCondition and checks its result.

Exceptions / Errors

ContractViolationError
An error raised when a contract check fails in ContractCheckingMode.alwaysThrow.