update validation

This commit is contained in:
Alex Holliday committed 2025-05-09 13:28:04 -07:00
1 parent a6ab7b652f
commit cba744f777
1 file changed
+14 -9
+14 -9
View File
@@ -11,7 +11,8 @@ const nameSchema = joi
.messages({ .messages({
"string.empty": "Name is required", "string.empty": "Name is required",
"string.max": "Name must be less than 50 characters", "string.max": "Name must be less than 50 characters",
"string.pattern.base": "Name must contain only letters, spaces, apostrophes, or hyphens" "string.pattern.base":
"Name must contain only letters, spaces, apostrophes, or hyphens",
}); });
const passwordSchema = joi const passwordSchema = joi
@@ -152,7 +153,8 @@ const monitorValidation = joi.object({
"string.invalidUrl": "Please enter a valid URL with optional port", "string.invalidUrl": "Please enter a valid URL with optional port",
"string.pattern.base": "Please enter a valid container ID.", "string.pattern.base": "Please enter a valid container ID.",
}), }),
port: joi.number() port: joi
.number()
.integer() .integer()
.min(1) .min(1)
.max(65535) .max(65535)
@@ -253,14 +255,14 @@ const statusPageValidation = joi.object({
showCharts: joi.boolean(), showCharts: joi.boolean(),
}); });
const settingsValidation = joi.object({ const settingsValidation = joi.object({
ttl: joi.number().required().messages({ checkTTL: joi.number().required().messages({
"string.empty": "Please enter a value", "string.empty": "Please enter a value",
"number.base": "Please enter a valid number", "number.base": "Please enter a valid number",
"any.required": "Please enter a value" "any.required": "Please enter a value",
}), }),
pagespeedApiKey: joi.string().allow("").optional(), pagespeedApiKey: joi.string().allow("").optional(),
}) language: joi.string().required(),
.unknown(true); });
const dayjsValidator = (value, helpers) => { const dayjsValidator = (value, helpers) => {
if (!dayjs(value).isValid()) { if (!dayjs(value).isValid()) {
@@ -363,9 +365,12 @@ const infrastructureMonitorValidation = joi.object({
notifications: joi.array().items( notifications: joi.array().items(
joi.object({ joi.object({
type: joi.string().valid("email").required(), type: joi.string().valid("email").required(),
address: joi.string().email({ tlds: { allow: false } }).required(), address: joi
.string()
.email({ tlds: { allow: false } })
.required(),
}) })
) ),
}); });
export { export {
@@ -377,5 +382,5 @@ export {
advancedSettingsValidation, advancedSettingsValidation,
infrastructureMonitorValidation, infrastructureMonitorValidation,
statusPageValidation, statusPageValidation,
logoImageValidation logoImageValidation,
}; };