@bluedot-innovation/models 5.1.19 → 5.1.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
+ ## 5.1.20
2
+ - Validate projectId when posting a zone
3
+
1
4
  ## 5.1.19
2
5
  - Lowercase incoming tags and remove duplicates
3
6
 
@@ -266,6 +266,16 @@ describe('Zone', () => {
266
266
  helpers.testNullValue(zone, ZoneModel, done)
267
267
  })
268
268
 
269
+ it('should throw an error when projectId is invalid', (done) => {
270
+ zone.projectId = "invalid id"
271
+ let Zone = new ZoneModel(zone)
272
+ Zone.validate((err, res) => {
273
+ assert.exists(err, 'err object should exist')
274
+ assert.match(err.message, /(Invalid Project Id)/i)
275
+ done()
276
+ })
277
+ })
278
+
269
279
  describe('should throw an error when any of the values of the array contains a falsy value', () => {
270
280
  let arrayTypeFields = rules.arrayTypeFields
271
281
 
package/models/Zone.js CHANGED
@@ -80,7 +80,7 @@ let zoneSchema = new Schema({
80
80
  customData: {type: Schema.Types.Mixed, validate: customDataValidators},
81
81
  creationTime: {type: Date, default: Date.now},
82
82
  lastUpdateTime: {type: Date, default: Date.now},
83
- projectId: {type: String, required: true},
83
+ projectId: {type: String, required: true, validate: {validator: helpers.validateUUIDv4, message: 'Invalid Project Id.'}},
84
84
  state: {type: String, default: StateEnum.ACTIVE, select: false},
85
85
  accountId: {type: String, required: true, validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'default error message'}}
86
86
  }, {collection: 'zone'})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "5.1.19",
3
+ "version": "5.1.20",
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",