op: if

Conditional branch — nested ops must be valid for the current phase.

Allowed phases

PhaseStatus
preflight✓ allowed
core✓ allowed
side_effects✓ allowed

Syntax

- op: if
  expr: "entity.cart.total > 100"
  then:
    - op: set
      path: /discount_rate
      value: 10
  else:
    - op: set
      path: /discount_rate
      value: 0

Parameters

FieldRequiredDescription
expryesCondition expression string
thenyesOps when truthy
elsenoOps when falsy

Behavior

  • Nested ops inside then/else must respect phase constraints (e.g. no set inside preflight).
  • Rule when: { expr: "..." } uses an object wrapper; array where: on filter/remove/find does not.

for_each · reject · stop

See also