Skip to main contentElyra

Canvas components

Common canvas displays a flow of data operations as nodes and links which the user can create and edit to get the flow they want. These visual flows of data operations are translated into data processing steps performed by a back-end server.

To use the Flow Validation API import the FlowValidation object fro common-canvas: import { FlowValidation } from "@elyra/canvas";

Then call the API on the object, for example: FlowValidation.validateFlow( ... );

The Flow Validation object provides the following API:

validateFlow(canvasController, parameterDataCallback, setNodeMessagesCallback, includeMsgTypes)
canvasController - an instance of the canvas controller
parameterDataCallback – function to get the parameter data or form data for a node
setNodeMessagesCallback – function to set the validation messages for a node. (optional)
includeMsgTypes - array[strings] Return invalid only if messages are found of types contained
in the array. If not specified then any message type causes invalid return. (optional)
return - boolean If flow is valid returns true, otherwise returns false.
```

The validateFlow() API will traverse the current flow and for each node invoke the parameterDataCallback() to get with a form data JSON or a parameterDef JSON. It will validate the JSON for the node and store any messages in the node objects within the model. The setNodeMessagesCallback() function will be called with all the messages generated for the node. This is only useful if the application is not using the internal object model. The format of the message object is described in Pipeline Flow UI schema.

Here is an example of using the FlowValidation API to validate a flow on opening:

getNodeForm(nodeId) {
const parameterDef = getParameterDefJSON(nodeId);
return { type: "parameterDef", data: parameterDef };
}
setNodeMessages(nodeId, messages) {
// code to persist messages in a store in addition to the internal model.
}