Mongoose Model Custom Error Message for Enums
Try something like it:
var enu = {
values: ['pending', 'accept', 'decline']
, message: 'Status is required.'
}
var ConnectionRequestSchema = new Schema({
...
status: {
type: String
, enum: enu
, trim: true
}
});
difficulty: {
type: String,
required: [true, 'A tour must have a difficulty.'],
enum: {
values: ['easy', 'medium', 'difficult'],
message: 'Difficult is either easy, medium, difficult.'
}
}