IFF
Synopsis
A conditional processor that evaluates a condition and assigns different values to a target field based on the result. The processor supports both scalar and array processing, allowing for element-wise conditional operations on arrays.
Schema
- iff:
target_field: <ident>
condition: <string>
when_true: <string>
when_false: <string>
is_array: <boolean>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
target_field | Y | - | Field to store the result |
condition | Y | - | Condition to evaluate (field name or expression) |
when_true | Y | - | Value to assign when condition is true |
when_false | Y | - | Value to assign when condition is false |
is_array | N | false | Force array processing mode |
description | N | - | Explanatory note |
if | N | - | Condition to run processor |
ignore_failure | N | false | Continue if processor fails |
ignore_missing | N | false | Continue if condition field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
The processor evaluates conditions in two ways: as field references or as expressions. When the condition parameter contains a simple field name, it retrieves the field value and evaluates its truthiness. When the condition contains operators (==, !=, <, >, in), it evaluates the expression directly.
The processor automatically detects array values and processes them element-wise unless explicitly configured otherwise.
For scalar processing, the processor evaluates the condition once and assigns either when_true or when_false to the target field. For array processing, it evaluates each array element and creates a result array with corresponding true/false values.
Values can be literal strings, field references, or template expressions using {{}} syntax. If a field reference fails, the processor treats the value as a literal string.
When processing arrays, mismatched array lengths between condition and value arrays may result in null values for missing elements.
Examples
Basic Conditional Assignment
Setting status based on score... | |
assigns the appropriate status: | |
Field Reference Condition
Using field truthiness... | |
evaluates field value directly: | |
Template Values
Using templates in assignments... | |
processes templates in values: | |
Array Processing
Processing arrays element-wise... | |
evaluates each array element: | |
Complex Expressions
Using complex conditions... | |
evaluates complex boolean logic: | |
Array Value Assignment
Using arrays as values... | |
assigns different values per element: | |