Skip to content

Validation rules

A validation rule set declares constraints on user-provided data: "the edge length must be between 1 mm and 100 mm," "exactly one boundary must be marked inlet," "the iteration count must be a positive integer." Rule conditions and messages are built from value models, so they're re-evaluated by the platform against actual user data — not interpreted at build time, evaluated at run time.

This page is the concept level: where rules attach, how they're shaped, the run-time semantics. For the exhaustive operator surface that conditions are built from, see reference: value-model catalogue; for the bound-check shortcuts, see reference: validation helpers.

Where rule sets attach

Component kind Block Validates
Workflow type validationRuleSet { … } the workflow's configuration, interactively while it is edited
Workflow type nonInteractiveValidationRuleSet { … } the workflow's configuration, in the workflow runner when a run is started
Method validationRuleSet { … } the method's configuration
Data type dataSchemaValidationRuleSet { … } instances of the data schema
Data type metadataSchemaValidationRuleSet { … } instances of the metadata schema

The block returns a ValidationRuleSet. Inside, the body sees the value-model view of the schema being validated: configValueModel, valueModel, or metadataValueModel depending on the kind.

Block Available value model
workflowType.validationRuleSet configValueModel
workflowType.nonInteractiveValidationRuleSet configValueModel
method.validationRuleSet configValueModel
dataType.dataSchemaValidationRuleSet valueModel
dataType.metadataSchemaValidationRuleSet metadataValueModel

A workflow-type configuration field declared as length("edgeLength") { ... } becomes configValueModel.edgeLength, statically typed as DimensionalScalarValue.

Interactive and non-interactive rules

A workflow type's configuration rules come in two blocks with the same builder scope, separated by when the platform evaluates them:

  • validationRuleSet { … } is interactive: the workflow repository evaluates it whenever the configuration is validated — as the user edits the workflow in Workbench, on simkit workflow validate, and once more when a run is created. Its rules must answer within an interactive round trip, so they read the configuration and the input data's metadata only.
  • nonInteractiveValidationRuleSet { … } is non-interactive: the workflow runner evaluates it when the run is started, in the run's VALIDATING state, before any operation is scheduled. Rules here may be expensive — value models that query the CAD session manager or other services can take minutes or longer — and they run inside the runner without launching a method. The CAD validation helpers are the ready-made blocks of this kind. A rule error fails the run with a workflow-runner-run-validation-failed error; warnings are recorded and the run proceeds to RUNNING. A workflow type without such rules skips the stage.

The split is deliberate: the developer decides per rule which class it belongs to, and Workbench knows which results to expect while editing and which to fetch from the run. Both blocks see configValueModel, and the non-interactive block additionally resolves the run's input data like an inline operation does (data values, metadata, entity mappings).

The result of a run's non-interactive validation is read from the run, not from the workflow version: simkit run validation <run-id>, or the runner's GET /workflow-runner/runs/{id}/validation endpoint. See how-to: read a validation result.

Per-input data validation rule sets

