add validations
This commit is contained in:
1 parent
48735c7dc8
commit
57acbd3497
3 files changed
+29
No files matched your search
@@ -21,3 +21,4 @@ export * from "./statusPageValidation.js";
|
|||||||
export * from "./notificationValidation.js";
|
export * from "./notificationValidation.js";
|
||||||
export * from "./userValidation.js";
|
export * from "./userValidation.js";
|
||||||
export * from "./incidentValidation.js";
|
export * from "./incidentValidation.js";
|
||||||
|
export * from "./tagValidation.js";
|
||||||
@@ -78,6 +78,7 @@ export const createMonitorBodyValidation = z
|
|||||||
diskAlertThreshold: z.number().optional(),
|
diskAlertThreshold: z.number().optional(),
|
||||||
tempAlertThreshold: z.number().optional(),
|
tempAlertThreshold: z.number().optional(),
|
||||||
notifications: z.array(z.string()).optional(),
|
notifications: z.array(z.string()).optional(),
|
||||||
|
tags: z.array(z.string()).optional(),
|
||||||
secret: z.string().optional(),
|
secret: z.string().optional(),
|
||||||
jsonPath: z.union([z.string(), z.literal("")]).optional(),
|
jsonPath: z.union([z.string(), z.literal("")]).optional(),
|
||||||
expectedValue: z.union([z.string(), z.literal("")]).optional(),
|
expectedValue: z.union([z.string(), z.literal("")]).optional(),
|
||||||
@@ -106,6 +107,7 @@ export const editMonitorBodyValidation = z
|
|||||||
description: z.union([z.string(), z.literal("")]).optional(),
|
description: z.union([z.string(), z.literal("")]).optional(),
|
||||||
interval: z.number().optional(),
|
interval: z.number().optional(),
|
||||||
notifications: z.array(z.string()).optional(),
|
notifications: z.array(z.string()).optional(),
|
||||||
|
tags: z.array(z.string()).optional(),
|
||||||
secret: z.string().optional(),
|
secret: z.string().optional(),
|
||||||
ignoreTlsErrors: z.boolean().optional(),
|
ignoreTlsErrors: z.boolean().optional(),
|
||||||
useAdvancedMatching: z.boolean().optional(),
|
useAdvancedMatching: z.boolean().optional(),
|
||||||
@@ -175,6 +177,7 @@ const importedMonitorSchema = z
|
|||||||
interval: z.number().default(60000),
|
interval: z.number().default(60000),
|
||||||
uptimePercentage: z.number().optional(),
|
uptimePercentage: z.number().optional(),
|
||||||
notifications: z.array(z.string()).default([]),
|
notifications: z.array(z.string()).default([]),
|
||||||
|
tags: z.array(z.string()).default([]),
|
||||||
secret: z.string().optional(),
|
secret: z.string().optional(),
|
||||||
cpuAlertThreshold: z.number().default(100),
|
cpuAlertThreshold: z.number().default(100),
|
||||||
cpuAlertCounter: z.number().default(5),
|
cpuAlertCounter: z.number().default(5),
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
//****************************************
|
||||||
|
// Tag Validations
|
||||||
|
//****************************************
|
||||||
|
|
||||||
|
export const createTagBodyValidation = z.object({
|
||||||
|
name: z.string().min(1, "Tag name is required"),
|
||||||
|
color: z
|
||||||
|
.string()
|
||||||
|
.regex(/^#([0-9a-fA-F]{6})$/, "Color must be a 6-digit hex value (e.g. #13715B)")
|
||||||
|
.optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const editTagBodyValidation = createTagBodyValidation;
|
||||||
|
|
||||||
|
export const getTagByIdParamValidation = z.object({
|
||||||
|
id: z.string().min(1, "Tag ID is required"),
|
||||||
|
});
|
||||||
|
export const editTagParamValidation = z.object({
|
||||||
|
id: z.string().min(1, "Tag ID is required"),
|
||||||
|
});
|
||||||
|
export const deleteTagParamValidation = z.object({
|
||||||
|
id: z.string().min(1, "Tag ID is required"),
|
||||||
|
});
|
||||||
Reference in new issue
Block a user