-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
Description
I have an array field with the following schema on that field:
parents:
type: 'Array'
required: true
When I try to create a document with the following data:
data =
parents: []
Translation.create data, (err, translations) ->
console.log err, translations
I get the following error:
ValidationError: Path `parents` is required.
If I put a value inside the array it works, like so:
data =
parents: ['blah']
Similarly, if I remove the required: true
from the schema, it also starts working.
Is an empty array not considered satisfactory for "required" validation? I understand it's false in javascript, but there are plenty of cases where empty arrays and objects are intended in Mongo documents.