Skip to content

Commit

Permalink
Update create & update url schema
Browse files Browse the repository at this point in the history
  • Loading branch information
pheralb committed Apr 1, 2024
1 parent 0d4fe53 commit faa5082
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/server/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export const CreateLinkSchema = z.object({
.url({
message: "Please enter a valid URL. Include http:// or https://",
})
.regex(/^(?!.*(?:http|https):\/\/(?:slug|slugr)\.vercel\.app).*$/, {
message: "You cannot redirect to the Slug url.",
})
// not contain any blank spaces
.regex(/^\S+$/, {
message: "URL must not contain any blank spaces.",
}),
Expand All @@ -39,7 +43,16 @@ export const CreateLinkSchema = z.object({

export const EditLinkSchema = z.object({
id: z.string(),
url: z.string().min(1, { message: "URL is required." }),
url: z
.string()
.min(1, { message: "URL is required." })
.regex(/^(?!.*(?:http|https):\/\/(?:slug|slugr)\.vercel\.app).*$/, {
message: "You cannot redirect to the Slug url.",
})
// not contain any blank spaces
.regex(/^\S+$/, {
message: "URL must not contain any blank spaces.",
}),
slug: z
.string()
.min(1, { message: "Short link is required." })
Expand Down

0 comments on commit faa5082

Please sign in to comment.