Create links between only between specific nodes

How do i allow to create link only between some specific kind of nodes,
“START” and “CONDITIONAL” but not between “Step”/“End” and “CONDITIONAL” nodes in a flowchart, in a case like

This is fine


But this should not happen

You will need to define a linkValidation function, so that links may only be allowed between nodes of specific categories.

Read more here: GoJS Validation -- Northwoods Software

See the documentation on linkValidation functions here: LinkingBaseTool | GoJS API

I have read both the links and have tried this but it seems to not be working. The links start to stutter and more weirdly

function shouldConnect(e){
if((myDiagram.toolManager.linkingTool.temporaryLink.fromPort === “Step”)&&(myDiagram.toolManager.linkingTool.temporaryLink.toPort === “Conditional”)){

    return false;

else if((myDiagram.toolManager.linkingTool.temporaryLink.fromPort === “End”)&&(myDiagram.toolManager.linkingTool.temporaryLink.toPort === “Conditional”)){

    return false;

} }

myDiagram.toolManager.linkingTool.temporaryLink.linkValidation = shouldConnect;
myDiagram.toolManager.linkingTool.linkValidation = shouldConnect;

The first link includes a complete example which only allows linking nodes that are the same color.

The link validation predicate normally does not need to refer to any tool.

Got it.
Thank you Walter & Ryan