Skip to main content

Contains

Control Flow

Synopsis

Checks if a specified field value exists within a list of values, enabling conditional processing based on value matching. This is useful for filtering, routing, or validating data based on predefined or dynamic lists.

Schema

contains:
- field: <ident>
- description: <text>
- if: <script>
- ignore_failure: <boolean>
- ignore_missing: <boolean>
- list: <string[]>
- list_field: <ident>
- on_failure: <processor[]>
- on_success: <processor[]>
- tag: <string>

Configuration

FieldRequiredDefaultDescription
fieldY-Field containing the value to check
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseSee Handling Failures
ignore_missingNfalseIf true and field does not exist, exit quietly without making any modifications
listN-Static list of values to check against
list_fieldN-Field containing the dynamic list of values to check against
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-Identifier

Details

The list can be provided directly or referenced from another field.

warning

Either list or list_field must be specified, but not both, and the field being checked must contain a string value. The processor will fail if neither list nor list_field is provided, or if the specified field contains a non-string value.

Examples

Static List

Check if a value exists in a static list...

{
"status": "active"
}
contains:
- field: status
- list: ["active", "pending", "completed"]

returns success because "active" is in the list

Dynamic List

Check against a list stored in another field...

{
"user_type": "admin",
"allowed_types": ["user", "moderator", "admin"]
}
contains:
- field: user_type
- list_field: allowed_types

returns success because "admin" is in allowed_types

Missing Fields

When the field is missing and ignore_missing is true...

{
"other_field": "value"
}
contains:
- field: status
- list: ["active", "pending"]
- ignore_missing: true

processor exits quietly without modification

Templates

List values can use template syntax...

{
"org_id": "123",
"role": "role_123_admin"
}
contains:
- field: role
- list: ["role_{{{org_id}}}_admin", "role_{{{org_id}}}_user"]

templates are evaluated before checking