My mongoose version is: "5.13.13",
I created my model called "wordSet" and i my problem is that validation is not working for array.
const schema = new mongoose.Schema({
name: {
type: String,
required: [true, 'Name is required.']
},
createdAt: {
type: Date,
default: Date.now(),
select: true,
},
category: [ // validation not working here
{
type: mongoose.Schema.Types.ObjectId,
ref: 'Category',
required: true,
},
],
});
const WordSet = mongoose.model('WordSet', schema);
What i'm doing something wrong?