Expressions
Expressions are how you pass data between resources, validate inputs, and run conditional logic. They are powered by expr-lang.
Where expressions are used
String interpolation -- embed an expression inside any string field using {{ }}:
yaml
# resources/example.yaml
chat:
prompt: "Hello {{ get('name') }}, today is {{ info('timestamp') }}"before:/after: blocks -- a list of statements executed sequentially. Each statement is a bare expression, not wrapped in {{ }}:
yaml
# resources/example.yaml
after:
- set('normalized', lower(trim(get('q')))) # stores a value
- set('is_admin', get('role') == 'admin') # boolean
- set('total', get('price') * get('quantity'))validations.skip / validations.check / onError.when -- a list of boolean expressions; any one true is enough:
yaml
# resources/example.yaml
validations:
skip:
- get('q') == '' # bare expression, evaluated as bool
check:
- len(get('password')) >= 8Standard library
Expressions have access to the full expr-lang standard library:
- String:
trim(),lower(),upper(),split(),replace(),join() - Math:
min(),max(),abs(),ceil(),floor() - List:
len(),filter(),map(),first(),last() - String matching (infix operators):
contains,startsWith,endsWith,matches - Type casting:
int(),float(),string()
kdeps adds workflow-specific helpers on top. See the Expression Functions Reference for the full list.
See Also
- Expression Functions Reference - All kdeps-specific functions
- Expression Operators - Comparison and logic operators
- Expression Blocks -
before:/after:statement blocks
