diff --git a/lib/mongodb.js b/lib/mongodb.js index 66bea5c9e..f8a4c4d41 100644 --- a/lib/mongodb.js +++ b/lib/mongodb.js @@ -2167,7 +2167,7 @@ function isObjectIDProperty(modelCtor, propDef, value, options) { if (!propDef) return false; if ((typeof value === 'string' && value.match(ObjectIdValueRegex)) || - (Array.isArray(value) && value.every((v) => v.match(ObjectIdValueRegex)))) { + (Array.isArray(value) && value.every((v) => typeof v === 'string' && v.match(ObjectIdValueRegex)))) { if (isStoredAsObjectID(propDef)) return true; else return !isStrictObjectIDCoercionEnabled(modelCtor, options); } else if (value instanceof mongodb.ObjectID) {