We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9cd043e commit bd9d373Copy full SHA for bd9d373
lib/document.js
@@ -975,16 +975,18 @@ Document.prototype.validate = function (cb) {
975
var validating = {}
976
, total = 0;
977
978
+ // gh-661: if a whole array is modified, make sure to run validation on all
979
+ // the children as well
980
for (var i = 0; i < paths.length; ++i) {
981
var path = paths[i];
982
var val = self.getValue(path);
983
if (val instanceof Array && !Buffer.isBuffer(val)) {
- for (var i = 0; i < val.length; ++i) {
- paths.push(path + '.' + i);
984
+ var numElements = val.length;
985
+ for (var j = 0; j < numElements; ++j) {
986
+ paths.push(path + '.' + j);
987
}
988
989
-
990
paths.forEach(validatePath);
991
return promise;
992
0 commit comments