Constraint Rules
Last modified: 11 November 2022The Constraints Language suffers from several deficiencies, like the inability to specify error messages for individual constraints or the inability to define multiple separate rules for the same kind of constraint. The experimental Constraint Rules language attempts to overcome those. It is available in the Constraints aspect under the RulesConstraintsRules root:

Can be child/parent/ancestor/root rules
The RulesConstraintsRules root chooses a minimalistic visual guidance:

CanBeAncestor
CanBeChild
CanBeParent
CanBeRoot


Variable definition - a reusable pre-calculated value that can be used in rules
Rule definition - a logical expression to evaluate as a constraint, with optional name for easy reference (e.g. from tests), an optional error message and an optional Applicability guard expression.

Implicit parameters of rules blocks
Each Rules block receive parameters that capture the context for evaluation in rules. These are available in the completion menu:


CanBeRoot - concept, model
CanBeChild - childNode, parentNode, link
CanBeParent - childNode, parentNode, link, childConcept
CanBeAncestor - ancestorNode, parentNode, descendantNode, descendantConcept, link
Tracing constraint rules evaluation
The constraint rules definitions allow logging messages to be specified in the Inspector window for better tracing:

Specify the feature to highlight
The error message for a constraint rule can be targeted for specific node’s properties or references.




