@justair/justair-library 3.3.4-hotel → 3.3.4-juliet

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justair/justair-library",
3
- "version": "3.3.4-hotel",
3
+ "version": "3.3.4-juliet",
4
4
  "description": "JustAir Internal Library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -19,7 +19,7 @@ const parameterThresholdsSchema = mongoose.Schema({
19
19
  type: mongoose.Schema.Types.Mixed,
20
20
  validate: {
21
21
  validator: function(v) {
22
- return Object.keys(v).every(key => pollutants.includes(key)
22
+ return Object.keys(v).every(key => pollutants.includes(key)
23
23
  );
24
24
  },
25
25
  message: props => `${props.value} is not a valid parameter threshold object`
@@ -27,6 +27,17 @@ const parameterThresholdsSchema = mongoose.Schema({
27
27
  },
28
28
  });
29
29
 
30
+ /*Ensure the parameter value is one of our valid parameters */
31
+ parameterThresholdsSchema.path('parameter').validate(function(value) {
32
+ console.log(value)
33
+ for (let key of value.keys()) {
34
+ if (!parametersEnum.includes(key)) {
35
+ return false;
36
+ }
37
+ }
38
+ return true;
39
+ }, 'Invalid parameter key');
40
+
30
41
  // Monitors Schema
31
42
  const monitorsSchema = mongoose.Schema(
32
43
  {
@@ -94,7 +105,7 @@ const monitorsSchema = mongoose.Schema(
94
105
  calculatedAverages: [Object],
95
106
  images: [String],
96
107
  isActive: { type: Boolean, default: true },
97
- parameterThresholds: Object
108
+ parameterThresholds: { type: Map, of: parameterThresholdsSchema },
98
109
  },
99
110
  {
100
111
  timestamps: true,