Home / Model Expert Homepage / Model Expert Help / Validation Script Examples / Validate a single element
Creating Reference Models
(13)
Import an MDG to create a Reference Model
Importing and exporting Reference Models
Editing RM Connector type properties
Stereotypes inheriting from other Element Types
Customizing Reference Model Properties
Customizing Reference Model Element Properties
Using Reference Models
(12)
Validate a single element
function UseCase() { // Parameters passed to the script: // Guid // Repository //*********** required so that Model Expert knows what kind of things is being validated. //* valid values are Element or Diagram //* <Validation>Element</Validation> //*********** Required so that Model Expert knows which element type / stereotype this is used for //* <Type>UseCase</Type> //* (applies to all stereotypes) // Find the element let e = Repository.GetElementByGuid(Guid.toString()); // Initialize outputHTML to hold the results from the script let outputHTML = ""; // Check the insides of the Use Case if (e.Scenarios &&Â e.Scenarios.Count === 0) { outputHTML += "<ElementViolation name='Missing scenarios for use case' severity='4' violatorID = '" + e.ElementID + "' subject='" + e.Name + "' />"; } if (e.Scenarios.Count === 1) { let aScenario = e.Scenarios.GetAt(0); if (aScenario.Type === "Basic Path") { outputHTML += "<ElementViolation name='Only basic path scenarios for use case' severity='3' violatorID = '" + e.ElementID + "' subject='" + e.Name + "'/>"; } } if (e.Requirements.Count > 0) { outputHTML += "<ElementViolation name='Use Case has Internal Requirements' severity='3' violatorID = '" + e.ElementID + "' subject='" + e.Name + "'/>"; } // Return the HTML string return outputHTML; } // Call the function result = UseCase();