Home / Model Expert Homepage / Model Expert Help / Validation Script Examples / Validate a diagram
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 diagram
function BPMNProcess() { // Parameters passed to the script: // Guid - may be the guid of a diagram or element // Repository //Script to validate a BPMN Activity diagram. //This implements rules which can not be checked using a Model Expert Reference Model. //It can used instead of, or as well as, a Reference Model, which can check the simple stuff //*********** Required so that Model Expert knows what kind of things is being validated. //* valid values are Element or Diagram //* <Validation>Diagram</Validation> //*********** Required so that Model Expert knows which element type/stereotype this is used for //* <Type>Business Process</Type> 'space is required here // Find the diagram let d = Repository.GetDiagramByGuid(Guid.toString()) // Initialize outputHTML to hold the results from the script let outputHTML = ""; // Check the contents of the diagram //* Rule 1 - diagram must have at least two Lanes let numberOfLanes = 0; if (d && d.DiagramObjects.Count > 0) { for (let i = 0; i < d.DiagramObjects.Count; i++) { let dObj = d.DiagramObjects.GetAt(i); // Get the element let e = Repository.GetElementByID(dObj.ElementID); if (e && e.MetaType === "BPMN2.0::Lane") { numberOfLanes = numberOfLanes + 1; } } } // Add violations if (numberOfLanes < 2 ) { outputHTML += "<DiagramViolation name='Diagram must have at least 2 Lanes' severity='7' diagramID = '" + d.DiagramID + "' subject='" + d.Name +Â "' />"; } // Return the HTML string return outputHTML; } // Call the function result = BPMNProcess();