Skip to content

Guards Syntax

Syntax patterns for conditional logic.

Single Guard

flow
? condition
  // runs if true

Multiple Guards (AND)

flow
? condition1
? condition2
  // runs if BOTH true

OR Guards

flow
? condition1
?? condition2
  // runs if EITHER true

Combined Logic

flow
? conditionA
? conditionB
?? conditionC
  // runs if (A AND B) OR C

Default Case

flow
? condition1
  handle 1
? condition2
  handle 2
otherwise
  handle default

Or:

flow
? condition
  handle condition
?
  handle else

Nested Guards

flow
? outer condition
  ? inner condition
    // nested action
  otherwise
    // inner else
otherwise
  // outer else

Guard Patterns

State Checks

flow
? order is in #pending
? order is not in #cancelled

Context Comparisons

flow
? $total equals 100
? $total is 100
? $total is greater than 0
? $total is less than 1000
? $items contains "Laptop"
? $items is empty
? $items is not empty

Assertion Patterns

flow
expect:
  // State assertions
  = order is in #paid
  = order is not in #cancelled

  // Context assertions
  = $total equals 1200
  = $items contains "Laptop"
  = $count is greater than 0

  // Event assertions
  = @customer received :confirmation
  = :payment_request was emitted to @payment

Released under the MIT License.