Skip to content

Commit bd9d373

Browse files
committed
Fix #661
1 parent 9cd043e commit bd9d373

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/document.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,16 +975,18 @@ Document.prototype.validate = function (cb) {
975975
var validating = {}
976976
, total = 0;
977977

978+
// gh-661: if a whole array is modified, make sure to run validation on all
979+
// the children as well
978980
for (var i = 0; i < paths.length; ++i) {
979981
var path = paths[i];
980982
var val = self.getValue(path);
981983
if (val instanceof Array && !Buffer.isBuffer(val)) {
982-
for (var i = 0; i < val.length; ++i) {
983-
paths.push(path + '.' + i);
984+
var numElements = val.length;
985+
for (var j = 0; j < numElements; ++j) {
986+
paths.push(path + '.' + j);
984987
}
985988
}
986989
}
987-
988990
paths.forEach(validatePath);
989991
return promise;
990992

0 commit comments

Comments
 (0)