Context Keywords
Keywords for working with context variables and state.
Assignment
becomes
Sets a context value.
flow
$total becomes 100
$status becomes "active"is
Used in given: to set initial values.
flow
given:
$total: number is 100
order is in #pendingArithmetic Operations
increases by
Adds to a numeric value.
flow
$total increases by 25
$retry_count increases by 1decreases by
Subtracts from a numeric value.
flow
$balance decreases by $amount
$stock decreases by $quantityCollection Operations
adds
Adds an item to a collection.
flow
$items adds "Laptop"
$tags adds "priority"removes
Removes an item from a collection.
flow
$items removes "Mouse"
$tags removes "draft"clears
Empties a collection.
flow
$items clears
$cart clearsState Keywords
State Transition Verbs
All equivalent:
moves totransitions toentersbecomeschanges to
flow
order moves to #paid
order transitions to #approved
payment enters #processing
ticket becomes #closedis in / is not in
Checks current state.
flow
? order is in #pending
process order
? order is not in #cancelled
allow modificationContext Validation
Post-Action Validation Table
Defines constraints for context variables after actions. The table follows the action(s).
Single variable:
flow
$retry_count increases by 1
| $retry_count | required, integer, between 0 and 5 |Multiple variables:
flow
$total increases by $item.price
$item_count increases by 1
| $total | required, number, greater than 0 |
| $item_count | required, integer |Validation Rules
Rules are comma-separated. Common rules:
| Rule | Description |
|---|---|
required | Must be present and not null |
optional | May be absent |
string, number, integer, boolean, array, object | Type rules |
greater than N, less than N, between N and M | Numeric rules |
at least N, at most N | Numeric bounds |
min N characters, max N characters | String length |
valid email, valid uuid, valid url | Format rules |
one of "a", "b" | Enum rule |
bail | Stop on first error |
See Data Validation for complete rule reference.
Constraint Violation
When a constraint is violated:
- The action is rolled back (value unchanged)
:constraint_violatedevent is emitted
flow
on :constraint_violated
? $field is "$retry_count"
emit :max_retries_exceeded to @customer