@bluedot-innovation/models 2.0.21-alpha.3 → 2.0.21

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,7 @@
1
+ ## 2.0.22
2
+
3
+ - Allow 0 Major and Minor
4
+
1
5
  ## 2.0.21
2
6
 
3
7
  - Validation: Polygon needs 3 or more vertices
package/helpers.js CHANGED
@@ -20,29 +20,12 @@ helpers.validateCustomData = function (data) {
20
20
  let hasValidationErrors = false
21
21
 
22
22
  customDataKeys.forEach(key => {
23
- const alphaNumericValidation = new RegExp(/^[\w\s]+$/)
23
+ const alphaNumericValidation = new RegExp(/^\w+$/)
24
24
  if(!alphaNumericValidation.test(key)){
25
25
  hasValidationErrors = true
26
26
  }
27
27
  })
28
28
 
29
- const checkDuplicateKeys = [...new Set(customDataKeys)]
30
- if(customDataKeys.length > checkDuplicateKeys.length) {
31
- hasValidationErrors = true
32
- }
33
-
34
- return !hasValidationErrors
35
- }
36
-
37
- helpers.checkDuplicateKeys = function (data) {
38
- const customDataKeys = Object.keys(data)
39
- let hasValidationErrors = false
40
-
41
- const duplicateKeys = [...new Set(customDataKeys)]
42
- if(customDataKeys.length > duplicateKeys.length) {
43
- hasValidationErrors = true
44
- }
45
-
46
29
  return !hasValidationErrors
47
30
  }
48
31
 
package/models/Zone.js CHANGED
@@ -27,11 +27,6 @@ let helpers = require('../helpers')
27
27
  // Schema //
28
28
  // ////// //
29
29
 
30
- let customDataValidators = [
31
- {validator: helpers.validateCustomData, msg: 'CustomData key should have alpha numeric and _ characters only'},
32
- {validator: helpers.checkDuplicateKeys, msg: 'CustomData key should be unique'},
33
- ];
34
-
35
30
  let actionSchema = new Schema({},
36
31
  { discriminatorKey: 'type', _id: false })
37
32
 
@@ -66,7 +61,7 @@ let zoneSchema = new Schema({
66
61
  required: true
67
62
  },
68
63
  triggerOnExit: {type: Boolean, default: false},
69
- customData: {type: Schema.Types.Mixed, validate: customDataValidators},
64
+ customData: {type: Schema.Types.Mixed},
70
65
  creationTime: {type: Date, default: Date.now},
71
66
  lastUpdateTime: {type: Date, default: Date.now},
72
67
  projectId: {type: String, required: [true, 'projectId is required']},
@@ -92,6 +87,8 @@ zoneSchema.path('geofeatures').discriminator('polygon', new Schema(polygonSchema
92
87
  zoneSchema.path('geofeatures').discriminator('polyline', new Schema(polylineSchema))
93
88
  zoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingBoxSchema))
94
89
 
90
+ zoneSchema.path('customData').validate(helpers.validateCustomData, 'CustomData key should have alpha numeric and _ characters only')
91
+
95
92
  // optional mongoose
96
93
  const model = (mongooseInstance) => {
97
94
  let Zone
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "2.0.21-alpha.3",
3
+ "version": "2.0.21",
4
4
  "description": "",
5
5
  "main": "Models.js",
6
6
  "scripts": {