Skip to content

Commit

Permalink
remove validation for empty conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
PClmnt committed Oct 31, 2024
1 parent dd90571 commit d37c3ab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
24 changes: 0 additions & 24 deletions packages/server/src/api/routes/tests/automation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/api/routes/utils/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit d37c3ab

Please sign in to comment.