From c346f0b8e4440e8cc2e55796901ef0b0c23a1bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Wed, 17 Mar 2021 16:34:27 +0000 Subject: [PATCH] fix: disallow zero as a value in some fields --- new-lamassu-admin/src/pages/Triggers/helper.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/new-lamassu-admin/src/pages/Triggers/helper.js b/new-lamassu-admin/src/pages/Triggers/helper.js index c7b9a565..be00ec90 100644 --- a/new-lamassu-admin/src/pages/Triggers/helper.js +++ b/new-lamassu-admin/src/pages/Triggers/helper.js @@ -104,7 +104,7 @@ const requirement = Yup.object().shape({ is: 'suspend', then: Yup.number() .required() - .min(0) + .min(1) .label('Invalid value'), otherwise: Yup.number() .nullable() @@ -126,10 +126,10 @@ const Schema = Yup.object() const validator = { txAmount: threshold => threshold.threshold >= 0, txVolume: threshold => - threshold.threshold >= 0 && threshold.thresholdDays >= 0, + threshold.threshold >= 0 && threshold.thresholdDays > 0, txVelocity: threshold => - threshold.threshold >= 0 && threshold.thresholdDays >= 0, - consecutiveDays: threshold => threshold.thresholdDays >= 0 + threshold.threshold > 0 && threshold.thresholdDays > 0, + consecutiveDays: threshold => threshold.thresholdDays > 0 } return ( (triggerType && validator?.[triggerType](threshold)) || @@ -244,10 +244,10 @@ const typeSchema = Yup.object() const validator = { txAmount: threshold => threshold.threshold >= 0, txVolume: threshold => - threshold.threshold >= 0 && threshold.thresholdDays >= 0, + threshold.threshold >= 0 && threshold.thresholdDays > 0, txVelocity: threshold => - threshold.threshold >= 0 && threshold.thresholdDays >= 0, - consecutiveDays: threshold => threshold.thresholdDays >= 0 + threshold.threshold > 0 && threshold.thresholdDays > 0, + consecutiveDays: threshold => threshold.thresholdDays > 0 } return ( @@ -397,7 +397,7 @@ const requirementSchema = Yup.object().shape({ is: value => value === 'suspend', then: Yup.number() .required() - .min(0), + .min(1), otherwise: Yup.number() .nullable() .transform(() => null)