Skip to main content
Version: Next

Primitive Value Types

Primitive value types are comprised of properties.

valuetype GasFillLevel {
property level oftype integer;
}

A property is a named "part" with its own value type (type cycles are forbidden). Value types with multiple properties are allowed in the language, but not yet supported by the interpreter.

Constraints

Constraints restrict the range of valid values.

valuetype GasFillLevel {
property level oftype integer;
constraint levelRange: level >= 0 and level <= 100;
}

A value type can have zero or more constraints, which are implicitly connected via a logical AND operation.

Constraints use an expression that evaluates to true or false and can reference every property of the value type.

In the above example, level >= 0 and level <= 100 is evaluated for each value of type GasFillLevel. level serves as a variable here for the concrete value. For example, for the value 10, the expression would evaluate to true, while it would evaluate to false for value -1.

Refer to the expression documentation for further reading on expressions.

Outline definition.

Constraints can also be defined outside of value types, allowing them to be reused.

valuetype GasFillLevel {
property level oftype integer;
constraint levelRange: GasFillLevelRange on level;
}

constraint GasFillLevelRange on decimal:
value >= 0 and value <= 100;

Since there are no properties to reference from the constraint definition, the special value keyword represents the tested value. Note that reusable constraints need to be applied to exactly one property of the value type - indicated by the identifier after the keyword on.