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.

fix(api): reorder `trim()` method calls in Zod schema

unrenamed608759a29615
diff --git a/apps/web/lib/zod/schemas/tags.ts b/apps/web/lib/zod/schemas/tags.ts
index e7e5a90226..6a7dde3aa6 100644
--- a/apps/web/lib/zod/schemas/tags.ts
+++ b/apps/web/lib/zod/schemas/tags.ts
@@ -38,17 +38,17 @@ export const createTagBodySchema = z
.object({
name: z
.string()
+ .trim()
.min(1)
.max(50)
- .trim()
.describe("The name of the tag to create."),
color: tagColorSchema.describe(
`The color of the tag. If not provided, a random color will be used from the list: ${tagColors.join(", ")}.`,
),
tag: z
.string()
- .min(1)
.trim()
+ .min(1)
.describe("The name of the tag to create.")
.openapi({ deprecated: true }),
})
diff --git a/apps/web/lib/zod/schemas/utm.ts b/apps/web/lib/zod/schemas/utm.ts
index c3313f1c31..28f50b4ed3 100644
--- a/apps/web/lib/zod/schemas/utm.ts
+++ b/apps/web/lib/zod/schemas/utm.ts
@@ -1,39 +1,45 @@
import z from "@/lib/zod";
export const createUTMTemplateBodySchema = z.object({
- name: z.string().min(1).max(50).trim(),
+ name: z.string().trim().min(1, "UTM name is required").max(50),
utm_source: z
.string()
+ .trim()
.max(190)
.nullish()
.transform((v) => v ?? null)
.describe("The UTM source of the short link."),
utm_medium: z
.string()
+ .trim()
.max(190)
.nullish()
.transform((v) => v ?? null)
.describe("The UTM medium of the short link."),
utm_campaign: z
.string()
+ .trim()
.max(190)
.nullish()
.transform((v) => v ?? null)
.describe("The UTM campaign of the short link."),
utm_term: z
.string()
+ .trim()
.max(190)
.nullish()
.transform((v) => v ?? null)
.describe("The UTM term of the short link."),
utm_content: z
.string()
+ .trim()
.max(190)
.nullish()
.transform((v) => v ?? null)
.describe("The UTM content of the short link."),
ref: z
.string()
+ .trim()
.max(190)
.nullish()
.transform((v) => v ?? null)