@bluedot-innovation/models 5.1.5 → 5.1.7

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
+ ## 5.1.7
2
+ - Added validations for Arrays with falsy values and strings as null
3
+
1
4
  ## 5.1.5
2
5
  - Added Test Management Portal models in Models.js
3
6
 
@@ -0,0 +1,26 @@
1
+ let chai = require('chai')
2
+ let assert = chai.assert
3
+
4
+ let helpers = {}
5
+
6
+ helpers.testFalsyValue = (falsyValue, arrayField, docObject, model, callback) => {
7
+ docObject = JSON.parse(JSON.stringify(docObject))
8
+ docObject[arrayField] = [falsyValue]
9
+ const Model = new model(docObject)
10
+ Model.validate((err, res) => {
11
+ assert.exists(err)
12
+ assert(err instanceof Error, "Should throw error.")
13
+ callback()
14
+ })
15
+ }
16
+
17
+ helpers.testNullValue = (docObject, model, callback) => {
18
+ let Model = new model(docObject)
19
+ Model.validate((err, res) => {
20
+ assert.exists(err, 'err object should exist')
21
+ assert(err instanceof Error, "Should throw error.")
22
+ callback()
23
+ })
24
+ }
25
+
26
+ module.exports = helpers
@@ -5,5 +5,6 @@
5
5
  {"name": "lastUpdateTime", "invalidInput": ["21/07/2017", "saturday"]},
6
6
  {"name": "creationTime", "invalidInput": ["21/07/2017", "thursday"]},
7
7
  {"name": "accountId", "invalidInput": ["21/07/2017", 21072017, "qwe123-21321-ad"]}
8
- ]
8
+ ],
9
+ "arrayTypeFields": ["webhooks"]
9
10
  }
@@ -11,6 +11,8 @@ let assert = chai.assert
11
11
  let mocha = require('mocha')
12
12
  let beforeEach = mocha.beforeEach
13
13
  let rules = require('./project.rules.json')
14
+ let helpers = require('../helpers')
15
+ let { FALSY_VALUES } = require('../../constants/tests')
14
16
 
15
17
  let project
16
18
 
@@ -96,5 +98,29 @@ testCase('Project', () => {
96
98
  })
97
99
  })
98
100
  })
101
+
102
+ it(`should trow an error when webhooks is null`, (done) => {
103
+ project = JSON.parse(JSON.stringify(project))
104
+ project.webhooks = null
105
+ helpers.testNullValue(project, ProjectModel, done)
106
+ })
107
+
108
+ it(`should trow an error when firebaseApiKey is null`, (done) => {
109
+ project = JSON.parse(JSON.stringify(project))
110
+ project.firebaseApiKey = null
111
+ helpers.testNullValue(project, ProjectModel, done)
112
+ })
113
+
114
+ describe('should throw an error when any of the values of the array contains a falsy value', () => {
115
+ let arrayTypeFields = rules.arrayTypeFields
116
+
117
+ arrayTypeFields.map(arrayField => {
118
+ FALSY_VALUES.map(falsyValue => {
119
+ it(`should trow an error when it contains ${falsyValue} on a ${arrayField}`, (done) => {
120
+ helpers.testFalsyValue(falsyValue, arrayField, project, ProjectModel, done)
121
+ })
122
+ })
123
+ })
124
+ })
99
125
  })
100
126
  })
@@ -4,5 +4,6 @@ module.exports = {
4
4
  {name: 'phoneNumber', invalidInputs: ['409203492039284232034398']},
5
5
  {name: 'creationTime', invalidInputs: ['21/07/2017', 'thursday']},
6
6
  {name: 'lastUpdateTime', invalidInputs: ['21/07/2017', 'saturday']}
7
- ]
7
+ ],
8
+ arrayTypeFields: ["projectPermissions"]
8
9
  }
@@ -9,6 +9,8 @@ let chai = require('chai')
9
9
  let assert = chai.assert
10
10
  let mocha = require('mocha')
11
11
  let beforeEach = mocha.beforeEach
12
+ let helpers = require('../helpers')
13
+ let { FALSY_VALUES } = require('../../constants/tests')
12
14
 
13
15
  let user
14
16
 
@@ -127,4 +129,17 @@ describe('User', () => {
127
129
  })
128
130
  })
129
131
  })
