Having developed Node and Edge/ Dynamic connector masters shapes for creating Node and Edge table entries for a SQL Server 2017, I decided that I should write some validation rules. The validation feature has been in Visio since the 2010 edition, but is underused, even though I wrote a book about them … see Microsoft Visio 2013 Business Process Diagramming and Validation . I think that only six rules are necessary to validate that a page with Node and Edge shapes is well constructed before attempting to update the tables in SQL Server, or any other GraphDatabase.
In the above screenshots, I have presented an issue for each rule. The panel on the right Follow the link earlier to read more.
Most of these rules are possible because I ensured that the Node shapes have the category “GraphNode“, and the Edge shapes have the category “GraphEdge“. This allows for testing of the relevant shapes using the HASCATEGORY() function. Some rules are for checking that shapes are correctly connected – basically a Node shape must be connected to another Node shape (or itself) with an Edge shape. The other rules are checking that required Shape Data row values have been entered.
That’s it, so why are Visio validation rules not being used more?
Here are the rules in full:
ID | 1 |
NameU | UngluedConnector |
Category | Connectivity |
Description | Edge connector shape is not glued to a Node shape at each end. |
RuleTarget | Shape |
RuleFilter | HASCATEGORY(“GraphEdge”) |
RuleTest | AGGCOUNT(FILTERSET(GLUEDSHAPES(3), “HASCATEGORY(“”GraphNode””)”))=2 |
ID | 2 |
NameU | TooFewConns |
Category | Connectivity |
Description | Each Node shape should have at least one Edge shape connection. |
RuleTarget | Shape |
RuleFilter | HASCATEGORY(“GraphNode”) |
RuleTest | NOT(AGGCOUNT(FILTERSET(GLUEDSHAPES(1), “HASCATEGORY(“”GraphEdge””)”))+ AGGCOUNT(FILTERSET(GLUEDSHAPES(2), “HASCATEGORY(“”GraphEdge””)”))) = 0 |
ID | 3 |
NameU | NoNodeValue |
Category | Data |
Description | Each Node shape should have a Node value |
RuleTarget | Shape |
RuleFilter | HASCATEGORY(“GraphNode”) |
RuleTest | AND(NOT(STRSAME(Prop.Node, “”)), NOT(STRSAME(Prop.Node, “<node>”))) |
ID | 4 |
NameU | NoEdgeValue |
Category | Data |
Description | Each Edge shape should have an Edge value |
RuleTarget | Shape |
RuleFilter | HASCATEGORY(“GraphEdge”) |
RuleTest | AND(NOT(STRSAME(Prop.Edge, “”)), NOT(STRSAME(Prop.Edge, “<edge>”))) |
ID | 5 |
NameU | NoNameValue |
Category | Data |
Description | Each Node shape should have a Name value |
RuleTarget | Shape |
RuleFilter | HASCATEGORY(“GraphNode”) |
RuleTest | AND(NOT(STRSAME(Prop.Name, “”)), NOT(STRSAME(Prop.Name, “<name>”))) |
ID | 6 |
NameU | BadNodeConnect |
Category | Connectivity |
Description | Node shapes must only be glued to Edge shapes |
RuleTarget | Shape |
RuleFilter | HASCATEGORY(“GraphNode”) |
RuleTest | AGGCOUNT(FILTERSET(GLUEDSHAPES(1), “NOT(HASCATEGORY(“”GraphEdge””))”))+ AGGCOUNT(FILTERSET(GLUEDSHAPES(2), “NOT(HASCATEGORY(“”GraphEdge””))”)) = 0 |
Useful links:
Introduction to Validation Rules in Visio Premium 2010
The Diagram Validation API
Dissecting the Process Flowchart Validation Rules
Writing rules to validate diagrams in Visio 2010 – A worked example
Other articles in this series:
Using #Visio and #PowerBI with #GraphDatabase in #SQLServer
Using #Visio and #PowerBI with #GraphDatabase in #SQLServer – Part 2
Using #JSON text in #Visio shapes
[…] Creating #Visio #Validation Rules for #GraphDatabase template […]