@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 CHANGED
@@ -1,3 +1,6 @@
1
+ ## 2.0.20
2
+ - Added customData validation in helpers so that it can be imported in the UI
3
+
1
4
  ## 2.0.19
2
5
  - Added validations for keys in customData
3
6
 
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(function(data) {
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) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "2.0.19",
3
+ "version": "2.0.20",
4
4
  "description": "",
5
5
  "main": "Models.js",
6
6
  "scripts": {