@bluedot-innovation/models 6.0.4 → 6.0.8
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 +9 -0
- package/__tests__/user/user.rules.js +3 -1
- package/__tests__/zone/zone.spec.js +5 -6
- package/helpers.js +1 -1
- package/models/Account.js +2 -1
- package/models/User.js +3 -3
- package/models/Zone.js +1 -1
- package/package.json +1 -1
- package/schemas/AccountFeatures.js +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
requiredFields: ['username', 'firstName', 'lastName', 'isAdmin', 'accountId'],
|
|
3
3
|
customValidators: [
|
|
4
|
-
{name: 'phoneNumber', invalidInputs: ['409203492039284232034398']},
|
|
4
|
+
{name: 'phoneNumber', invalidInputs: ['409203492039284232034398','1','1234']},
|
|
5
|
+
{name: 'firstName', invalidInputs: ['F']},
|
|
6
|
+
{name: 'lastName', invalidInputs: ['L']},
|
|
5
7
|
{name: 'creationTime', invalidInputs: ['21/07/2017', 'thursday']},
|
|
6
8
|
{name: 'lastUpdateTime', invalidInputs: ['21/07/2017', 'saturday']}
|
|
7
9
|
],
|
|
@@ -236,15 +236,14 @@ describe('Zone', () => {
|
|
|
236
236
|
})
|
|
237
237
|
})
|
|
238
238
|
|
|
239
|
-
it('should throw an error if custom data keys count is greater than
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
zone.customData["name6"] = "Action Value 6";
|
|
239
|
+
it('should throw an error if custom data keys count is greater than 20 ', (done) => {
|
|
240
|
+
for (let i = 0; i <= 21; i++) {
|
|
241
|
+
zone.customData[`key${i}`] = `value ${i}`
|
|
242
|
+
}
|
|
244
243
|
|
|
245
244
|
let Zone = new ZoneModel(zone)
|
|
246
245
|
Zone.validate((err, res) => {
|
|
247
|
-
assert.match(err.message, /(Only
|
|
246
|
+
assert.match(err.message, /(Only 20 custom data fields are allowed to be added per zone)/i)
|
|
248
247
|
done()
|
|
249
248
|
})
|
|
250
249
|
})
|
package/helpers.js
CHANGED
package/models/Account.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
let mongoose = require('mongoose')
|
|
7
7
|
// let Schema = mongoose.Schema
|
|
8
8
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
9
|
+
let accountFeatures = require('../schemas/AccountFeatures')
|
|
9
10
|
let uuidv4 = require('uuid/v4')
|
|
10
11
|
let patcher = require('@bluedot-innovation/mongoose-json-patch')
|
|
11
12
|
const helpers = require('../helpers')
|
|
@@ -26,7 +27,7 @@ let AccountSchema = new mongoose.Schema({
|
|
|
26
27
|
state: {type: String, default: StateEnum.ACTIVE},
|
|
27
28
|
poiCredits: Number,
|
|
28
29
|
integrations: Object,
|
|
29
|
-
features:
|
|
30
|
+
features: accountFeatures,
|
|
30
31
|
creationTime: {type: Date, default: Date.now},
|
|
31
32
|
lastUpdateTime: {type: Date, default: Date.now}
|
|
32
33
|
},
|
package/models/User.js
CHANGED
|
@@ -26,9 +26,9 @@ let UserSchema = new mongoose.Schema({
|
|
|
26
26
|
message: '{VALUE} is not a valid email'
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
firstName: {type: String, required: true},
|
|
30
|
-
lastName: {type: String, required: true},
|
|
31
|
-
phoneNumber: {type: String, maxlength: 20, validate: helpers.validateNotNull},
|
|
29
|
+
firstName: {type: String, required: true, minlength:2, maxlength:120},
|
|
30
|
+
lastName: {type: String, required: true, minlength:2, maxlength:120},
|
|
31
|
+
phoneNumber: {type: String, minlength:8, 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},
|
package/models/Zone.js
CHANGED
|
@@ -34,7 +34,7 @@ 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
36
|
{validator: helpers.isCustomDataValuesNotEmpty, msg: 'CustomData value should not be empty'},
|
|
37
|
-
{validator: helpers.isValidCustomDataCount, msg: 'Only
|
|
37
|
+
{validator: helpers.isValidCustomDataCount, msg: 'Only 20 custom data fields are allowed to be added per zone'}
|
|
38
38
|
];
|
|
39
39
|
|
|
40
40
|
const tagsFormation = (zone) => {
|
package/package.json
CHANGED