recommended changes

This commit is contained in:
Anurag123Chauhan committed 2025-05-15 11:16:02 +05:30
1 parent 18b439bad6
commit 9da9ef6939
1 file changed
+8 -9
+8 -9
View File
@@ -109,14 +109,15 @@ const monitorValidation = joi.object({
then: joi
.string()
.trim()
.regex(/^[a-z0-9]{64}$/),
.regex(/^[a-z0-9]{64}$/)
.messages({
"string.empty": "This field is required.",
"string.pattern.base": "Please enter a valid 64-character Docker container ID.",
}),
otherwise: joi
.string()
.trim()
.custom((value, helpers) => {
// Get the current validation context
const { type } = helpers.state.ancestors[0];
// Regex from https://gist.github.com/dperini/729294
var urlRegex = new RegExp(
"^" +
@@ -155,19 +156,16 @@ const monitorValidation = joi.object({
"i"
);
if (!urlRegex.test(value)) {
// Use different error key based on monitor type
return helpers.error(type === "docker" ? "string.invalidDockerID" : "string.invalidUrl");
return helpers.error("string.invalidUrl");
}
return value;
}),
})
.messages({
"string.empty": "This field is required.",
"string.uri": "The URL you provided is not valid.",
"string.invalidUrl": "Please enter a valid URL with optional port",
"string.invalidDockerID": "Please enter a valid 64-character Docker container ID.",
"string.pattern.base": "Please enter a valid container ID.",
}),
}),
port: joi
.number()
@@ -270,6 +268,7 @@ const statusPageValidation = joi.object({
showUptimePercentage: joi.boolean(),
showCharts: joi.boolean(),
});
const settingsValidation = joi.object({
checkTTL: joi.number().required().messages({
"string.empty": "Please enter a value",