Skip to main content
Version: 1.3.0

IFF

Logic Conditional

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:

FieldRequiredDefaultDescription
target_fieldY-Field to store the result
conditionY-Condition to evaluate (field name or expression)
when_trueY-Value to assign when condition is true
when_falseY-Value to assign when condition is false
is_arrayNfalseForce array processing mode
descriptionN-Explanatory note
ifN-Condition to run processor
ignore_failureNfalseContinue if processor fails
ignore_missingNfalseContinue if condition field doesn't exist
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-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.

note

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.

warning

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...

{
"score": 85
}
- iff:
target_field: status
condition: "score >= 70"
when_true: "pass"
when_false: "fail"

assigns the appropriate status:

{
"score": 85,
"status": "pass"
}

Field Reference Condition​

Using field truthiness...

{
"is_premium": true,
"username": "john_doe"
}
- iff:
target_field: access_level
condition: is_premium
when_true: "premium"
when_false: "basic"

evaluates field value directly:

{
"is_premium": true,
"username": "john_doe",
"access_level": "premium"
}

Template Values​

Using templates in assignments...

{
"user_id": 12345,
"is_admin": false
}
- iff:
target_field: greeting
condition: is_admin
when_true: "Welcome, Administrator!"
when_false: "Hello, User {{user_id}}"

processes templates in values:

{
"user_id": 12345,
"is_admin": false,
"greeting": "Hello, User 12345"
}

Array Processing​

Processing arrays element-wise...

{
"scores": [85, 92, 67, 78],
"threshold": 70
}
- iff:
target_field: results
condition: "scores >= threshold"
when_true: "PASS"
when_false: "FAIL"
is_array: true

evaluates each array element:

{
"scores": [85, 92, 67, 78],
"threshold": 70,
"results": ["PASS", "PASS", "FAIL", "PASS"]
}

Complex Expressions​

Using complex conditions...

{
"age": 25,
"country": "US",
"has_license": true
}
- iff:
target_field: can_rent_car
condition: "age >= 21 && country == 'US' && has_license"
when_true: "eligible"
when_false: "not_eligible"

evaluates complex boolean logic:

{
"age": 25,
"country": "US",
"has_license": true,
"can_rent_car": "eligible"
}

Array Value Assignment​

Using arrays as values...

{
"user_types": ["admin", "user", "guest"],
"permissions": ["read", "write", "delete"]
}
- iff:
target_field: access_rights
condition: "user_types == 'admin'"
when_true: permissions
when_false: "read"
is_array: true

assigns different values per element:

{
"user_types": ["admin", "user", "guest"],
"permissions": ["read", "write", "delete"],
"access_rights": ["read", "read", "read"]
}