Mongoose Validation Based on Other Fields

Viewed 3093

Consider the following schema for saving time intervals in Mongoose:

let dateIntervalSchema = new mongoose.Schema({
  begin: { type: Date, required: true  },
  end: { type: Date, required: true }
})

How can I ensure that end is always greater than or equal to begin using Mongoose Validation?

1 Answers
Related