fix: minor changes to statusPageValidation and other fixes
This commit is contained in:
1 parent
3a9f9f0ce5
commit
294a149fd1
2 files changed
+8
-3
No files matched your search
@@ -45,7 +45,7 @@ const StatusPageSchema = new Schema<StatusPageDocument>(
|
|||||||
type: {
|
type: {
|
||||||
type: [String],
|
type: [String],
|
||||||
required: true,
|
required: true,
|
||||||
default: [],
|
default: ["uptime"],
|
||||||
enum: StatusPageTypes,
|
enum: StatusPageTypes,
|
||||||
},
|
},
|
||||||
companyName: {
|
companyName: {
|
||||||
|
|||||||
@@ -10,13 +10,17 @@ export const getStatusPageParamValidation = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const getStatusPageQueryValidation = z.object({
|
export const getStatusPageQueryValidation = z.object({
|
||||||
type: z.array(z.enum(["uptime", "infrastructure"])),
|
type: z
|
||||||
|
.union([z.enum(["uptime", "infrastructure"]), z.array(z.enum(["uptime", "infrastructure"]))])
|
||||||
|
.transform((val) => (Array.isArray(val) ? val : [val])),
|
||||||
timeFrame: z.coerce.number().optional(),
|
timeFrame: z.coerce.number().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const createStatusPageBodyValidation = z
|
export const createStatusPageBodyValidation = z
|
||||||
.object({
|
.object({
|
||||||
type: z.array(z.enum(["uptime", "infrastructure"])),
|
type: z
|
||||||
|
.union([z.enum(["uptime", "infrastructure"]), z.array(z.enum(["uptime", "infrastructure"]))])
|
||||||
|
.transform((val) => (Array.isArray(val) ? val : [val])),
|
||||||
companyName: z.string().min(1, "Company name is required"),
|
companyName: z.string().min(1, "Company name is required"),
|
||||||
url: z.string().regex(/^[a-zA-Z0-9_-]+$/, {
|
url: z.string().regex(/^[a-zA-Z0-9_-]+$/, {
|
||||||
message: "URL can only contain letters, numbers, underscores, and hyphens",
|
message: "URL can only contain letters, numbers, underscores, and hyphens",
|
||||||
@@ -30,6 +34,7 @@ export const createStatusPageBodyValidation = z
|
|||||||
showCharts: booleanCoercion.optional(),
|
showCharts: booleanCoercion.optional(),
|
||||||
showUptimePercentage: booleanCoercion,
|
showUptimePercentage: booleanCoercion,
|
||||||
showAdminLoginLink: booleanCoercion.optional(),
|
showAdminLoginLink: booleanCoercion.optional(),
|
||||||
|
showInfrastructure: booleanCoercion.optional(),
|
||||||
removeLogo: z.union([z.literal("true"), z.literal("false")]).optional(),
|
removeLogo: z.union([z.literal("true"), z.literal("false")]).optional(),
|
||||||
})
|
})
|
||||||
.strip();
|
.strip();
|
||||||
|
|||||||
Reference in new issue
Block a user