Home / Model Expert Homepage / Model Expert Help / Validation Script Examples / Validate names of elements
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 names of elements
function BPMNActivity() { // Parameters passed to the script: // Guid - may be the guid of a diagram or element // Repository //Script to check the name of a BMPN Activity against an allowed list //*********** 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>Activity</Type> 'space is required here //* <Stereotype>Activity</Stereotype> //* (applies to all stereotypes of Use Case diagram) // Find the element let e = Repository.GetElementByGuid(Guid.toString()); // Initialize outputHTML to hold the results from the script let outputHTML = ""; let processName = e.Name; if (!isValidProcessName(processName)) { outputHTML += "<ElementViolation name='Activity verb is not in allowed list' severity='4' violatorID = '" + e.ElementID + "' notes='" + e.Name + "' />"; }; // Another check is to make sure all Activities are inside a Lane if (e.ParentID == 0) { outputHTML += "<ElementViolation name='Activity has no parent Lane' severity='5' violatorID = '" + e.ElementID + "' notes='" + e.Name + "' />"; }; // Return the HTML string return outputHTML; } //* Example of how to implement a naming convention // A variation on this would be to pull all these names from some EA elements. function isValidProcessName(processName) { const approvedVerbs = [ "Approve", "Assign", "Authorize", "Calculate", "Cancel", "Capture", "Classify", "Close", "Collect", "Complete", "Confirm", "Create", "Decline", "Determine", "Disburse", "Document", "Escalate", "Evaluate", "File", "Generate", "Initiate", "Investigate", "Issue", "Notify", "Process", "Receive", "Reject", "Request", "Resolve", "Validate" ]; if (!processName || typeof processName !== "string") { return false; } const firstWord = processName.split(" ")[0]; return approvedVerbs.includes(firstWord); } // Call the function result = BPMNActivity();