Validation
The designer supports the validation of the definition. There are two types of validators: step and root. The step validator is called for each step and the root validator is called for the root of the definition (mainly for root properties). To add validation you need to provide your validators to the validator
property of your configuration.
const configuration = {
validator: {
// all validators are optional
step: (step: Step, parentSequence: Sequence, definition: Definition) => {
return /^[a-z]+$/.test(step.name);
},
root: (definition: Definition) => {
return definition.properties['memory'] > 256;
}
},
// ...
};
The designer will call validator functions every time the definition of the workflow is changed. This is a reason why you should avoid using heavy logic in your validators. The validation functions should return true
if the step or the root is valid, otherwise they should return false
.
You can get the result of the validation of the whole definition by calling isValid
method. If any step or the root is invalid, the method will return false
, otherwise it will return true
.
const designer = Designer.create(/* ... */);
designer.isValid();