132
+
133
+ describe('should throw an error when any of the values of the array contains a falsy value', () => {
134
+ let arrayTypeFields = rules.arrayTypeFields
135
+
136
+ arrayTypeFields.map(arrayField => {
137
+ FALSY_VALUES.map(falsyValue => {
138
+ it(`should trow an error when it contains ${falsyValue} on a ${arrayField}`, (done) => {
139
+ helpers.testFalsyValue(falsyValue, arrayField, user, UserModel, done)
140
+ })
141
+ })
142
+ })
143
+ })
144
+
130
145
  })
@@ -23,4 +23,4 @@ describe('trimDecimals(num, n)', () => {
23
23
  assert(isCorrect);
24
24
  })
25
25
  })
26
- })
26
+ })
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "TDD zone",
3
3
  "minimumRetriggerTime": "60",
4
- "checkout": true,
4
+ "triggerOnExit": true,
5
5
  "lastUpdateTime": "2018-02-14T04:12:02.103Z",
6
6
  "creationTime": "2018-02-14T04:12:02.103Z",
7
7
  "projectId": "c7058934-f1e6-4176-8730-a0bd28e8e0a9",
@@ -0,0 +1,4 @@
1
+ {
2
+ "arrayTypeFields": ["geofeatures", "conditions", "actions"]
3
+ }
4
+
@@ -2,7 +2,9 @@ let mongoose = require('mongoose')
2
2
  mongoose.Promise = global.Promise
3
3
  let chai = require('chai')
4
4
  let assert = chai.assert
5
-
5
+ let rules = require('./zone.rules.json')
6
+ let helpers = require('../helpers')
7
+ let { FALSY_VALUES } = require('../../constants/tests')
6
8
 
7
9
  let ZoneModel = require('../../Models').Zone(mongoose)
8
10
  let ZoneModelBuiltInMongoose = require('../../Models').Zone()
@@ -72,6 +74,17 @@ describe('Zone', () => {
72
74
  done()
73
75
  })
74
76
  })
77
+
78
+ it('should set triggerOnExit default and save without errors', (done) => {
79
+ delete zone.triggerOnExit
80
+
81
+ let Zone = new ZoneModel(zone)
82
+ Zone.validate((err, res) => {
83
+ assert.notExists(res)
84
+ assert(err === null, 'err equals null')
85
+ done()
86
+ })
87
+ })
75
88
  })
76
89
 
77
90
  describe('Invalid Zone ', () => {
@@ -107,12 +120,106 @@ describe('Zone', () => {
107
120
  })
108
121
  })
109
122
 
