fix notification validation
This commit is contained in:
1 parent
de99577b9d
commit
dabff74946
1 file changed
+25
-11
@@ -580,17 +580,31 @@ const createNotificationBodyValidation = joi.object({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
address: joi.when("type", {
|
address: joi.when("type", {
|
||||||
is: "email",
|
switch: [
|
||||||
then: joi.string().email().required().messages({
|
{
|
||||||
"string.empty": "E-mail address cannot be empty",
|
is: "email",
|
||||||
"any.required": "E-mail address is required",
|
then: joi.string().email().required().messages({
|
||||||
"string.email": "Please enter a valid e-mail address",
|
"string.empty": "E-mail address cannot be empty",
|
||||||
}),
|
"any.required": "E-mail address is required",
|
||||||
otherwise: joi.string().uri().required().messages({
|
"string.email": "Please enter a valid e-mail address",
|
||||||
"string.empty": "Webhook URL cannot be empty",
|
}),
|
||||||
"any.required": "Webhook URL is required",
|
},
|
||||||
"string.uri": "Please enter a valid Webhook URL",
|
{
|
||||||
}),
|
is: "pager_duty",
|
||||||
|
then: joi.string().required().messages({
|
||||||
|
"string.empty": "PagerDuty integration key cannot be empty",
|
||||||
|
"any.required": "PagerDuty integration key is required",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
is: joi.string().valid("webhook", "slack", "discord"),
|
||||||
|
then: joi.string().uri().required().messages({
|
||||||
|
"string.empty": "Webhook URL cannot be empty",
|
||||||
|
"any.required": "Webhook URL is required",
|
||||||
|
"string.uri": "Please enter a valid Webhook URL",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user