Home / Model Expert Homepage / Model Expert Help / Validation rules / Validation Scripting Examples
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
Validation Scripting Examples
Example Scripts
January 2025 – Scripts for Model expert validation have been deprecated.
Note: all scripts are examples only, and are supplied on an âas-isâ basis. You must check that they meet your requirements, and are functioning correctly.
Internal Use Case checks
This example script checks the details of a single use case.
!INC Local Scripts.EAConstants-VBScript
â â Script Name: Use_Case â Author: Ian Mitchell â Purpose: Checks the details of a single Use Case: â- are there any scenarios (severity 4) â- only a basic path scenario (3) â- checks if Internal Requirements are used: if so, severity = 3 â Date: 18/01/2016 â function Use_Case â************* Required so that eaDocX knows which element type / stereotype this is used for â<Type>UseCase</Type> âAll stereotypes â**************** â Parameters which are passed to the script are: â ElementID âfind the element dim e as EA.Element set e = Repository.GetElementByID(ElementID.toString) ânow do the checks dim outputHTML â a string which will contain the results from the script outputHTML = â<results>â âlook in more detail at the insides of the Use Case if e.Scenarios.count =0 then outputHTML = outputHTML & â<violation note=âMissing scenarios for use caseâ severity=â4â² />â end if
if e.Scenarios.count =1 then dim aScenario as EA.Scenario set aScenario = e.Scenarios.GetAt(0) if aScenario.Type = âBasic Pathâ then outputHTML = outputHTML & â<violation note=âOnly basic path scenarios for use caseâ severity=â3â² />â end if end if if e.Requirements.count > 0 then outputHTML = outputHTML & â<violation note=âUse Case has Internal Requirementsâ severity=â3â² />â end if outputHTML = outputHTML & â</results>â âput the HTML string into the return Use_Case = outputHTML end function Use_Case |
Connections of an Element
This example script checks that the right Dependency links exist, with one of 4 stereotypes â Responsible, Accountable, Consulted, Informed â <<High Level>> Requirements and Stakeholders.
!INC Local Scripts.EAConstantsâVBScript
â â Script Name: APITest â Author: Ian Mitchell â Purpose: Checks connections of a <<High Level>Requirement â Date: 16/12/2013 â functionÃÂ HighLevel_Requirement â************* Required so that eaDocX knows which element type / stereotype this is used for â<Type>Requirement</Type> â<Stereotype>High Level</Stereotype> â**************** â Parameters which are passed to the script are: â ElementID âfind the element dim e as EA.Element set e = Repository.GetElementByID(ElementID.toString) ânow do the checks dim outputHTML â a string which will contain the results from the script outputHTML = â<results>â
âcheck if it has RACI links âdeliberately no check for âInformedâ dim foundAccountable, foundResponsible, foundConsulted foundAccountable = false foundResponsible = false foundConsulted = false
dim c as EA.Connector for each c in e.connectors if c.Type = âDependencyâ and c.Stereotype = âAccountableâ then foundAccountable = true end if if c.Type = âDependencyâ and c.Stereotype = âResponsibleâ then foundResponsible = true end if if c.Type = âDependencyâ and c.Stereotype = âConsultedâ then foundConsulted = true end if
next
if not foundAccountable then outputHTML = outputHTML & â<violation note=âNo Accountable personâ severity=â5â² />â end if if not foundResponsible then outputHTML = outputHTML & â<violation note=âNo Responsible personâ severity=â5â² />â end if âif nobody is consulted, this isnât really an error, just something to think about if not foundConsulted then outputHTML = outputHTML & â<violation note=âNo Consulted personâ severity=â1â² />â end if âdeliberately no check for âInformedâ
outputHTML = outputHTML & â</results>â âput the HTML string into the return HighLevel_Requirement = outputHTML end function HighLevel_Requirement |
Checking <<Functional>> Requirements
This example script checks for two things:
- Do the notes for any <<Functional>>Requirement contains a specific word (âWibbleâ)
- Are there any <<Functional>>Requirements which have a status of âApprovedâ, and a phase of â2.0â
!INC Local Scripts.EAConstantsâVBScript
â â Script Name: Functional_Requirement â Author: Ian Mitchell â Purpose: Checks the details of a single functional Requirement â â Date: 22/06/2016 â functionÃÂ Functional_Requirement â************* Required so that eaDocX knows which element type / stereotype this is used for â<Type>Requirement</Type> â<Stereotype>Functional</Stereotype> âAll stereotypes â****************
â Parameters which are passed to the script are: â ElementID âfind the element dim e as EA.Element set e = Repository.GetElementByID(ElementID.toString)
ânow do the checks
dim outputHTML â a string which will contain the results from the script outputHTML = â<results>â
â1. Does the notes field contain the string âWibbleâ ? if instr(e.notes,âWibbleâ) <> 0 then outputHTML = outputHTML & â<violation note=âContains reference to Wibblesâàseverity=â3â² />â end if
â2. Are there any Phase 2.0 + âApprovedâ Requirements ? if e.phase = â2.0â then if e.Status = âApprovedâ then outputHTML = outputHTML & â<violation note=âApproved phase 2.0 requirement in 1.0 packageâ severity=â10â />â end if end if
outputHTML = outputHTML & â</results>â
âput the HTML string into the return Functional_Requirement = outputHTML end function ânot sure why this next line is needed, but it wonât work otherwise! Functional_Requirement |
Import / Export of Validation Scripts
Export
To export your Model Expert validation scripts (EA v15):
- EA Ribbon > Configure / Transfer / Export Reference data
- Select âAutomation Scriptsâ:
- Choose a file name
Import
To import Model Expert validation scripts:
- EA Ribbon > Configure / Transfer / Import Reference data
- Choose the file saved above
- Choose to import the Automation Scripts:
- Import.