Validating startDate vs endDate
verscph opened this issue · comments
Philip Verschueren commented
I needed to validate whether the startDate is before the endDate and whether both dates have the right format:
var dateSchema = new schema({
dateRange: {
type: {
startDate: {
type: Date,
required: true,
validate: [dateFormatValidator, '{VALUE} is not a valid date!']
},
endDate: {
type: Date,
required: true,
validate: [dateFormatValidator, '{VALUE} is not a valid date!']
}
},
required: true,
validate: [dateRangeValidator, 'startDate must be before endDate!']
}
});
The validation of dateRange is executed, but the validation of the startDate and endDate format isn't. Is this a bug?