const questionSchema = new mongoose.Schema({
question: {
type: String,
required: [true, 'Question Required'],
trim: true
},
options: {
type: [{
optionNo: Number,
optionValue:{
type: String,
required: [true,'Option required'],
trim: true
}
}],
validate: [(val) -> val.length > 1, 'Must have minimum two options']
}
});
questionSchema.path('options')
.validate((val) -> val.length > 1, 'Must have minimum two options');