Skip to content

Commit

Permalink
test(update): repro #9172
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jul 3, 2020
1 parent 0d60630 commit f3be507
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/model.update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3478,4 +3478,22 @@ describe('model: updateOne: ', function() {
});
});
});

it('update validators respect storeSubdocValidationError (gh-9172)', function() {
const opts = { storeSubdocValidationError: false };
const Model = db.model('Test', Schema({
nested: Schema({
arr: [{ name: { type: String, required: true } }]
}, opts)
}));

return co(function*() {
const opts = { runValidators: true };
const err = yield Model.updateOne({}, { nested: { arr: [{}] } }, opts).catch(err => err);

assert.ok(err);
assert.ok(err.errors['nested.arr.0.name']);
assert.ok(!err.errors['nested']);
});
});
});

0 comments on commit f3be507

Please sign in to comment.