Validate that everyX values in dailies are integers bounded by 0 and 9999 fixes #8782 (#9268)

* Validate that everyX values are integers bounded by 0 and 9999

* Added client side check

* Updated tests

* Added migration for bad dailies

Near idential to the other task migration.

* fix(typo): camelCase function call
This commit is contained in:
Tyler Nychka
2017-12-05 14:55:32 -05:00
committed by Sabe Jones
parent 8367de34bf
commit bfaa7c0fea
5 changed files with 135 additions and 3 deletions

View File

@@ -239,7 +239,14 @@ export let habit = Task.discriminator('habit', HabitSchema);
export let DailySchema = new Schema(_.defaults({
frequency: {type: String, default: 'weekly', enum: ['daily', 'weekly', 'monthly', 'yearly']},
everyX: {type: Number, default: 1}, // e.g. once every X weeks
everyX: {
type: Number,
default: 1,
validate: [
(val) => val % 1 === 0 && val >= 0 && val <= 9999,
'Valid everyX values are integers from 0 to 9999',
],
},
startDate: {
type: Date,
default () {