added security check to avoid errors on building empty flows

This commit is contained in:
anovazzi1 2023-06-12 20:26:56 -03:00
commit a41cc95abb

View file

@ -744,6 +744,9 @@ export function validateNode(n: NodeType, reactFlowInstance:ReactFlowInstance):A
}
export function validateNodes(reactFlowInstance:ReactFlowInstance){
if(reactFlowInstance.getNodes().length === 0){
return ["No nodes found in the flow. Please add at least one node to the flow."];
}
return reactFlowInstance
.getNodes()
.flatMap((n: NodeType) => validateNode(n, reactFlowInstance));