repositories
/
e-mobility-charging-stations-simulator.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
361c98f
)
refactor: improve helper arguments validation
author
Jérôme Benoit
<jerome.benoit@sap.com>
Sun, 2 Jul 2023 22:35:01 +0000
(
00:35
+0200)
committer
Jé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
patch
|
blob
|
blame
|
history
diff --git
a/src/utils/Utils.ts
b/src/utils/Utils.ts
index 83c1e3f7490a4dd9fff5976c2367a5eb548e7dfa..647edcb9f88ad6b2674d8b82a051b75a443bba18 100644
(file)
--- 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);
}