refactor: improve helper arguments validation
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 2 Jul 2023 22:35:01 +0000 (00:35 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 2 Jul 2023 22:35:01 +0000 (00:35 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/utils/Utils.ts

index 83c1e3f7490a4dd9fff5976c2367a5eb548e7dfa..647edcb9f88ad6b2674d8b82a051b75a443bba18 100644 (file)
@@ -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);
     }