From 473aada9e1122774dbc9c7f05954ae0f6bc013f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Mon, 29 Mar 2021 14:32:11 +0100 Subject: [PATCH] refactor: error message building --- .../src/pages/Triggers/helper.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/new-lamassu-admin/src/pages/Triggers/helper.js b/new-lamassu-admin/src/pages/Triggers/helper.js index 8da70d6d..165b3505 100644 --- a/new-lamassu-admin/src/pages/Triggers/helper.js +++ b/new-lamassu-admin/src/pages/Triggers/helper.js @@ -114,21 +114,18 @@ const Schema = Yup.object() txVolume: threshold => { const thresholdMessage = 'Volume must be greater than or equal to 0' const thresholdDaysMessage = 'Days must be greater than 0' - const message = [thresholdMessage, thresholdDaysMessage] - if (threshold.threshold < 0 && threshold.thresholdDays <= 0) - return message.join(', ') - if (threshold.threshold < 0) return message[0] - if (threshold.thresholdDays <= 0) return message[1] + const message = [] + if (threshold.threshold < 0) message.push(thresholdMessage) + if (threshold.thresholdDays <= 0) message.push(thresholdDaysMessage) + return message.join(', ') }, txVelocity: threshold => { const thresholdMessage = 'Transactions must be greater than 0' const thresholdDaysMessage = 'Days must be greater than 0' - const message = [thresholdMessage, thresholdDaysMessage] - if (threshold.threshold <= 0 && threshold.thresholdDays <= 0) - return message.join(', ') - if (threshold.threshold <= 0) return message[0] - if (threshold.thresholdDays <= 0) return message[1] - return message + const message = [] + if (threshold.threshold <= 0) message.push(thresholdMessage) + if (threshold.thresholdDays <= 0) message.push(thresholdDaysMessage) + return message.join(', ') }, consecutiveDays: threshold => 'Days must be greater than 0' }