Skip to content

Value models

The platform's expression language. Where the schema description language describes which fields exist, value models describe computations over field values at run time. Validation rule conditions, inline-operation bodies, configuration mappings into method calls, resource estimations — all are value-model expressions.

A value model is not Kotlin code that runs at runtime. It's a typed expression tree that gets serialized to JSON when the component is built and re-evaluated by the platform against the user's data. Same expressions in development, in production, and across languages on the consumer side.

Where you write value models

Block Returns Built from
validationRuleSet { } ValidationRuleSet BooleanValue conditions, StringValue messages
nonInteractiveValidationRuleSet { } ValidationRuleSet same as validationRuleSet, evaluated by the workflow runner at run start
Inline operation(...) { } body Map<DataReference, Value> typed value models per output
Method-call lambda body mappings into method config typed value models per config field
resourceEstimation { } MethodResourceEstimationValueModel typed value models for CPU / memory

Value types

Every schema field has a corresponding value-model type:

Schema field Value type
boolean(...) BooleanValue
integer(...) IntegerValue
real(...) RealValue
string(...) StringValue
enum(...) EnumValue
length(...) etc. DimensionalScalarValue
dimensionalVector(...) DimensionalVectorValue
entityAssignment(...) EntityAssignmentValue
entityAssignmentList(...) EntityAssignmentListValue
any list ValueList<T>
compound (any record) CompoundValue (or a generated subclass)

Plus MeasurementUnitValue for the unit slot of a dimensional.

Lifting literals

asValueModel() wraps a Kotlin literal as a value model:

true.asValueModel()              // BooleanValue
42.asValueModel()                // IntegerValue
1.5.asValueModel()               // RealValue
"hello".asValueModel()           // StringValue
MyEnumType.A.asValueModel()      // EnumValue

Dimensional literals come from data-type-generated extensions — when the component depends on the length data type, you get 5.millimeter, 2.meter, 1000.kilometer directly:

val threshold = 1.millimeter         // DimensionalScalar (framework-side)
val thresholdModel = 1.millimeter.asValueModel()  // DimensionalScalarValue (model)

Most operators have overloads that take both the framework-side type and the value-model type, so you rarely need to call .asValueModel() explicitly.

Reading values

Inside a block where configValueModel is in scope (validation, inline op, method-call lambda), reading a field returns the value-model view:

configValueModel.edgeLength    // DimensionalScalarValue
configValueModel.maxIterations // IntegerValue
configValueModel.strategy      // EnumValue

The shape mirrors the configuration schema exactly — autocomplete in the editor walks compound nesting and lists.

For data type instances (e.g. inputs to a workflow), there's a .value accessor:

geometry.value.position    // DimensionalVectorValue (from a mock-geometry input)
geometry.value.size        // DimensionalVectorValue

The .value indirection separates the data reference (for runtime data plumbing) from the value-model view of its current contents.

Operators

Each value type has its own operator set. A summary:

Comparisons → BooleanValue (work on most pairs; cross-type via implicit conversion):

greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual
equal, notEqual

Arithmetic on IntegerValue, RealValue, DimensionalScalarValue, DimensionalVectorValue:

+ - * /  (rem on integers)
abs(x), min(a, b), max(a, b)
pow(x, n), sqrt(x), cbrt(x)
sin/cos/tan/asin/acos/atan/atan2
exp, log, log10

Boolean composition: and, or, xor, not, select(...).

String operators: + (concat), length(), startsWith, endsWith, contains, lowercase, uppercase, substring.

Enum operators: equal, notEqual, oneOf.

List operators: isEmpty, isNotEmpty, any { … }, all { … }, none { … }, map { … }, filter { … }, take(n), drop(n), first(), last(), get(i).

Cross-type conversions: to_string, to_integer, to_real, to_dimensional_scalar, etc. — usually implicit when an operator overload matches a more general type.

Working snippets

A condition for a validation rule:

condition = configValueModel.edgeLength greaterThan 1.millimeter

An inline operation that doubles a length:

mapOf(outputLength to (configValueModel.inputLength * 2.asValueModel()))

A message that splices the offending value:

message = "Edge length too small: ".asValueModel() + configValueModel.edgeLength

(StringValue + DimensionalScalarValue works because the framework has implicit to_string conversions.)

A compound field of a generated value model is typed with the concrete generated class, so a compound expression cannot be assigned to it directly. Every scalar compound field therefore comes with an <field>Expression accessor typed AbstractCompoundValue, which stores the expression under the same key:

configuration = {
    writeControlExpression = select(
        (writeControl isTypeOf "RUNTIME") to WriteControlValueModel.fromDefaults { … },
        (writeControl isTypeOf "NUMBER_TIME_STEPS") to WriteControlValueModel.fromDefaults { … },
    )
}

List fields need no accessor: ValueList is an interface and accepts select(...) as it is.

A select expression — pick a value depending on a boolean:

val approxCellSize = select(
    (configValueModel.refinement equal Refinement.HIGH.asValueModel())   to 0.5.millimeter.asValueModel(),
    (configValueModel.refinement equal Refinement.MEDIUM.asValueModel()) to 1.0.millimeter.asValueModel(),
    (configValueModel.refinement equal Refinement.LOW.asValueModel())    to 2.0.millimeter.asValueModel(),
)

Why "model" and not "expression"

Because at runtime the platform re-evaluates the same expression tree against the user's data. The expression isn't compiled in the conventional sense — it's serialized to JSON and interpreted. That's why everything in the surface is a typed data-class: IntegerComparisonGreaterThan(operandA, operandB) is a JSON object, not a Kotlin function call.

The "model" naming reinforces that: at build time you assemble a model of the computation, which the platform evaluates at run time.

Cross-references