110
- it('should throw an error when validating an invalid customData key ', (done) => {
111
- zone.customData["name#3"] = "A Custom action3"
123
+ it('should throw an error when custom data is null', (done) => {
124
+ zone.customData = null
125
+ let Zone = new ZoneModel(zone)
126
+ Zone.validate((err, res) => {
127
+ assert.exists(err, 'err object should exist')
128
+ assert.isObject(err)
129
+ assert.match(err.message, /Zone validation failed: customData/i)
130
+ done()
131
+ })
132
+ })
133
+
134
+ it('should throw an error when custom data is undefined', (done) => {
135
+ zone.customData = undefined
136
+ let Zone = new ZoneModel(zone)
137
+ Zone.validate((err, res) => {
138
+ assert.notExists(err, 'err is neither `null` nor `undefined`')
139
+ assert(err === null, 'err equals null')
140
+ done()
141
+ })
142
+ })
143
+
144
+ it('should throw an error when custom data is not an object', (done) => {
145
+ zone.customData = 1
112
146
  let Zone = new ZoneModel(zone)
113
147
  Zone.validate((err, res) => {
114
148
  assert.exists(err, 'err object should exist')
115
149
  assert.isObject(err)
150
+ assert.match(err.message, /Zone validation failed: customData/i)
151
+ done()
152
+ })
153
+ })
154
+
155
+ it('should throw an error if CustomData key does not have alpha numeric and _ characters only ', (done) => {
156
+ zone.customData["name#3"] = "A Custom action"
157
+ let Zone = new ZoneModel(zone)
158
+ Zone.validate((err, res) => {
159
+ assert.match(err.message, /(CustomData key should have alpha numeric and _ characters only)/i);
160
+ done()
161
+ })
162
+ })
163
+
164
+ it('should throw an error if custom data keys count is greater than 5 ', (done) => {
165
+ zone.customData["name3"] = true;
166
+ zone.customData["name4"] = 1;
167
+ zone.customData["name5"] = "Action value 5";
168
+ zone.customData["name6"] = "Action Value 6";
169
+
170
+ let Zone = new ZoneModel(zone)
171
+ Zone.validate((err, res) => {
172
+ assert.match(err.message, /(Only 5 custom data fields are allowed to be added per zone)/i)
173
+ done()
174
+ })
175
+ })
176
+
177
+ it('should throw an error if CustomData value is null ', (done) => {
178
+ zone.customData["name3"] = null;
179
+
180
+ let Zone = new ZoneModel(zone)
181
+ Zone.validate((err, res) => {
182
+ assert.match(err.message, /(CustomData value should not be empty)/i);
183
+ done()
184
+ })
185
+ })
186
+
187
+ it('should throw an error if CustomData value is undefined ', (done) => {
188
+ zone.customData["name3"] = undefined;
189
+
190
+ let Zone = new ZoneModel(zone)
191
+ Zone.validate((err, res) => {
192
+ assert.match(err.message, /(CustomData value should not be empty)/i);
193
+ done()
194
+ })
195
+ })
196
+
197
+ it('should throw an error if CustomData value is an empty string ', (done) => {
198
+ zone.customData["name3"] = ' ';
199
+
200
+ let Zone = new ZoneModel(zone)
201
+ Zone.validate((err, res) => {
202
+ assert.match(err.message, /(CustomData value should not be empty)/i);
203
+ done()
204
+ })
205
+ })
206
+
207
+ it('should throw an error if CustomData value is an empty object ', (done) => {
208
+ zone.customData["name3"] = {};
209
+
210
+ let Zone = new ZoneModel(zone)
211
+ Zone.validate((err, res) => {
212
+ assert.match(err.message, /(CustomData value should not be empty)/i);
213
+ done()
214
+ })
215
+ })
216
+
217
+ it('should throw an error if CustomData value is an empty array ', (done) => {
218
+ zone.customData["name3"] = [];
219
+
220
+ let Zone = new ZoneModel(zone)
221
+ Zone.validate((err, res) => {
222
+ assert.match(err.message, /(CustomData value should not be empty)/i);
116
223
  done()
117
224
  })
118
225
  })
@@ -136,5 +243,27 @@ describe('Zone', () => {
136
243
  done()
137
244
  })
138
245
  })
246
+
247
+ it('should throw an error when triggerOnExit is null', (done) => {
248
+ zone.triggerOnExit = null
249
+ helpers.testNullValue(zone, ZoneModel, done)
250
+ })
251
+
252
+ it('should throw an error when tags is null', (done) => {
253
+ zone.tags = null
254
+ helpers.testNullValue(zone, ZoneModel, done)
255
+ })
256
+
257
+ describe('should throw an error when any of the values of the array contains a falsy value', () => {
258
+ let arrayTypeFields = rules.arrayTypeFields
259
+
260
+ arrayTypeFields.map(arrayField => {
261
+ FALSY_VALUES.map(falsyValue => {
262
+ it(`should trow an error when it contains ${falsyValue} on a ${arrayField}`, (done) => {
263
+ helpers.testFalsyValue(falsyValue, arrayField, zone, ZoneModel, done)
264
+ })
265
+ })
266
+ })
267
+ })
139
268
  })
140
269
  })
@@ -0,0 +1 @@
1
+ exports.FALSY_VALUES = [null, false, NaN, "", undefined]
package/helpers.js CHANGED
@@ -19,34 +19,65 @@ helpers.threeOrMoreVertices = function(vertices) {
19
19
  }
20
20
 
