Files
Checkmate/client/src/Validation/settings.ts
T

61 lines
1.9 KiB
TypeScript
Raw Normal View History

2026-03-10 10:20:23 -07:00
import { CHECK_TTL_SENTINEL } from "@/Types/Check";
2026-02-12 12:13:36 -05:00
import { z } from "zod";
export const settingsSchema = z.object({
systemEmailIgnoreTLS: z.boolean(),
systemEmailRequireTLS: z.boolean(),
systemEmailRejectUnauthorized: z.boolean(),
2026-02-18 20:14:35 +00:00
systemEmailConnectionHost: z
.string()
2026-03-12 09:54:08 -07:00
.transform((val) => (val.trim() === "" ? null : val.trim()))
2026-02-18 20:14:35 +00:00
.optional(),
2026-02-12 12:13:36 -05:00
systemEmailSecure: z.boolean().optional(),
systemEmailPool: z.boolean().optional(),
showURL: z.boolean().optional(),
defaultUserAgent: z
.string()
.max(500)
.transform((val) => (val.trim() === "" ? null : val.trim()))
.optional(),
2026-03-10 10:20:23 -07:00
checkTTL: z
.number()
.int()
.min(1, "Please enter a value")
.max(CHECK_TTL_SENTINEL, `Maximum ${CHECK_TTL_SENTINEL}`),
2026-02-18 20:14:35 +00:00
pagespeedApiKey: z
.string()
2026-03-12 09:54:08 -07:00
.transform((val) => (val.trim() === "" ? null : val.trim()))
2026-02-18 20:14:35 +00:00
.optional(),
systemEmailHost: z
.string()
.regex(/^[a-zA-Z0-9.-]*$/, "Invalid hostname or IP address")
2026-03-12 09:54:08 -07:00
.transform((val) => (val.trim() === "" ? null : val.trim()))
2026-02-18 20:14:35 +00:00
.optional(),
systemEmailPort: z.number().int().min(1).max(65535).optional(),
systemEmailAddress: z
.email("Please enter a valid email address")
.or(z.literal(""))
2026-03-12 09:54:08 -07:00
.transform((val) => (val === "" ? null : val.toLowerCase().trim()))
2026-02-18 20:14:35 +00:00
.optional(),
systemEmailUser: z
.string()
2026-03-12 09:54:08 -07:00
.transform((val) => (val.trim() === "" ? null : val.trim()))
2026-02-18 20:14:35 +00:00
.optional(),
systemEmailPassword: z
.string()
2026-03-12 09:54:08 -07:00
.transform((val) => (val.trim() === "" ? null : val.trim()))
2026-02-18 20:14:35 +00:00
.optional(),
systemEmailTLSServername: z
.string()
2026-03-12 09:54:08 -07:00
.transform((val) => (val.trim() === "" ? null : val.trim()))
2026-02-18 20:14:35 +00:00
.optional(),
2026-02-26 19:07:43 +00:00
globalThresholds: z.object({
cpu: z.number().int().min(1).max(100),
memory: z.number().int().min(1).max(100),
disk: z.number().int().min(1).max(100),
2026-02-26 19:31:12 +00:00
temperature: z.number().int().min(1).max(150),
2026-02-26 19:07:43 +00:00
}),
2026-02-12 12:13:36 -05:00
});
2026-03-12 09:54:08 -07:00
export type SettingsFormInput = z.input<typeof settingsSchema>;
2026-02-12 12:13:36 -05:00
export type SettingsFormData = z.infer<typeof settingsSchema>;