@bluedot-innovation/models 6.2.4 → 6.2.5

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
+ ## 6.2.5
2
+ - Add `tempo.isochroneBracketInterval` to Project
3
+
1
4
  ## 6.2.4
2
5
  - Remove disableBackgroundLocation
3
6
  - Add heartbeat interval
@@ -271,6 +271,16 @@ testCase('Project', () => {
271
271
  helpers.testNullValue(project, ProjectModel, done)
272
272
  })
273
273
 
274
+ it('should not validate if tempo.isochroneBracketInterval contains items other than integer', (done) => {
275
+ project.tempo.isochroneBracketInterval = [900, 600, 1.5, 120]
276
+ let Project = new ProjectModel(project)
277
+ Project.validate((err, res) => {
278
+ assert.exists(err)
279
+ assert.match(err.message, /tempo.isochroneBracketInterval should contain integer numbers only/)
280
+ done()
281
+ })
282
+ })
283
+
274
284
  describe('should throw an error when any of the values of the array contains a falsy value', () => {
275
285
  let arrayTypeFields = rules.arrayTypeFields
276
286
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "6.2.4",
3
+ "version": "6.2.5",
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",
@@ -2,13 +2,22 @@ let mongoose = require('mongoose')
2
2
  let WebhookSchema = require('./Webhook')
3
3
  let helpers = require('../helpers')
4
4
 
5
+ function validateIsochroneBracketInterval (brackets) {
6
+ const isInteger = brackets.every((bracket) => {
7
+ return Number.isInteger(bracket)
8
+ })
9
+
10
+ return isInteger
11
+ }
12
+
5
13
  let webhooksValidators = [
6
14
  {validator: helpers.validateNotNull},
7
15
  {validator: helpers.validateTempoWebhooks, msg: 'tempo.webhooks should contain tempo webhooks only'}
8
16
  ];
9
17
 
10
18
  let ProjectTempoSchema = new mongoose.Schema({
11
- webhooks: {type:[WebhookSchema], validate: webhooksValidators}
19
+ webhooks: {type:[WebhookSchema], validate: webhooksValidators},
20
+ isochroneBracketInterval: {type: [Number], validate: { validator: validateIsochroneBracketInterval, msg: 'tempo.isochroneBracketInterval should contain integer numbers only' }}
12
21
  }, {
13
22
  _id: false
14
23
  })