Merge pull request #2806 from bluewave-labs/fix/pager_duty
fix: update pager_duty validation, resolves #2805
This commit is contained in:
3 files changed
+33
-21
No files matched your search
@@ -89,8 +89,6 @@ const CreateNotifications = () => {
|
|||||||
error.details.forEach((err) => {
|
error.details.forEach((err) => {
|
||||||
newErrors[err.path[0]] = err.message;
|
newErrors[err.path[0]] = err.message;
|
||||||
});
|
});
|
||||||
console.log(JSON.stringify(newErrors));
|
|
||||||
console.log(JSON.stringify(form, null, 2));
|
|
||||||
createToast({ body: Object.values(newErrors)[0] });
|
createToast({ body: Object.values(newErrors)[0] });
|
||||||
setErrors(newErrors);
|
setErrors(newErrors);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export const NOTIFICATION_TYPES = [
|
|||||||
export const TITLE_MAP = {
|
export const TITLE_MAP = {
|
||||||
email: "createNotifications.emailSettings.title",
|
email: "createNotifications.emailSettings.title",
|
||||||
slack: "createNotifications.slackSettings.title",
|
slack: "createNotifications.slackSettings.title",
|
||||||
pager_duty: "createNotifications.pagerDutySettings.title",
|
pager_duty: "createNotifications.pagerdutySettings.title",
|
||||||
webhook: "createNotifications.webhookSettings.title",
|
webhook: "createNotifications.webhookSettings.title",
|
||||||
discord: "createNotifications.discordSettings.title",
|
discord: "createNotifications.discordSettings.title",
|
||||||
};
|
};
|
||||||
@@ -17,7 +17,7 @@ export const TITLE_MAP = {
|
|||||||
export const DESCRIPTION_MAP = {
|
export const DESCRIPTION_MAP = {
|
||||||
email: "createNotifications.emailSettings.description",
|
email: "createNotifications.emailSettings.description",
|
||||||
slack: "createNotifications.slackSettings.description",
|
slack: "createNotifications.slackSettings.description",
|
||||||
pager_duty: "createNotifications.pagerDutySettings.description",
|
pager_duty: "createNotifications.pagerdutySettings.description",
|
||||||
webhook: "createNotifications.webhookSettings.description",
|
webhook: "createNotifications.webhookSettings.description",
|
||||||
discord: "createNotifications.discordSettings.description",
|
discord: "createNotifications.discordSettings.description",
|
||||||
};
|
};
|
||||||
@@ -25,7 +25,7 @@ export const DESCRIPTION_MAP = {
|
|||||||
export const LABEL_MAP = {
|
export const LABEL_MAP = {
|
||||||
email: "createNotifications.emailSettings.emailLabel",
|
email: "createNotifications.emailSettings.emailLabel",
|
||||||
slack: "createNotifications.slackSettings.webhookLabel",
|
slack: "createNotifications.slackSettings.webhookLabel",
|
||||||
pager_duty: "createNotifications.pagerDutySettings.integrationKeyLabel",
|
pager_duty: "createNotifications.pagerdutySettings.integrationKeyLabel",
|
||||||
webhook: "createNotifications.webhookSettings.webhookLabel",
|
webhook: "createNotifications.webhookSettings.webhookLabel",
|
||||||
discord: "createNotifications.discordSettings.webhookLabel",
|
discord: "createNotifications.discordSettings.webhookLabel",
|
||||||
};
|
};
|
||||||
@@ -33,7 +33,7 @@ export const LABEL_MAP = {
|
|||||||
export const PLACEHOLDER_MAP = {
|
export const PLACEHOLDER_MAP = {
|
||||||
email: "createNotifications.emailSettings.emailPlaceholder",
|
email: "createNotifications.emailSettings.emailPlaceholder",
|
||||||
slack: "createNotifications.slackSettings.webhookPlaceholder",
|
slack: "createNotifications.slackSettings.webhookPlaceholder",
|
||||||
pager_duty: "createNotifications.pagerDutySettings.integrationKeyPlaceholder",
|
pager_duty: "createNotifications.pagerdutySettings.integrationKeyPlaceholder",
|
||||||
webhook: "createNotifications.webhookSettings.webhookPlaceholder",
|
webhook: "createNotifications.webhookSettings.webhookPlaceholder",
|
||||||
discord: "createNotifications.discordSettings.webhookPlaceholder",
|
discord: "createNotifications.discordSettings.webhookPlaceholder",
|
||||||
};
|
};
|
||||||
@@ -439,21 +439,35 @@ const notificationValidation = joi.object({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
address: joi.when("type", {
|
address: joi.when("type", {
|
||||||
is: "email",
|
switch: [
|
||||||
then: joi
|
{
|
||||||
.string()
|
is: "email",
|
||||||
.email({ tlds: { allow: false } })
|
then: joi
|
||||||
.required()
|
.string()
|
||||||
.messages({
|
.email({ tlds: { allow: false } })
|
||||||
"string.empty": "E-mail address cannot be empty",
|
.required()
|
||||||
"any.required": "E-mail address is 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 routing key cannot be empty",
|
||||||
|
"any.required": "PagerDuty routing key is required",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
is: joi.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