evaluatesTo – Runtime Type of Expression Values
tSM forms allow values to be entered as SpEL expressions, typically using the syntax #{...}.
To keep the stored form data valid JSON and compatible with generic JSON Schema tooling, these expression values are stored as strings at design time.
The evaluatesTo property is used to explicitly describe the runtime type of the value after expression evaluation, separating:
- the storage / design-time type (usually
string) - from the runtime / API type produced by evaluating the expression
Purpose
evaluatesTo enables:
- correct runtime type validation after SpEL evaluation
- generation of clean, type-accurate API schemas
- use of expression-based form fields without weakening type guarantees
Usage
evaluatesTo is defined in the field configuration of a form schema:
{
"type": "string",
"config": {
"isExpression": true,
"evaluatesTo": {
"type": "object"
}
}
}
In this example:
- the value is stored as a
string(e.g."#{someExpression}") - the expression must evaluate to an object at runtime
Supported Runtime Types
evaluatesTo follows standard JSON Schema type definitions, for example:
stringnumberintegerbooleanobjectarraystringwithformat(e.g.date-time)
Example for an array:
{
"type": "string",
"config": {
"isExpression": true,
"evaluatesTo": {
"type": "array",
"items": { "type": "string" }
}
}
}
Runtime Behavior
At runtime:
- The stored value is read from the form data.
- If the value is marked as an expression, it is evaluated using SpEL.
- The evaluation result is validated against the
evaluatesTodefinition. - If the result does not match the expected type, a runtime error is raised.
API Schema Generation
When generating API or contract schemas:
- fields marked with
isExpression=trueuseevaluatesToas their effective type - the storage type (
string) is ignored - resulting schemas accurately reflect runtime data types without unions such as
string | object
Practical Example
Here is a complete form schema with an expression-based object field:
{
"type": "object",
"widget": {
"type": "dtl-fluent-section"
},
"properties": {
"objectParam": {
"type": "string",
"title": "Object Expression",
"widget": {
"type": "dtl-expression-editor"
},
"config": {
"isExpression": true,
"evaluatesTo": {
"type": "object"
}
}
}
},
"layout": [
"objectParam"
]
}
In this example:
- The field
objectParamaccepts a SpEL expression as input (stored as a string) - The
isExpression: trueflag marks it for evaluation - The
evaluatesToproperty declares that the expression must evaluate to an object at runtime - During form processing, the expression is evaluated and validated against this type constraint
- The generated API schema will reflect this field as an
objecttype, not astring
Summary
evaluatesTo allows tSM to safely combine:
- expression-based configuration
- strict runtime typing
- valid JSON storage
- clean API contracts
by explicitly declaring the expected runtime type of expression values.