From 8f3233c2c8819e361c598519f9b1d17ad5cc7cdb Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 3 Jul 2023 00:35:01 +0200 Subject: [PATCH] refactor: improve helper arguments validation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/utils/Utils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 83c1e3f7..647edcb9 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -165,6 +165,11 @@ export class Utils { fluctuationPercent: number, scale = 2 ): number { + if (fluctuationPercent < 0 || fluctuationPercent > 100) { + throw new Error( + `Fluctuation percent must be between 0 and 100. Actual value: ${fluctuationPercent}` + ); + } if (fluctuationPercent === 0) { return Utils.roundTo(staticValue, scale); } -- 2.34.1