@justair/justair-library 3.3.4-lima → 3.3.4-november
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 +1 -1
- package/src/models/monitors.js +10 -22
package/package.json
CHANGED
package/src/models/monitors.js
CHANGED
|
@@ -14,29 +14,17 @@ const parametersEnum = [
|
|
|
14
14
|
"WS And Direction",
|
|
15
15
|
];
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
validator: function(v) {
|
|
22
|
-
return Object.keys(v).every(key => parametersEnum.includes(key)
|
|
23
|
-
);
|
|
24
|
-
},
|
|
25
|
-
message: props => `${props.value} is not a valid parameter threshold object`
|
|
26
|
-
}
|
|
17
|
+
const thresholdSchema = new mongoose.Schema({
|
|
18
|
+
invalid: {
|
|
19
|
+
min: Number,
|
|
20
|
+
max: Number
|
|
27
21
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
}
|
|
22
|
+
warning: {
|
|
23
|
+
min: Number,
|
|
24
|
+
max: Number
|
|
37
25
|
}
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
}, { _id: false });
|
|
27
|
+
|
|
40
28
|
|
|
41
29
|
// Monitors Schema
|
|
42
30
|
const monitorsSchema = mongoose.Schema(
|
|
@@ -110,7 +98,7 @@ const monitorsSchema = mongoose.Schema(
|
|
|
110
98
|
validate: {
|
|
111
99
|
validator: function(v) {
|
|
112
100
|
return Object.keys(v).every(key =>
|
|
113
|
-
|
|
101
|
+
parametersEnum.includes(key) &&
|
|
114
102
|
thresholdSchema.path('invalid.min').instance(v[key].invalid.min) &&
|
|
115
103
|
thresholdSchema.path('invalid.max').instance(v[key].invalid.max) &&
|
|
116
104
|
thresholdSchema.path('warning.min').instance(v[key].warning.min) &&
|