Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update upsert-group-move-rules.ts

Kiran K70361b2a4ba9
diff --git a/apps/web/lib/api/groups/upsert-group-move-rules.ts b/apps/web/lib/api/groups/upsert-group-move-rules.ts
index 8cdc3fe930..b87a9a9cc2 100644
--- a/apps/web/lib/api/groups/upsert-group-move-rules.ts
+++ b/apps/web/lib/api/groups/upsert-group-move-rules.ts
@@ -9,6 +9,7 @@ import { createId } from "../create-id";
import { DubApiError } from "../errors";
import { findGroupsWithMatchingRules } from "./find-groups-with-matching-rules";
import { getGroupMoveRules } from "./get-group-move-rules";
+import { validateGroupMoveRules } from "./validate-group-move-rules";
export async function upsertGroupMoveRules({
workspace,
@@ -48,6 +49,19 @@ export async function upsertGroupMoveRules({
};
}
+ try {
+ validateGroupMoveRules({
+ rules: moveRules,
+ destinationGroupId: group.id,
+ });
+ } catch (error) {
+ throw new DubApiError({
+ code: "bad_request",
+ message:
+ error instanceof Error ? error.message : "Invalid group move rules.",
+ });
+ }
+
const groupsWithMatchingRules = findGroupsWithMatchingRules({
groups: await getGroupMoveRules(group.programId),
currentRules: moveRules,