@bluedot-innovation/models 9.0.0 → 9.0.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
|
@@ -869,7 +869,22 @@ describe('Project', () => {
|
|
|
869
869
|
let Project = new ProjectModel(project)
|
|
870
870
|
Project.validate((err, res) => {
|
|
871
871
|
assert.exists(err)
|
|
872
|
-
assert.match(err.message, /
|
|
872
|
+
assert.match(err.message, /Multiple reports of the same type are not allowed/)
|
|
873
|
+
done()
|
|
874
|
+
})
|
|
875
|
+
})
|
|
876
|
+
|
|
877
|
+
it('Should be successfull when there are multiple report types per project', (done) => {
|
|
878
|
+
project.reportConfigurations.push({
|
|
879
|
+
"type": "geo-trigger",
|
|
880
|
+
"frequency": "monthly",
|
|
881
|
+
"reportDay": 1,
|
|
882
|
+
"timezone": "Australia/Sydney",
|
|
883
|
+
"recipients": "xyz@example.com"
|
|
884
|
+
})
|
|
885
|
+
let Project = new ProjectModel(project)
|
|
886
|
+
Project.validate((err, res) => {
|
|
887
|
+
assert.notExists(err)
|
|
873
888
|
done()
|
|
874
889
|
})
|
|
875
890
|
})
|
package/models/Project.js
CHANGED
|
@@ -26,7 +26,7 @@ let webhooksValidators = [
|
|
|
26
26
|
|
|
27
27
|
const reportConfigurationsValidators = [
|
|
28
28
|
{validator: helpers.validateNotNull},
|
|
29
|
-
{validator: helpers.validateNoDuplicateReportConfigurations, msg: "
|
|
29
|
+
{validator: helpers.validateNoDuplicateReportConfigurations, msg: "Multiple reports of the same type are not allowed"}
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
let ProjectSchema = new mongoose.Schema({
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ function validateRecipients(value) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
let ReportConfigurationSchema = new mongoose.Schema({
|
|
37
|
-
type: {type: String, enum: ['hello'], required: true},
|
|
37
|
+
type: {type: String, enum: ['hello', 'geo-trigger'], required: true},
|
|
38
38
|
frequency: {type: String, enum: ['daily', 'weekly', 'monthly'], required: true},
|
|
39
39
|
reportDay: {type: Number, validate: {validator: validateReportDay}},
|
|
40
40
|
timezone: {type: String, required: true, validate: { validator: validateTimeZone, msg: 'Invalid timezone'}},
|