email settings

This commit is contained in:
Alex Holliday committed 2025-11-19 23:55:29 +00:00
1 parent 819c0ca05a
commit 3faff5dc54
16 files changed
+665 -33

No files matched your search

+70
View File
@@ -81,6 +81,12 @@ const durationSchemaInfra = z
}
});
const optionalString = <T extends z.ZodTypeAny>(schema: T) =>
z.preprocess(
(val) => (val === "" || val === null ? undefined : val),
schema.optional()
);
export const monitorSchema = z.object({
type: z.string().min(1, "You must select an option"),
url: z.string().min(1, "URL is required").regex(urlRegex, "Invalid URL"),
@@ -203,6 +209,70 @@ export const maintenanceSchema = z
}
});
export const systemSettingsSchema = z.object({
systemEmailHost: optionalString(
z
.string()
.trim()
.min(1, { message: "SMTP host is required" })
.max(255, {
message: "SMTP host must be 255 characters or fewer",
})
),
systemEmailPort: optionalString(
z
.union([z.number().int(), z.string().regex(/^\d+$/)])
.transform((val) => (typeof val === "string" ? Number(val) : val))
.refine(
(val) =>
val === undefined ||
(Number.isInteger(val) && val > 0 && val < 65536),
{
message: "Port must be a number between 1 and 65535",
}
)
),
systemEmailAddress: optionalString(
z.string().email({ message: "SMTP email must be valid" })
),
systemEmailPassword: optionalString(
z
.string()
.max(255, {
message: "SMTP password must be 255 characters or fewer",
})
),
systemEmailUser: optionalString(
z
.string()
.trim()
.max(255, {
message: "SMTP username must be 255 characters or fewer",
})
),
systemEmailConnectionHost: optionalString(
z
.string()
.trim()
.max(255, {
message: "Connection host must be 255 characters or fewer",
})
),
systemEmailTLSServername: optionalString(
z
.string()
.trim()
.max(255, {
message: "TLS server name must be 255 characters or fewer",
})
),
systemEmailSecure: z.boolean().optional(),
systemEmailPool: z.boolean().optional(),
systemEmailIgnoreTLS: z.boolean().optional(),
systemEmailRequireTLS: z.boolean().optional(),
systemEmailRejectUnauthorized: z.boolean().optional(),
});
const statusPageUrlRegex = /^[A-Za-z0-9]+$/;
export const statusPageSchema = z.object({