I want to build \"minLength\" and \"maxLength\" in the mongoose schema validation rules, the current solution is:
var blogSchema = new Schema({
title: { re
Min and max have changed
var breakfastSchema = new Schema({
eggs: {
type: Number,
min: [6, 'Too few eggs'],
max: 12
},
bacon: {
type: Number,
required: [true, 'Why no bacon?']
},
drink: {
type: String,
enum: ['Coffee', 'Tea'],
required: function() {
return this.bacon > 3;
}
}
});
https://mongoosejs.com/docs/validation.html