@bluedot-innovation/models 2.0.19 → 2.0.20
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/CHANGELOG.md +3 -0
- package/helpers.js +14 -0
- package/models/Zone.js +1 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/helpers.js
CHANGED
|
@@ -11,4 +11,18 @@ helpers.validateEmail = function (value) {
|
|
|
11
11
|
return regex.test(value);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
helpers.validateCustomData = function (data) {
|
|
15
|
+
const customDataKeys = Object.keys(data)
|
|
16
|
+
let hasValidationErrors = false
|
|
17
|
+
|
|
18
|
+
customDataKeys.forEach(key => {
|
|
19
|
+
const alphaNumericValidation = new RegExp(/^\w+$/)
|
|
20
|
+
if(!alphaNumericValidation.test(key)){
|
|
21
|
+
hasValidationErrors = true
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return !hasValidationErrors
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
module.exports = helpers
|
package/models/Zone.js
CHANGED
|
@@ -87,17 +87,7 @@ zoneSchema.path('geofeatures').discriminator('polygon', new Schema(polygonSchema
|
|
|
87
87
|
zoneSchema.path('geofeatures').discriminator('polyline', new Schema(polylineSchema))
|
|
88
88
|
zoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingBoxSchema))
|
|
89
89
|
|
|
90
|
-
zoneSchema.path('customData').validate(
|
|
91
|
-
const customDataKeys = Object.keys(data)
|
|
92
|
-
let hasValidationErrors = false
|
|
93
|
-
|
|
94
|
-
customDataKeys.forEach(key => {
|
|
95
|
-
const alphaNumericValidation = new RegExp(/^\w+$/)
|
|
96
|
-
hasValidationErrors = !alphaNumericValidation.test(key)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
return !hasValidationErrors
|
|
100
|
-
}, 'CustomData key should have alpha numeric and _ characters only')
|
|
90
|
+
zoneSchema.path('customData').validate(helpers.validateCustomData, 'CustomData key should have alpha numeric and _ characters only')
|
|
101
91
|
|
|
102
92
|
// optional mongoose
|
|
103
93
|
const model = (mongooseInstance) => {
|