use enums for validation

This commit is contained in:
Alex committed 2026-05-08 12:56:56 -07:00
1 parent 172d36ba1d
commit 4b4fae91c2
2 files changed
+4 -13

No files matched your search

+2 -1
View File
@@ -8,6 +8,7 @@ import type {
CheckNetworkInterfaceInfo, CheckNetworkInterfaceInfo,
GotTimings, GotTimings,
ILighthouseAudit, ILighthouseAudit,
DnsRecordType,
Monitor, Monitor,
MonitorMatchMethod, MonitorMatchMethod,
MonitorType, MonitorType,
@@ -119,7 +120,7 @@ export interface WebSocketStatusPayload {
export interface DNSStatusPayload { export interface DNSStatusPayload {
hostname: string; hostname: string;
dnsServer: string; dnsServer: string;
recordType: string; recordType: DnsRecordType;
resolved: boolean; resolved: boolean;
results: unknown; results: unknown;
} }
+2 -12
View File
@@ -20,12 +20,7 @@ export const getMonitorByIdQueryValidation = z.object({
export const getMonitorsByTeamIdParamValidation = z.object({}); export const getMonitorsByTeamIdParamValidation = z.object({});
export const getMonitorsByTeamIdQueryValidation = z.object({ export const getMonitorsByTeamIdQueryValidation = z.object({
type: z type: z.union([z.enum(MonitorTypes), z.array(z.enum(MonitorTypes))]).optional(),
.union([
z.enum(["http", "ping", "pagespeed", "docker", "hardware", "port", "game", "grpc", "websocket"]),
z.array(z.enum(["http", "ping", "pagespeed", "docker", "hardware", "port", "game", "grpc", "websocket"])),
])
.optional(),
filter: z.union([z.string(), z.literal("")]).optional(), filter: z.union([z.string(), z.literal("")]).optional(),
}); });
@@ -36,12 +31,7 @@ export const getMonitorsWithChecksQueryValidation = z.object({
filter: z.union([z.string(), z.literal("")]).optional(), filter: z.union([z.string(), z.literal("")]).optional(),
field: z.string().optional(), field: z.string().optional(),
order: z.enum(["asc", "desc"]).optional(), order: z.enum(["asc", "desc"]).optional(),
type: z type: z.union([z.enum(MonitorTypes), z.array(z.enum(MonitorTypes))]).optional(),
.union([
z.enum(["http", "ping", "pagespeed", "docker", "hardware", "port", "game", "grpc", "websocket"]),
z.array(z.enum(["http", "ping", "pagespeed", "docker", "hardware", "port", "game", "grpc", "websocket"])),
])
.optional(),
explain: booleanCoercion.optional(), explain: booleanCoercion.optional(),
}); });