pub fn ensure_status(
tx: &TransactionRepoModel,
expected: TransactionStatus,
operation: Option<&str>,
) -> Result<(), TransactionError>Expand description
Validates that a transaction is in the expected state.
This enforces state machine invariants and prevents invalid state transitions. Used for domain-level validation to ensure business rules are always enforced.
§Arguments
tx- The transaction to validateexpected- The expected statusoperation- Optional operation name for better error messages (e.g., “prepare_transaction”)
§Returns
Ok(()) if the status matches, Err(TransactionError) otherwise