Table of Contents

Class WorkflowExpression

Namespace
LMKit.Agents.Workflows
Assembly
LM-Kit.NET.dll

The small, side-effect-free expression language of workflows: conditions (when, until) and the {{ ... }} placeholders of templates. It reads the workflow's values and computes nothing else: no assignment, no I/O, no code.

public static class WorkflowExpression
Inheritance
WorkflowExpression
Inherited Members

Remarks

Values: input (the workflow's input), steps.<id>.output (or steps.<id>), steps.<id>.error (why a step failed for good, read by its error steps), a field of a JSON input or answer as input.<field> or steps.<id>.output.<field> (dotted, array items by index; missing reads as null), vars.<name> (values the host passes), item and item.<field> (the item a foreach step runs its steps on), loop.iteration (the innermost loop's pass, from 1), string literals in single or double quotes, numbers, true, false, null.

Operators: ==, !=, <, >, <=, >=, and, or, not, parentheses. Two values compare as numbers when both read as numbers, otherwise as text (case-sensitive).

Functions: contains(a, b), startsWith(a, b), endsWith(a, b) (case-insensitive), lower(a), upper(a), trim(a), length(a), empty(a), number(a), matches(a, pattern) (regular expression, bounded time), json(a, 'path.to.field'), which reads a field of a JSON answer, and coalesce(a, b), which is a unless it is null or empty, then b.

A value is true when it is true, a non-zero number, or a non-empty text other than false.

Fields

ItemVariable

The variable name under which a scope answers the current foreach item (as JSON); a host variable cannot carry it, since its name is not one a host can pass.

Methods

Evaluate(string, IWorkflowScope)

Evaluates an expression over scope.

IsTrue(string, IWorkflowScope)

Evaluates a condition over scope.

Render(string, IWorkflowScope)

Renders a template: every {{ expression }} is replaced by its value as text; the rest is kept as written.

StepReferences(string, bool)

The step ids an expression or template reads (steps.<id>).

Text(object)

A value as text: a number in invariant form, true or false, null as empty.

Truthy(object)

Whether a value counts as true.

Validate(string)

Why an expression cannot be read, or null when it can.

ValidateTemplate(string)

Why a template cannot be rendered, or null when it can.

Share