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.

code improvements

Pedro Ladeira8ad98a0fbf60
diff --git a/apps/web/lib/zod/schemas/commissions.ts b/apps/web/lib/zod/schemas/commissions.ts
index 9842ae68bb..2e7fe55f46 100644
--- a/apps/web/lib/zod/schemas/commissions.ts
+++ b/apps/web/lib/zod/schemas/commissions.ts
@@ -629,6 +629,7 @@ const createSaleCommissionSchema = z
),
discountCode: z
.string()
+ .min(1)
.nullish()
.describe(
"The partner discount code to resolve the associated link. Use this when the link ID is unknown. Cannot be provided together with `linkId`.",
diff --git a/apps/web/playwright/api/commissions/commissions-create.spec.ts b/apps/web/playwright/api/commissions/commissions-create.spec.ts
index 75e0bb7f90..bda20f2f83 100644
--- a/apps/web/playwright/api/commissions/commissions-create.spec.ts
+++ b/apps/web/playwright/api/commissions/commissions-create.spec.ts
@@ -886,6 +886,21 @@ test.describe("Sale commissions", () => {
"custom: discountCode: Either `linkId` or `discountCode` may be provided, not both.",
}),
},
+ {
+ name: "rejects empty discountCode",
+ body: {
+ type: "sale",
+ partnerId: "pn_test",
+ customerId: "cus_test",
+ saleAmount: 1000,
+ discountCode: "",
+ },
+ expected: apiError({
+ code: "unprocessable_entity",
+ message:
+ "too_small: discountCode: Too small: expected string to have >=1 characters",
+ }),
+ },
];
for (const { name, body, expected } of errorCases) {