Creating validation suites and rules
See the procedures on this page for creating validation suites and rules.
Enabling and updating validation suites
- Once you have created a validation suite, make sure to enable it.
- If you modify a validation suite or rule, press F5 or click View > Refresh in the main toolbar to see the changes.
Creating validation suites and rules
Creating a validation suite
To create a validation suite
- In the Containment tree, create a new root namespace.
- Open the Textual Editor for the new namespace.
- In the Textual Editor, create a package and name it.
- Within the body of the package, declare a part definition, specify the name for the validation suite, subclassify DS_Validation::CoreValidationComponents::Suite, then, within the body of the definition:
- Click the Synchronize button.
package CustomValidationSuite { // the new validation suite's package
part def CustomValidationSuite :> DS_Validation::CoreValidationComponents::Suite { // naming the new validation suite and subclassifying the DS_Validation::CoreValidationComponents::Suite
}
}
Creating a validation rule
To create a validation rule
- Within the body of the part definition element of the new validation suite, declare a part usage, name it, then subset the templateRule element.
The templateRule is a reusable template for creating validation rules. It contains all the necessary validation rule components: severity, message, and condition. The template's severity level is set to error; to change it, see the Specify the validation rule severity procedure.
- Click the Synchronize button.
package CustomValidationSuite {
part def CustomValidationSuite :> DS_Validation::CoreValidationComponents::Suite {
part 'Validate Part Usage Type' :> templateRule { // naming a new validation rule and subsetting the templateRule
}
}
}
Specifying the validation rule severity
For more information on the validation rule severity level, see the Severity level section on the (2026x Refresh1) Reviewing validation results page.
To specify the validation rule severity
- Within the body of the part usage element of the new validation rule, declare an attribute usage, redefine severity, and then specify the needed severity level.
- Click the Synchronize button.
package CustomValidationSuite {
part def CustomValidationSuite :> DS_Validation::CoreValidationComponents::Suite {
part 'Validate Part Usage Type' :> templateRule {
attribute :>> severity = severity::warning; // specifying the validation rule's severity level as warning
}
}
}
Specifying the validation rule message
To specify the validation rule message
- Within the body of the part usage element of the new validation rule, declare a part usage and redefine the effect element.
- Within the body of the effect's part usage, declare an attribute usage, redefine the 'message' element (enclosed in single quotation marks), and specify the message text (enclosed in double quotation marks).
- Click the Synchronize button.
package CustomValidationSuite {
part def CustomValidationSuite :> DS_Validation::CoreValidationComponents::Suite {
part 'Validate Part Usage Type' :> templateRule {
attribute :>> severity = severity::warning;
part :>> effect { // specifying the validation rule's message
attribute :>> 'message' = "Part usage must be defined only by part definition.";
}
}
}
}
Specifying the validation rule condition
To specify the validation rule condition
- Within the body of the part usage element of the new validation rule, declare a part usage and redefine the condition element.
- Within the body of the condition's part usage, do the following:
- (Optional) Declare a ref item, redefine subjectType, and specify the element metaclasses the validation should check. Target metaclasses with metadata access expression.
- List multiple metaclasses by enclosing them in parentheses and separating them with commas, e.g., ref item :>> subjectType = (SysML::Systems::PartUsage.metadata, SysML::Systems::ActionUsage.metadata);
- If you do not specify the subjectType, the validation rule applies to all elements and should be narrowed down via the expression specification for the calculation (see the next step).
- Declare a calculation usage and redefine the test element. Within the calc's body, specify the expression for the validation rule's condition.
Use functions to construct the condition expression. See the (2026x Refresh1) Functions subpages containing predefined functions with examples and explanations.
- (Optional) Declare a ref item, redefine subjectType, and specify the element metaclasses the validation should check. Target metaclasses with metadata access expression.
- Click the Synchronize button.
package CustomValidationSuite {
part def CustomValidationSuite :> DS_Validation::CoreValidationComponents::Suite {
part 'Validate Part Usage Feature Typing' :> templateRule {
attribute :>> severity = severity::error;
part :>> effect {
attribute :>> 'message' = "Part usage must be defined only by part definition.";
}
// specifying a subjectType, then using a simpler expression in the calculation:
part :>> condition {
ref item :>> subjectType = SysML::Systems::PartUsage.metadata;
calc :>> test {
(element as KerML::Feature).type hastype SysML::Systems::PartDefinition
}
}
}
}
}
The first option uses the subjectType to narrow down evaluable elements to part usages. The calculation's expression:
(element as KerML::Feature).type hastype SysML::Systems::PartDefinition - targets the part usage's type (feature typing), then checks whether it is a part definition. If it is, the condition evaluates to true (validation passed); if it is not, the condition evaluates to false (validation failed). An element fails the validation rule if the condition expression evaluates to false.
package CustomValidationSuite {
part def CustomValidationSuite :> DS_Validation::CoreValidationComponents::Suite {
part 'Validate Part Usage Feature Typing' :> templateRule {
attribute :>> severity = severity::error;
part :>> effect {
attribute :>> 'message' = "Part usage must be defined only by part definition.";
}
// not specifying a subjectType and using a complete expression in the calculation:
part :>> condition {
calc :>> test {
not (element hastype SysML::Systems::PartUsage) or (element as KerML::Feature).type hastype SysML::Systems::PartDefinition
}
}
}
}
}
The second option discards subjectType and uses an expression to do the same:
not (element hastype SysML::Systems::PartUsage) - checks if an element is not a part usage. If the element is not a part usage, the condition evaluates to true (validation passed); if the element is a part usage, the condition evaluates to false (validation failed).
(element as KerML::Feature).type hastype SysML::Systems::PartDefinition - targets the part usage's type (feature typing), then checks whether it is a part definition. If it is, the condition evaluates to true (validation passed); if it is not, the condition evaluates to false (validation failed).
The or function checks both conditions; if either one of the conditions, or both, evaluates to true, then it returns true (validation passed). Thus, if only one of the conditions evaluates to false, the outcome is still true, meaning the validation rule is not failed and the element passes the validation. The element only fails the validation if it evaluates to false for both conditions.
For example, if the evaluated element is:
- a part usage that is defined by a part definition → first condition: (false) failed, second condition: (true) passed, outcome: validation passed.
- an action usage that is defined by an action definition → first condition: (true) passed, because the first condition passed, the second is not evaluated, outcome: validation passed.
- a part usage that is defined by an action definition → first condition: (false) failed, second condition: (false) failed, outcome: validation failed.