@bluedot-innovation/models 10.12.2 → 10.12.3
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 +3 -0
- package/__tests__/project/project.spec.js +7 -0
- package/package.json +1 -1
- package/schemas/Campaign.js +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1196,6 +1196,13 @@ describe('Project', () => {
|
|
|
1196
1196
|
assert.notExists(res)
|
|
1197
1197
|
}
|
|
1198
1198
|
})
|
|
1199
|
+
it('should allow empty zones when campaign status is draft', async () => {
|
|
1200
|
+
project.campaigns[0].status = 'draft'
|
|
1201
|
+
project.campaigns[0].zones = []
|
|
1202
|
+
let Project = new ProjectModel(project)
|
|
1203
|
+
const res = await Project.validate()
|
|
1204
|
+
assert.notExists(res)
|
|
1205
|
+
})
|
|
1199
1206
|
})
|
|
1200
1207
|
|
|
1201
1208
|
describe('Invalid Campaigns', () => {
|
package/package.json
CHANGED
package/schemas/Campaign.js
CHANGED
|
@@ -22,7 +22,10 @@ let CampaignSchema = new mongoose.Schema({
|
|
|
22
22
|
required: [true, 'campaign zones are required'],
|
|
23
23
|
validate: {
|
|
24
24
|
validator: function(zones) {
|
|
25
|
-
|
|
25
|
+
if (this.status === 'active' || this.status === 'paused') {
|
|
26
|
+
return zones && zones.length > 0
|
|
27
|
+
}
|
|
28
|
+
return true
|
|
26
29
|
},
|
|
27
30
|
msg: 'campaign must have at least one zone'
|
|
28
31
|
}
|