Jelajahi Sumber

Ajout champ validate pour activer ou non la validation des données

Arthur Brandao 5 tahun lalu
induk
melakukan
3aa41855cf
2 mengubah file dengan 7 tambahan dan 2 penghapusan
  1. 2 1
      node/config.json
  2. 5 1
      node/src/config.js

+ 2 - 1
node/config.json

@@ -4,5 +4,6 @@
   "findPort": true,
   "basePort": 8000,
   "highestPort": 65535,
-  "https": false
+  "https": false,
+  "validate": true
 }

+ 5 - 1
node/src/config.js

@@ -5,7 +5,7 @@ const path = './config.json';
 
 // Verif que le fichier de config existe
 if (!fs.existsSync(path)) {
-    throw "Config file not found";
+    throw 'Config file not found';
 }
 
 // Lecture du fichier
@@ -25,6 +25,8 @@ if (config.storage === undefined) {
     throw 'highestPort undefined in the config file';
 } else if (config.https === undefined) {
     throw 'https undefined in the config file';
+} else if (config.validate === undefined) {
+    throw 'validate undefined in the config file';
 }
 
 //Verification valeur
@@ -40,6 +42,8 @@ if (config.storage !== 'database' && config.storage !== 'file') {
     throw 'Bad value for highestPort: number between 0 and 65535 and higher than or equal basePort expected';
 } else if (typeof config.https !== 'boolean') {
     throw 'Bad value for https: boolean expected';
+} else if (typeof config.validate !== 'boolean') {
+    throw 'Bad value for validate: boolean expected';
 }
 
 module.exports = config;