21
21
  helpers.validateCustomData = function (data) {
22
- const customDataKeys = Object.keys(data)
23
- let hasValidationErrors = false
24
-
25
- customDataKeys.forEach(key => {
26
- const alphaNumericValidation = new RegExp(/^[\w\s]+$/)
27
- if(!alphaNumericValidation.test(key)){
28
- hasValidationErrors = true
29
- }
30
- })
31
22
 
32
- const checkDuplicateKeys = [...new Set(customDataKeys)]
33
- if(customDataKeys.length > checkDuplicateKeys.length) {
34
- hasValidationErrors = true
23
+ if(!isValidObject(data)){
24
+ return false
35
25
  }
36
26
 
37
- return !hasValidationErrors
27
+ const customDataKeys = Object.keys(data)
28
+ const alphaNumericValidation = new RegExp(/^[\w\s]+$/)
29
+ return customDataKeys.every(key => {
30
+ return alphaNumericValidation.test(key)
31
+ });
38
32
  }
39
33
 
40
34
  helpers.checkDuplicateKeys = function (data) {
41
- const customDataKeys = Object.keys(data)
42
- let hasValidationErrors = false
43
35
 
36
+ if(!isValidObject(data)){
37
+ return false
38
+ }
39
+
40
+ const customDataKeys = Object.keys(data);
44
41
  const duplicateKeys = [...new Set(customDataKeys)]
45
- if(customDataKeys.length > duplicateKeys.length) {
46
- hasValidationErrors = true
42
+ return !(customDataKeys.length > duplicateKeys.length)
43
+ }
44
+
45
+
46
+ /**
47
+ * helper function to validate valid custom data value is not empty
48
+ *
49
+ * @remarks
50
+ * ensures that data is an object
51
+ * ensures data.key is valid (`not null, not undefined, not {}, not [], not empty String`)
52
+ *
53
+ * @param data
54
+ * @returns boolean
55
+ */
56
+ helpers.isCustomDataValuesNotEmpty = function (data) {
57
+
58
+ if(!isValidObject(data)){
59
+ return false
47
60
  }
48
61
 
49
- return !hasValidationErrors
62
+ const customDataValues = Object.values(data)
63
+
64
+ return customDataValues.every(value => {
65
+ //not empty String
66
+ if(typeof value === 'string' && value.trim().length == 0) return false
67
+
68
+ // not null, not undefined, not {}, not []
69
+ return (value !== null && value !== undefined && JSON.stringify(value) !== '{}' && JSON.stringify(value) !== '[]')
70
+ })
71
+ }
72
+
73
+ helpers.isValidCustomDataCount = function (data) {
74
+
75
+ if(!isValidObject(data)){
76
+ return false
77
+ }
78
+ const customDataKeysSize = Object.keys(data).length;
79
+
80
+ return !(customDataKeysSize > 5)
50
81
  }
51
82
 
52
83
  helpers.checkIsDifferent = function(propertyName) {
@@ -65,6 +96,8 @@ helpers.checkConditionsSuitableForBeacon = function(zone, next) {
65
96
  let hasBeacons = false;
66
97
  if( zone.geofeatures && zone.geofeatures.length ) {
67
98
  for( let geofeature of zone.geofeatures ) {
99
+ if(!geofeature) return next(new Error("Geofeature must have a type"))
100
+
68
101
  if( geofeature.type === "beacon" ) {
69
102
  hasBeacons = true;
70
103
  break;
@@ -76,6 +109,7 @@ helpers.checkConditionsSuitableForBeacon = function(zone, next) {
76
109
  if( !zone.conditions || !zone.conditions.length )
77
110
  return next(); // No conditions.
78
111
  for( let condition of zone.conditions ) {
112
+ if( !condition ) return next(new Error("Condition must have a valid value"))
79
113
  if( condition.type === "travelDirection" ) {
80
114
  return next(new Error("Zone cannot both contain a beacon and have a Travel Direction condition."))
81
115
  }
@@ -92,6 +126,7 @@ helpers.checkMinimumGeofeaturesValidForZone = function(zone, next) {
92
126
  if( !zone.conditions || !zone.conditions.length )
93
127
  return next(); // No conditions.
94
128
  for( let condition of zone.conditions ) {
129
+ if( !condition ) return next(new Error("Condition must have a valid value"))
95
130
  if( condition.type === "travelPath" && condition.minimumGeofeaturesCrossed > zone.geofeatures.length ) {
96
131
  return next(new Error("Zone must not have minimumGeofeaturesCrossed higher than geofeatures count"))
97
132
  }
@@ -108,10 +143,34 @@ helpers.validateTravelPathConditionCount = function(zone, next) {
108
143
  let numberOfTravelPathConditions = 0
109
144
 
110
145
  for( let condition of zone.conditions ) {
146
+ if( !condition ) return next(new Error("Condition must have a valid value"))
111
147
  if( condition.type === "travelPath" ) numberOfTravelPathConditions ++
112
- if ( numberOfTravelPathConditions > 1 ) return next(new Error("Zone must not have more than 1 travel path condition"))
148
+ if( numberOfTravelPathConditions > 1 ) return next(new Error("Zone must not have more than 1 travel path condition"))
113
149
  }
114
150
  next();
115
151
  }
116
152
 
153
+ helpers.checkArrayContainsValidValues = function(document, properties, next) {
154
+ properties.forEach(property => {
155
+ if(document[property] && document[property].length) {
156
+ for(let item of document[property]) {
157
+ if(!Boolean(item)) {
158
+ return next(new Error(`${property} must have a value`))
159
+ }
160
+ }
161
+ }
162
+ })
163
+
164
+ return next()
165
+ }
166
+
167
+ helpers.validateNotNull = function(value) {
168
+ return value !== null
169
+ }
170
+
171
+ const isValidObject = data => {
172
+ // data not null, not undefined, must be an object
173
+ return !(data === null || typeof data === 'undefined'|| data.constructor !== Object)
174
+ }
175
+
117
176
  module.exports = helpers
package/models/Beacon.js CHANGED
@@ -4,11 +4,12 @@ const patcher = require('@bluedot-innovation/mongoose-json-patch')
4
4
  const Point = require('../schemas/Point')
5
5
  const mongoose = require('mongoose')
6
6
  const uuidv4 = require('uuid/v4')
7
+ const helpers = require('../helpers')
7
8
 
8
9
  let schema = {
9
10
  _id: {type: String, default: uuidv4},
10
11
  name: {type: String, required: [true, 'name is required.']},
11
- description: {type: String, default: ''},
12
+ description: {type: String, default: '', require: true},
12
13
  creationTime: {type: Date, default: Date.now},
13
14
  lastUpdateTime: {type: Date, default: Date.now},
14
15
  state: {type: String, default: StateEnum.active},
@@ -28,9 +29,9 @@ let schema = {
28
29
  // These must be unique
29
30
  major: {type: Number, validate: [{validator: validateMajorMinor, msg: 'Major needs to be within range(0-65535)'}]},
30
31
  minor: {type: Number, validate: [{validator: validateMajorMinor, msg: 'Minor needs to be within range(0-65535)'}]},
31
- txPower: {type: Number},
32
- macAddress: {type: String},
33
- proximityUUID: {type: String}
32
+ txPower: {type: Number, validate: helpers.validateNotNull},
33
+ macAddress: {type: String, validate: helpers.validateNotNull},
34
+ proximityUUID: {type: String, validate: helpers.validateNotNull}
34
35
  }
35
36
 
36
37
  let BeaconSchema = new mongoose.Schema(schema, {collection: 'beacon', autoIndex: false})
package/models/Project.js CHANGED
@@ -32,18 +32,30 @@ let ProjectSchema = new mongoose.Schema({
32
32
  lastSyncTime: {type: Date, default: Date.now},
33
33
  name: {type: String, required: [true, 'name is required']},
34
34
  accountId: {type: String, required: true, validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'default error message'}},
35
- webhooks: [WebhookSchema],
35
+ webhooks: {type:[WebhookSchema], validate: helpers.validateNotNull},
36
36
  configurationParameters: {
37
37
  iosConfig: iosConfig, // when we want to enable this {type: iosConfig, required: true}
38
38
  androidConfig: androidConfig, // when we want to enable this {type: androidConfig, required: true}
39
39
  }, // http://collab.bluedot.io/display/PD/Remote+configuration => https://bluedotinnovation.atlassian.net/wiki/spaces/ENG/pages/223150126/Remote+Config+details
40
- firebaseApiKey: {type: String},
40
+ firebaseApiKey: {type: String, validate: helpers.validateNotNull},
41
41
  apiKey: {type: String}
42
42
  },
43
43
  {collection: 'project'})
44
44
 
45
45
  ProjectSchema.plugin(patcher)
46
46
 
47
+ ProjectSchema.pre('validate', function(next) {
48
+ Promise.all([
49
+ new Promise((resolve, reject) => helpers.checkArrayContainsValidValues(this, ['webhooks'], resolve)),
50
+ ]).then(results => {
51
+ for( let result of results ) {
52
+ if( result )
53
+ return next(result)
54
+ }
55
+ next()
56
+ }).catch(console.log);
57
+ })
58
+
47
59
  // optional mongoose
48
60
  let model = (mongooseInstance) => {
49
61
  let Project
package/models/User.js CHANGED
@@ -28,13 +28,13 @@ let UserSchema = new mongoose.Schema({
28
28
  },
29
29
  firstName: {type: String, required: true},
30
30
  lastName: {type: String, required: true},
31
- phoneNumber: {type: String, maxlength: 20},
31
+ phoneNumber: {type: String, maxlength: 20, validate: helpers.validateNotNull},
32
32
  state: {type: String, default: StateEnum.active},
33
33
  creationTime: {type: Date, default: Date.now},
34
34
  lastUpdateTime: {type: Date, default: Date.now},
35
35
  isAdmin: {type: Boolean, required: true},
36
36
  secret: String,
37
- projectPermissions: [ProjectPermission],
37
+ projectPermissions: {type: [ProjectPermission], validate: helpers.validateNotNull},
38
38
  accountId: {
39
39
  type: String,
40
40
  required: true,
@@ -45,6 +45,18 @@ let UserSchema = new mongoose.Schema({
45
45
 
46
46
  UserSchema.plugin(patcher)
47
47
 
48
+ UserSchema.pre('validate', function(next) {
49
+ Promise.all([
50
+ new Promise((resolve, reject) => helpers.checkArrayContainsValidValues(this, ['projectPermissions'], resolve)),
51
+ ]).then(results => {
52
+ for( let result of results ) {
53
+ if( result )
54
+ return next(result)
55
+ }
56
+ next()
57
+ }).catch(console.log);
58
+ })
59
+
48
60
  // optional mongoose
49
61
  let model = (mongooseInstance) => {
50
62
  let User
package/models/Zone.js CHANGED
@@ -33,6 +33,8 @@ let helpers = require('../helpers')
33
33
  let customDataValidators = [
34
34
  {validator: helpers.validateCustomData, msg: 'CustomData key should have alpha numeric and _ characters only'},
35
35
  {validator: helpers.checkDuplicateKeys, msg: 'CustomData key should be unique'},
36
+ {validator: helpers.isCustomDataValuesNotEmpty, msg: 'CustomData value should not be empty'},
37
+ {validator: helpers.isValidCustomDataCount, msg: 'Only 5 custom data fields are allowed to be added per zone'}
36
38
  ];
37
39
 
38
40
  let actionSchema = new Schema({},
@@ -57,7 +59,7 @@ let zoneSchema = new Schema({
57
59
  message: '{VALUE} is not a number'
58
60
  }
59
61
  },
60
- tags: {type: [String]},
62
+ tags: {type: [String], validate: helpers.validateNotNull},
61
63
  conditions: {
62
64
  type: [conditionSchema]
63
65
  },
@@ -68,11 +70,13 @@ let zoneSchema = new Schema({
68
70
  type: [geofeatureSchema],
69
71
  required: true
70
72
  },
71
- triggerOnExit: {type: Boolean, default: false},
73
+ // To prevent saving `null` we use `required: true`
74
+ // https://github.com/Automattic/mongoose/issues/6034#issuecomment-362112268
75
+ triggerOnExit: {type: Boolean, default: false, required: true},
72
76
  customData: {type: Schema.Types.Mixed, validate: customDataValidators},
73
77
  creationTime: {type: Date, default: Date.now},
74
78
  lastUpdateTime: {type: Date, default: Date.now},
75
- projectId: {type: String, required: [true, 'projectId is required']},
79
+ projectId: {type: String, required: true},
76
80
  state: {type: String, default: StateEnum.active, select: false},
77
81
  accountId: {type: String, required: true, validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'default error message'}}
78
82
  }, {collection: 'zone'})
@@ -99,6 +103,7 @@ zoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingB
99
103
 
100
104
  zoneSchema.pre('validate', function(next) {
101
105
  Promise.all([
106
+ new Promise((resolve, reject) => helpers.checkArrayContainsValidValues(this, ['geofeatures', 'actions', 'conditions', 'tags'], resolve)),
102
107
  new Promise((resolve, reject) => helpers.checkConditionsSuitableForBeacon(this, resolve)),
103
108
  new Promise((resolve, reject) => helpers.checkMinimumGeofeaturesValidForZone(this, resolve)),
104
109
  new Promise((resolve, reject) => helpers.validateTravelPathConditionCount(this, resolve))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "5.1.5",
3
+ "version": "5.1.7",
4
4
  "main": "Models.js",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",