macro_rules! require {
($condition:expr, $message:expr $(,)?) => { ... };
($condition:expr, $format:expr, $($arg:expr),+ $(,)?) => { ... };
}Expand description
Validates a business rule condition and returns early with
CommandError::BusinessRuleViolation when the condition is false.
Designed for command handlers (or any function returning
Result<_, CommandError>) so domain invariants stay close to the logic
without verbose boilerplate.
ยงExamples
With a literal message:
require!(balance >= amount, "Insufficient funds");With a formatted message:
require!(
balance >= amount,
"Insufficient: have {}, need {}",
balance,
amount,
);