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.

add parseDateSchema

Steven Teyb21a87960b6a
diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.ts
index d9b38442cb..15d0d97142 100644
--- a/apps/web/lib/api/links/process-link.ts
+++ b/apps/web/lib/api/links/process-link.ts
@@ -374,7 +374,6 @@ export async function processLink<T extends Record<string, any>>({
key,
// we're redefining these fields because they're processed in the function
url,
- createdAt: createdAt ? new Date(createdAt) : undefined,
expiresAt,
expiredUrl,
// make sure projectId is set to the current workspace
diff --git a/apps/web/lib/zod/schemas/import-csv.ts b/apps/web/lib/zod/schemas/import-csv.ts
index 6d8b613141..2903f204af 100644
--- a/apps/web/lib/zod/schemas/import-csv.ts
+++ b/apps/web/lib/zod/schemas/import-csv.ts
@@ -1,11 +1,12 @@
import { z } from "zod";
+import { parseDateSchema } from "./utils";
export const linkMappingSchema = z.object({
domain: z.string(),
url: z.string(),
key: z.string(),
- createdAt: z.string().optional(),
- tags: z.string().optional(),
- title: z.string().optional(),
- description: z.string().optional(),
+ createdAt: parseDateSchema.nullish(),
+ tags: z.string().nullish(),
+ title: z.string().nullish(),
+ description: z.string().nullish(),
});
diff --git a/apps/web/lib/zod/schemas/links.ts b/apps/web/lib/zod/schemas/links.ts
index 48e8cdab52..6658d567e1 100644
--- a/apps/web/lib/zod/schemas/links.ts
+++ b/apps/web/lib/zod/schemas/links.ts
@@ -202,12 +202,7 @@ export const createLinkBodySchema = z.object({
"The unique name of the tags assigned to the short link (case insensitive).",
),
comments: z.string().nullish().describe("The comments for the short link."),
- createdAt: z
- .string()
- .nullish()
- .describe("The date and time when the short link was created."),
- expiresAt: z
- .string()
+ expiresAt: parseDateSchema
.nullish()
.describe("The date and time when the short link will expire at."),
expiredUrl: parseUrlSchema