From: Jérôme Benoit Date: Sun, 2 Jul 2023 22:35:01 +0000 (+0200) Subject: refactor: improve helper arguments validation X-Git-Tag: v1.2.18~85 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8f3233c2c8819e361c598519f9b1d17ad5cc7cdb;p=e-mobility-charging-stations-simulator.git refactor: improve helper arguments validation Signed-off-by: Jérôme Benoit --- 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); }