From 153349e0da9237f94f0bb2345635b046bc94fc99 Mon Sep 17 00:00:00 2001
From: "francois.grand" <francois.grand@irstea.fr>
Date: Wed, 28 Mar 2018 13:23:49 +0200
Subject: [PATCH] =?UTF-8?q?classe=20ParamValues=20:=20ajout=20d'une=20m?=
 =?UTF-8?q?=C3=A9thode=20check()=20de=20v=C3=A9rification=20des=20membres?=
 =?UTF-8?q?=20en=20fonction=20du=20mode?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/param/param-values.ts | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/param/param-values.ts b/src/param/param-values.ts
index d4e55170..62d132ba 100644
--- a/src/param/param-values.ts
+++ b/src/param/param-values.ts
@@ -51,6 +51,7 @@ export class ParamValueIterator implements IterableIterator<number> {
     private _config: number;
 
     constructor(prm: ParamValues, reverse: boolean = false) {
+        prm.check();
         this._param = prm;
         this.reset(reverse)
     }
@@ -246,6 +247,37 @@ export class ParamValues {
             throw new Error(`ParamValues : mode de valeurs ${ParamValueMode[expected]} incorrect`);
     }
 
+    public check() {
+        switch (this._valueMode) {
+            case ParamValueMode.SINGLE:
+                if (!this._singleValue.isDefined)
+                    throw new Error(`ParamValues : valeur fixe non définie`);
+                break;
+
+            case ParamValueMode.MINMAX:
+                if (this._minValue == undefined)
+                    throw new Error(`ParamValues : valeur min non définie`);
+                if (this._maxValue == undefined)
+                    throw new Error(`ParamValues : valeur max non définie`);
+                if (this._stepValue == undefined)
+                    throw new Error(`ParamValues : valeur du pas non définie`);
+                if (this._minValue > this._maxValue)
+                    throw new Error(`ParamValues : min > max`);
+                break;
+
+            case ParamValueMode.LISTE:
+                if (this._valueList == undefined)
+                    throw new Error(`ParamValues : liste de valeurs non définie`);
+                break;
+
+            case ParamValueMode.CALCUL:
+                break;
+
+            default:
+                throw new Error(`ParamValues : mode de valeurs ${ParamValueMode[this._valueMode]} incorrect`);
+        }
+    }
+
     public get singleValue() {
         return this._singleValue.value;
     }
-- 
GitLab