Zebflow Docs
logic.if
Zebflow Docs

logic.if

Sends the payload down true or false by a condition

logic.if --when EXPR

Sends the payload down true or false by a condition. Evaluates --when (JavaScript over input, $trigger, $nodes) and sends the payload, unchanged, down the true pin or the false pin. This is how a pipeline validates, guards and answers 404/400: wire [b]:true -> [c] and [b]:false -> [e] in graph mode — in pipe mode only true continues and false ends the run silently. The pin not taken is skipped, and so is every node only it feeds ($nodes of a skipped node is null). The expression sees the payload as input (right after a webhook, input.webhook.body.x; anywhere, $trigger.body.x), not $input.

Flags

  • --when (required): JavaScript over input (and $trigger, $nodes): truthy routes to the true pin, falsy to false.

Examples

Guard a form field

| logic.if --when "typeof $trigger.body?.title === 'string' && $trigger.body.title.length > 0"

true carries the same payload on; wire false to a web.response.send --status 400.

Found or not found

| logic.if --when "input.query.rows.length > 0"

Fires the false pin; the payload is unchanged.

Input:

json
{  "query": {    "rows": []  }}