update validation
This commit is contained in:
1 parent
a6ab7b652f
commit
cba744f777
1 file changed
+26
-21
@@ -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,20 +153,21 @@ 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
|
||||||
.integer()
|
.number()
|
||||||
.min(1)
|
.integer()
|
||||||
.max(65535)
|
.min(1)
|
||||||
.when("type", {
|
.max(65535)
|
||||||
is: "port",
|
.when("type", {
|
||||||
then: joi.required().messages({
|
is: "port",
|
||||||
"number.base": "Port must be a number.",
|
then: joi.required().messages({
|
||||||
"number.min": "Port must be at least 1.",
|
"number.base": "Port must be a number.",
|
||||||
"number.max": "Port must be at most 65535.",
|
"number.min": "Port must be at least 1.",
|
||||||
"any.required": "Port is required for port monitors.",
|
"number.max": "Port must be at most 65535.",
|
||||||
|
"any.required": "Port is required for port monitors.",
|
||||||
|
}),
|
||||||
|
otherwise: joi.optional(),
|
||||||
}),
|
}),
|
||||||
otherwise: joi.optional(),
|
|
||||||
}),
|
|
||||||
name: joi.string().trim().max(50).allow("").messages({
|
name: joi.string().trim().max(50).allow("").messages({
|
||||||
"string.max": "This field should not exceed the 50 characters limit.",
|
"string.max": "This field should not exceed the 50 characters limit.",
|
||||||
}),
|
}),
|
||||||
@@ -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,
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user