value builds one immutable named value from data the run already has, checks it against a
schema, and binds it. Nothing outside the run is contacted. Use it to reshape data, fill in a
default for a missing field, or build a string. When you need logic it can’t express, such as
arithmetic, comparisons or loops, use a pure ts function
through a call.
Syntax
value id=normalize-approval
id.
Fields
Leaf forms
There are no calls, comparisons, arithmetic or conditionals in a value node.
A template placeholder holds exactly one reference to a string, number or boolean. To keep a
value’s original type, write the reference on its own, unquoted, not inside a template.
Fallbacks
?? is the only operator. It works only in an unquoted YAML scalar inside value. Each operand is
a reference or a JSON scalar: a JSON string such as "", a number, true, false or null.
- Operands are tried left to right. The first one that is neither missing nor
nullwins.false,0and""are values and are never skipped. - Only the last member of a reference may be optional or nullable. Everything before it must be a
required, non-null object, so
??is not optional chaining. - The chain must always produce a value the schema accepts. End it with a required reference or a
non-null literal. A final
nullis allowed only when the schema field acceptsnull. - Put at least one space on each side of
??. A quoted scalar such as'$x ?? fallback'is a plain string.
Example
Build the fields of a nonpayment notice. The agent’s email is optional, so it falls back to an empty string:notice-letter.procedure.md
policyNumber: NW-100234, insuredName: Dana Reyes, amountDue: 412.5 and no
agentEmail, the procedure returns:
notice_letter, not letter, because a named value can’t reuse the
procedure’s output name.
On retry and resume
- No outside call. A value node runs nothing outside the run, so there is nothing to retry.
- Checked before it runs. Validation proves that every reference exists, every type fits and every fallback chain is total before the procedure can be published.
- Bound once. The run builds the whole value, checks it against
schema, and bindsoutputin the same recorded step that moves the run on. A resumed run never sees a partly built value. - Bounded. Building the value has fixed size, depth and compute limits. Hitting one fails the run; it is not a validation error.
Common errors
See also
completenode, which also builds a value but ends the runcallnode- Function and effect declarations
schemadeclaration