refactor(validation): use Zod URL protocols

Refs #3821
This commit is contained in:
Marcos Paulo Diniz committed 2026-08-05 08:34:12 -03:00
1 parent 0c184e6d0c
commit 466d356ad1
2 files changed
+5 -8

No files matched your search

+1 -5
View File
@@ -35,11 +35,7 @@ const rocketChatSchema = baseSchema.extend({
address: z
.string()
.min(1, "Webhook URL is required")
.url("Please enter a valid URL")
.refine(
(url) => /^https?:\/\//i.test(url),
"Rocket.Chat webhook URL must use HTTP or HTTPS"
),
.url({ protocol: /^https?$/, message: "Please enter a valid URL" }),
});
const pagerDutySchema = baseSchema.extend({
@@ -27,9 +27,10 @@ export const createNotificationBodyValidation = z.discriminatedUnion("type", [
z.object({
notificationName: z.string().min(1, "Notification name is required"),
type: z.literal("rocket_chat"),
address: z
.url({ message: "Please enter a valid Rocket.Chat webhook URL" })
.refine((url) => /^https?:\/\//i.test(url), { message: "Rocket.Chat webhook URL must use HTTP or HTTPS" }),
address: z.url({
protocol: /^https?$/,
message: "Please enter a valid Rocket.Chat webhook URL",
}),
}),
// Slack notification
z.object({