Skip to main content
Version: 0.6.0

Primitive Value Types

Primitive value types are based on built-in value types and use a collection of constraints to restrict the range of valid values. Such constraints are implicitly connected via a logical AND relation. Note that the constraints need to be applicable to the base-type of the value type - indicated by the identifier after the keyword oftype:

valuetype GasFillLevel oftype integer {
constraints: [ GasFillLevelRange ];
}

Constraints

Constraints for value types declare the validity criteria that each concrete value is checked against.

Syntax 1: Expression syntax

The syntax of expression-based constraints uses an expression that evaluates to true or false for the given value. The type of the values the expression is working in is indicated ofter the keyword on:

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

Refer to the expression documentation for further reading on expressions.

Syntax 2: Block-like syntax

The syntax of constraints is similar to the syntax of blocks. The availability of property keys and their respective value types is determined by the type of the constraint - indicated by the identifier after the keyword oftype:

constraint GasFillLevelRange oftype RangeConstraint {
lowerBound: 0;
lowerBoundInclusive: true;
upperBound: 100;
upperBoundInclusive: true;
}

Note that the type of constraint also determines its applicability to value types. For instance, a RangeConstraint can only be applied to the numerical types integer and decimal.