Files
Checkmate/server/src/validation/checkValidation.ts
T

43 lines
1.5 KiB
TypeScript
Raw Normal View History

2026-03-02 17:29:48 +00:00
import { z } from "zod";
2026-03-02 19:25:34 +00:00
import { booleanCoercion } from "./shared.js";
2026-03-01 17:35:00 +00:00
import { GeoContinents } from "@/types/geoCheck.js";
2026-05-11 10:12:27 -07:00
import { MonitorTypes } from "@/types/monitor.js";
2026-03-01 17:35:00 +00:00
//****************************************
// Check Validations
//****************************************
2026-03-02 17:29:48 +00:00
export const getChecksParamValidation = z.object({
monitorId: z.string().min(1, "Monitor ID is required"),
2026-03-01 17:35:00 +00:00
});
2026-03-02 17:29:48 +00:00
export const getChecksQueryValidation = z.object({
2026-05-11 10:12:27 -07:00
type: z.enum(MonitorTypes).optional(),
2026-03-10 10:20:23 -07:00
sortOrder: z.enum(["asc", "desc"]),
2026-03-02 17:46:33 +00:00
limit: z.coerce.number().optional(),
2026-03-10 10:20:23 -07:00
dateRange: z.enum(["recent", "hour", "day", "week", "month", "all"]),
2026-03-02 17:29:48 +00:00
filter: z.enum(["all", "up", "down", "resolve"]).optional(),
2026-03-02 19:25:34 +00:00
ack: booleanCoercion.optional(),
2026-03-10 10:20:23 -07:00
page: z.coerce.number(),
rowsPerPage: z.coerce.number(),
2026-03-02 19:25:34 +00:00
status: booleanCoercion.optional(),
2026-03-02 17:29:48 +00:00
continent: z.union([z.enum(GeoContinents), z.array(z.enum(GeoContinents))]).optional(),
2026-03-01 17:35:00 +00:00
});
2026-03-02 17:29:48 +00:00
export const getTeamChecksQueryValidation = z.object({
2026-03-10 10:20:23 -07:00
sortOrder: z.enum(["asc", "desc"]),
2026-03-02 17:46:33 +00:00
limit: z.coerce.number().optional(),
2026-03-10 10:20:23 -07:00
dateRange: z.enum(["recent", "hour", "day", "week", "month", "all"]),
2026-03-02 17:29:48 +00:00
filter: z.enum(["all", "up", "down", "resolve"]).optional(),
2026-03-02 19:25:34 +00:00
ack: booleanCoercion.optional(),
2026-03-10 10:20:23 -07:00
page: z.coerce.number(),
rowsPerPage: z.coerce.number(),
2026-03-01 17:35:00 +00:00
});
2026-03-02 17:29:48 +00:00
export const deleteChecksParamValidation = z.object({
monitorId: z.string().min(1, "Monitor ID is required"),
2026-03-01 17:35:00 +00:00
});
2026-03-10 10:20:23 -07:00
export const getChecksSummaryByTeamIdQueryValidation = z.object({
dateRange: z.enum(["recent", "hour", "day", "week", "month", "all"]).optional(),
});