Skip to main content

Expression Transformation and Judgment (Filters)

In workflow expressions, the function to perform "transformation" and "judgment" on values ​​is provided as filters.

In general programming terms, it's similar to a function that takes input (value) and returns output (transformed value).

How to Read Filters (Pipe Notation)

The | (pipe) is used to apply filters from left to right.

{{ 'ABC' | to_lower | trim }}

This example means "convert 'ABC' to lowercase and remove leading and trailing whitespace."

Using filters, you can simply write a wide range of data transformations, such as string processing, date and time manipulation, path processing, and hashing.

Basic Filters

Filter NameDescriptionExample
sizeReturns the number of elements{{ [1,2,3] | size}}3
typeReturns the type name{{ 123 | type}}Int32

String Manipulation

Filter NameDescriptionExample
to_lower/to_upper/trimFormats strings{{ 'ABC' | to_lower}}abc
contains/starts_with/ends_withMatch detection{{ 'abc' | contains 'b'}}true
split/joinSplit and join{{ 'a|b|c' | split '|'}}[a,b,c]
regex_match/regex_replaceRegular expression operation{{ 'abc' | regex_replace 'a' 'z'}}zbc
to_base64/from_base64Base64 conversion{{ 'abc' | to_base64}}YWJj
url_encode/url_decodeURL Conversion{{ 'a b' | url_encode}}a%20b
sha256/md5Hashing{{ 'abc' | sha256}}

JSON/YAML

Filter NameDescriptionExample
to_json/from_jsonJSON Conversion{{ obj | to_json}}/{{ '{"a":1}' | from_json}}
to_yaml/from_yamlYAML Conversion{{ obj | to_yaml}}/{{ 'a: 1' | from_yaml}}

ignoreNulls option allows ignoring null values
Example: {{ obj | to_json { ignoreNulls: true } }}


Date and Time Manipulation

Filter NameDescriptionExample
now/utcnowGet Current Date and Time{{ now }}
add_days/add_hoursAdding Days{{ '2024-01-01' | add_days 1}}2024-01-02
format_dateDate Formatting{{ '2024-01-01' | format_date 'yyyy/MM/dd'}}2024/01/01

Collection Operations

Filter NameDescriptionExample
sort/reverseSort{{ [3,1,2] | sort}}[1,2,3]
unique/flattenDuplicate Removal/Flattening{{ [[1,2],[3]] | flatten}}[1,2,3]

Path Manipulation

Filter NameDescriptionExample
path_filename/path_basenameFilename Manipulation{{ '/a/b/file.txt' | path_filename}}file.txt
path_join/path_normalizePath Manipulation{{ ['a','b','c.txt'] | path_join}}a/b/c.txt
path_change_extensionChange extension{{ '/tmp/data.txt' | path_change_extension '.json'}}/tmp/data.json

Utilities

Filter NameDescriptionExample
uuidGenerate UUID{{ uuid }}550e8400-e29b-41d4-a716-446655440000
randomGenerate random number{{ random 1 10 }}7
default/coalesceDefault value processing{{ null | default 'x'}}x
is_null/is_emptyJudgment Filter{{ '' | is_empty}}true

Parameterized Filter Notation

{{ obj | to_json { ignoreNulls: true } }}

Example of Use

# Decode JSON string and extract items
{{ '{"a":1,"b":2}' | from_json | size }} → 2

# Change file extension from file path
{{ '/tmp/data.txt' | path_change_extension '.json' }} → '/tmp/data.json'

# Format the current date and time
{{ now | format_date 'yyyy-MM-dd HH:mm' }}