Skip to main content

Function: isValidStageId()

isValidStageId<W>(workflow, stageId): stageId is WorkflowStageId<W>

Defined in: packages/workflow-engine/src/core/stage-ids.ts:157

Validate that a stage ID exists in a workflow

Use this for runtime validation when the stage ID comes from user input.

Type Parameters​

W​

W extends Workflow<any, any, any>

Parameters​

workflow​

W

stageId​

string

Returns​

stageId is WorkflowStageId<W>

Example​

const stageId = request.params.stageId;

if (!isValidStageId(certificateWorkflow, stageId)) {
throw new Error(`Invalid stage ID: ${stageId}`);
}