@bluedot-innovation/models 5.1.27-alpha.2 → 5.1.27-alpha.4

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.
Files changed (2) hide show
  1. package/models/Zone.js +3 -6
  2. package/package.json +1 -1
package/models/Zone.js CHANGED
@@ -38,7 +38,7 @@ let customDataValidators = [
38
38
  ];
39
39
 
40
40
  const tagsFormation = (zone, next) => {
41
- zone.tags = [...new Set(zone.tags.map(tag => tag.toLowerCase()))]
41
+ zone.tags = [...new Set(zone.tags.map(tag => typeof tag === 'string' ? tag.toLowerCase() : tag))]
42
42
  next()
43
43
  }
44
44
 
@@ -140,7 +140,8 @@ zoneSchema.pre('validate', function(next) {
140
140
  new Promise((resolve, reject) => helpers.checkArrayContainsValidValues(this, ['geofeatures', 'actions', 'conditions', 'tags'], resolve)),
141
141
  new Promise((resolve, reject) => helpers.checkConditionsSuitableForBeacon(this, resolve)),
142
142
  new Promise((resolve, reject) => helpers.checkMinimumGeofeaturesValidForZone(this, resolve)),
143
- new Promise((resolve, reject) => helpers.validateTravelPathConditionCount(this, resolve))
143
+ new Promise((resolve, reject) => helpers.validateTravelPathConditionCount(this, resolve)),
144
+ new Promise((resolve, reject) => tagsFormation(this, next))
144
145
  ]).then(results => {
145
146
  for( let result of results ) {
146
147
  if( result )
@@ -150,10 +151,6 @@ zoneSchema.pre('validate', function(next) {
150
151
  }).catch((error) => console.log('Validation error ', error));
151
152
  })
152
153
 
153
- zoneSchema.pre('save', function (next) {
154
- tagsFormation(this, next)
155
- })
156
-
157
154
  // optional mongoose
158
155
  const model = (mongooseInstance) => {
159
156
  let Zone
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "5.1.27-alpha.2",
3
+ "version": "5.1.27-alpha.4",
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",