A workflow type can additionally constrain its input data, directly on the input in its dataInterface block: each input(...) can declare a validationRuleSet { … } interpreted over the metadata of the data assigned to that input. Every data-type dependency with a metadata schema generates a typed metadata value model property for the input block (geometryMetadata, named after the data type and rooted at the input's own name), so conditions and rule targets read like any other value expression — no hand-built reference paths:

dataInterface {
    input("geometry", "vendor.example:geometry:1.0.0") {
        validationRuleSet {
            rule(geometryMetadata.triangleCount, name = "Tessellation size check", code = "tessellation_size") {
                error(atMost = 1_000_000, message = "The geometry is tessellated into too many triangles")
            }
        }
    }
}

The block is the same builder scope as every other rule-set block — see reference: validation helpers.

Using another data type's metadata property on a mismatched input (say meshMetadata inside a geometry input) fails the build with an actionable message — the property checks the input's declared data type.

Data validation is part of the data interface — the workflow type's description — and deliberately not part of the configuration validationRuleSet, for two fundamental reasons:

  • Scope. The configuration rule set validates the workflow's configuration as a whole, over the value model generated from the workflow type's own configuration schema. A data validation rule set attaches to a single input and sees exactly one data's metadata, needing only the input data type's generated models — one conceptual layer earlier. That is why each input carries its own rule set, declared on the input itself.
  • Evaluation context. Because each rule set is self-contained per data, the platform can evaluate it without any workflow existing. That is what powers filtering on individual data: the registry answers both "which workflow types can take this data" and "which of these data fit this workflow type, and for which input" from these rule sets alone. The same rule sets are also evaluated when a workflow is validated.

A data is suitable for an input when the validation reports no error. This replaces the deprecated boolean dataTypeFilter property, which could only answer whether a data matches, not why it does not.

Anatomy

ValidationRuleSet
  └─ ValidationRule[]
       ├─ valueReference          // the field a UI highlights when a case fails
       └─ ValidationRuleCase[]
            ├─ condition: BooleanValue       // must hold; otherwise the case fails
            ├─ severityLevel: ERROR | WARNING
            ├─ message: StringValue          // re-evaluated; can splice in field values
            └─ details: Map<String, Value>   // optional structured payload

A case passes when its condition evaluates to true; only failing cases (false) emit a result. Cases are independent — one failing case does not "shadow" later cases of the same rule.

SeverityLevel has exactly two members: ERROR (blocks the user from proceeding) and WARNING (notifies but allows). No INFO.

A rule end-to-end

From a real workflow type — bounds the configured edge length between hard limits and warns when it's outside a preferred range:

validationRuleSet {
    ValidationRuleSet(
        listOf(
            ValidationRule(
                code        = "edge_length",
                name        = "Edge length check",
                description = "Edge length must be between 1 mm and 100 mm; preferred 5–50 mm.",
                valueReference = configValueModel.edgeLength.reference(),
                cases = listOf(
                    ValidationRuleCase(
                        code          = "too_small_error",
                        condition     = configValueModel.edgeLength greaterThan 1.millimeter,
                        severityLevel = SeverityLevel.ERROR,
                        message       = "Too small value: ".asValueModel() + configValueModel.edgeLength,
                    ),
                    ValidationRuleCase(
                        code          = "too_big_error",
                        condition     = configValueModel.edgeLength lessThan 100.millimeter,
                        severityLevel = SeverityLevel.ERROR,
                        message       = "Too big value: ".asValueModel() + configValueModel.edgeLength,
                    ),
                    ValidationRuleCase(
                        code          = "too_small_warning",
                        condition     = configValueModel.edgeLength greaterThan 5.millimeter,
                        severityLevel = SeverityLevel.WARNING,
                        message       = "Very small value: ".asValueModel() + configValueModel.edgeLength,
                    ),
                ),
            ),
        ),
    )
}

How to read the cases: the condition is the predicate that must remain true. > 1mm means "fail if not greater than 1 mm" — i.e. the user gave us 0.5 mm, the case fails, an ERROR is reported.

In a unified-DSL .kts, the same content goes inside the validationRuleSet { } block, which expects the body to return a ValidationRuleSet.

Bound-check shortcuts

For numeric ranges the framework ships pre-built case factories:

ValidationRule(
    code           = "iteration_count",
    name           = "Iteration count check",
    valueReference = configValueModel.maxIterations.reference(),
    cases = listOf(
        checkLowerBound(configValueModel.maxIterations, lowerBound = 1,    includeBound = true),
        checkUpperBound(configValueModel.maxIterations, upperBound = 1000, includeBound = true),
    ),
)

checkLowerBound / checkUpperBound default to SeverityLevel.ERROR and generate canonical messages. checkRange(lowerBound, upperBound, includeBound) is for the case where both bounds are themselves configuration values and you want to assert lower ≤ upper. Helpers are provided for IntegerValue, RealValue, DimensionalScalarValue.

Pick from a list: no validation rule needed

There's no "the value the user picked must be one of the offered list" rule to write. A field driven by an options binding stores a reference to the picked source-list element, so validity is referential integrity — does the referenced element still exist? — and the framework checks that automatically as part of configuration validation: a dangling reference is reported like a missing or unknown value. There is nothing to keep "in lockstep" between a dropdown and a validator.

Non-empty lists: no validation rule needed

Declare the requirement on the field itself — compoundList("presets") { nonEmpty = true }, cadSolidList("solids") { nonEmpty = true } — instead of writing a count rule. The schema then tells user interfaces statically that the field must be filled, and structural validation enforces it the way it enforces optional: a canonical empty_value error at the field's path. There is one declaration and nothing to keep in sync. Write a count rule only for finer cardinality or when the message must be yours.

Messages and details

message is a StringValue, not a String. It's re-evaluated at validation time, so you can splice in the offending value:

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

StringValue + StringValue concatenates; non-string types have implicit to_string conversions, so adding a DimensionalScalarValue to a string prefix works — it serializes to its unit-aware form ("5 mm") at evaluation time.

details: Map<String, Value> carries arbitrary structured data alongside the textual message; downstream processors (e.g. simkit web UI) read it without parsing the string.

When the field is missing or wrong-type

If the value at the rule's valueReference is missing or of the wrong type when the rule evaluates, the rule reports a single synthetic case (ValidationErrors.missingValue / ValidationErrors.invalidDataType) rather than running its own cases. You don't have to add explicit existence checks; the framework does that.

Output JSON

Validation rule sets are bundled into the component's JSON envelope (under the package field) and stored alongside the description in the registry. The platform consults them on every configuration write — failing cases produce results delivered back to the UI for the user to fix.

Each kind has its own slot in the envelope:

Component kind Validation rule set slot
Workflow type configurationSchemaValidationRuleSet
Method validationRuleSet
Data type dataSchemaValidationRuleSet
Data type metadataSchemaValidationRuleSet

For data types, both files are emitted whenever either block is non-empty; the unused side is ValidationRuleSet.EMPTY.

Cross-references