Skip to content

Commit

Permalink
fix(array): fix tests re: #8544
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Feb 20, 2020
1 parent cf6b45e commit 2afec3a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/schema/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,13 @@ SchemaArray.prototype._applySetters = function(value, scope, init, priorVal) {
arr = arr.casterConstructor;
}

const valueDepth = arrayDepth(value);
if (valueDepth.min === valueDepth.max && valueDepth.max < depth) {
for (let i = valueDepth.max; i < depth; ++i) {
value = [value];
// No need to wrap empty arrays
if (value != null && value.length > 0) {
const valueDepth = arrayDepth(value);
if (valueDepth.min === valueDepth.max && valueDepth.max < depth) {
for (let i = valueDepth.max; i < depth; ++i) {
value = [value];
}
}
}
}
Expand Down

0 comments on commit 2afec3a

Please sign in to comment.