From d37c3ab99f56d964212f960eb67ffa61cadd667d Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 31 Oct 2024 11:43:15 +0000 Subject: [PATCH] remove validation for empty conditions --- .../src/api/routes/tests/automation.spec.ts | 24 ------------------- .../server/src/api/routes/utils/validators.ts | 4 ++-- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/packages/server/src/api/routes/tests/automation.spec.ts b/packages/server/src/api/routes/tests/automation.spec.ts index a517346c82d..2b017274022 100644 --- a/packages/server/src/api/routes/tests/automation.spec.ts +++ b/packages/server/src/api/routes/tests/automation.spec.ts @@ -173,30 +173,6 @@ describe("/automations", () => { }) }) - it("Should check validation on a branch step with empty conditions", async () => { - const automation = createAutomationBuilder({ - name: "String Equality Branching", - appId: config.getAppId(), - }) - .appAction({ fields: { status: "active" } }) - .branch({ - activeBranch: { - steps: stepBuilder => - stepBuilder.serverLog({ text: "Active user" }), - condition: {}, - }, - }) - .build() - - await config.api.automation.post(automation, { - status: 400, - body: { - message: - 'Invalid body - "definition.steps[0].inputs.branches[0].condition" must have at least 1 key', - }, - }) - }) - it("Should check validation on an branch that has a condition that is not valid", async () => { const automation = createAutomationBuilder({ name: "String Equality Branching", diff --git a/packages/server/src/api/routes/utils/validators.ts b/packages/server/src/api/routes/utils/validators.ts index 0343cc186c3..a72f4f7a1d7 100644 --- a/packages/server/src/api/routes/utils/validators.ts +++ b/packages/server/src/api/routes/utils/validators.ts @@ -280,8 +280,8 @@ function generateStepSchema(allowStepTypes: string[]) { const branchSchema = Joi.object({ id: Joi.string().required(), name: Joi.string().required(), - condition: filterObject({ unknown: false }).required().min(1), - conditionUI: Joi.object(), + condition: filterObject({ unknown: false }).required().allow(null), + conditionUI: Joi.object().allow(null), }) return Joi.object({