diff --git a/packages/server/src/api/routes/utils/validators.ts b/packages/server/src/api/routes/utils/validators.ts index 9218223d08..d83569673f 100644 --- a/packages/server/src/api/routes/utils/validators.ts +++ b/packages/server/src/api/routes/utils/validators.ts @@ -298,8 +298,8 @@ const validateStepsArray = ( steps: AutomationStep[], helpers: Joi.CustomHelpers ) => { - for (let i = 0; i < steps.length - 1; i++) { - if (steps[i].stepId === AutomationActionStepId.BRANCH) { + for (const step of steps.slice(0, -1)) { + if (step.stepId === AutomationActionStepId.BRANCH) { return helpers.error("branchStepPosition") } }