<code>category: {
type: ObjectId,
ref: "Category",
required: [true, "Recipe must belong to a category"],
},
</code>
<code>category: {
type: ObjectId,
ref: "Category",
required: [true, "Recipe must belong to a category"],
},
</code>
category: {
type: ObjectId,
ref: "Category",
required: [true, "Recipe must belong to a category"],
},
But if a category isn’t selected, the message I get is:
<code>Recipe validation failed: category: Cast to ObjectId failed for value "" (type string) at path "category" because of "BSONError"
</code>
<code>Recipe validation failed: category: Cast to ObjectId failed for value "" (type string) at path "category" because of "BSONError"
</code>
Recipe validation failed: category: Cast to ObjectId failed for value "" (type string) at path "category" because of "BSONError"
Why do I not get my custom error message?