@bluedot-innovation/models 8.5.0 → 8.5.1

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
+ ## 8.5.1
2
+ - Add min and max limits to activeTtl and finalTtl
3
+
1
4
  ## 8.5.0
2
5
  - Add activeTtl and finalTtl to project.hello and remove registrationTtl
3
6
 
@@ -293,6 +293,47 @@ describe('Project', () => {
293
293
  })
294
294
  })
295
295
 
296
+ it('should not validate if hello.finalTtl is a negative', (done) => {
297
+ project.hello.finalTtl = -2
298
+ let Project = new ProjectModel(project)
299
+ Project.validate((err, res) => {
300
+ assert.exists(err)
301
+ assert.match(err.message, /finalTtl` \(-2\) is less than minimum allowed value \(0\)/)
302
+ done()
303
+ })
304
+ })
305
+
306
+ it('should not validate if hello.activeTtl is a negative', (done) => {
307
+ project.hello.activeTtl = -2
308
+ let Project = new ProjectModel(project)
309
+ Project.validate((err, res) => {
310
+ assert.exists(err)
311
+ assert.match(err.message, /activeTtl` \(-2\) is less than minimum allowed value \(0\)/)
312
+ done()
313
+ })
314
+ })
315
+
316
+ it('should not validate if hello.finalTtl is a greater than the maximum', (done) => {
317
+ project.hello.finalTtl = 1209601
318
+ let Project = new ProjectModel(project)
319
+ Project.validate((err, res) => {
320
+ console.log(err)
321
+ assert.exists(err)
322
+ assert.match(err.message, /finalTtl` \(1209601\) is more than maximum allowed value/)
323
+ done()
324
+ })
325
+ })
326
+
327
+ it('should not validate if hello.activeTtl is a greater than the maximum', (done) => {
328
+ project.hello.activeTtl = 1209601
329
+ let Project = new ProjectModel(project)
330
+ Project.validate((err, res) => {
331
+ assert.exists(err)
332
+ assert.match(err.message, /activeTtl` \(1209601\) is more than maximum allowed value/)
333
+ done()
334
+ })
335
+ })
336
+
296
337
  describe("webhook validation", () => {
297
338
  assertions(`should not validate if webhook protocol is not valid `, (done) => {
298
339
  project.webhooks[0].url = 'htt://test.com'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "8.5.0",
3
+ "version": "8.5.1",
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,8 +2,8 @@ let mongoose = require('mongoose')
2
2
  const helpers = require('../helpers')
3
3
 
4
4
  let ProjectHelloSchema = new mongoose.Schema({
5
- activeTtl: {type: Number, validate: { validator: Number.isInteger, msg: 'hello.activeTtl should be an integer number' }},
6
- finalTtl: {type: Number, validate: { validator: Number.isInteger, msg: 'hello.finalTtl should be an integer number' }},
5
+ activeTtl: {type: Number, min: 0, max: 1209600, validate: { validator: Number.isInteger, msg: 'hello.activeTtl should be an integer number' }},
6
+ finalTtl: {type: Number, min: 0, max: 1209600, validate: { validator: Number.isInteger, msg: 'hello.finalTtl should be an integer number' }},
7
7
  ssoLinkingCode: {type: String, validate: {validator: helpers.validateSsoLinkingCode, msg: 'SSO linking code must be a 12 character capital alphanumeric text'}}
8
8
  }, {
9
9
  _id: false