Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(defaults || {})[idx],
definitions,
item
);
});
}
if (schema.minItems) {
if (!isMultiSelect(schema, definitions)) {
const defaultsLength = defaults ? defaults.length : 0;
if (schema.minItems > defaultsLength) {
const defaultEntries = defaults || [];
// populate the array with the defaults
const fillerSchema = Array.isArray(schema.items)
? schema.additionalItems
: schema.items;
const fillerEntries = fill(
new Array(schema.minItems - defaultsLength),
computeDefaults(fillerSchema, fillerSchema.defaults, definitions)
);
// then fill up the rest with either the item default or empty, up to minItems
return defaultEntries.concat(fillerEntries);
}
} else {
return defaults ? defaults : [];
}
}
}
return defaults;
}
(formData || {})[key]
)
return acc
}, {})
case 'array':
if (schema.minItems) {
if (!isMultiSelect(schema, definitions)) {
const defaultsLength = defaults ? defaults.length : 0
if (schema.minItems > defaultsLength) {
const defaultEntries = defaults || []
// populate the array with the defaults
const fillerSchema = Array.isArray(schema.items)
? schema.additionalItems
: schema.items
const fillerEntries = fill(
new Array(schema.minItems - defaultsLength),
computeDefaults(fillerSchema, fillerSchema.defaults, definitions)
)
// then fill up the rest with either the item default or empty, up to minItems
return defaultEntries.concat(fillerEntries)
}
} else {
return defaults ? defaults : []
}
}
}
return defaults
}
definitions
);
return acc;
}, {});
case "array":
if (schema.minItems) {
if (!isMultiSelect(schema, definitions)) {
const defaultsLength = defaults ? defaults.length : 0;
if (schema.minItems > defaultsLength) {
const defaultEntries = defaults || [];
// populate the array with the defaults
const fillerSchema = Array.isArray(schema.items)
? schema.additionalItems
: schema.items;
const fillerEntries = fill(
new Array(schema.minItems - defaultsLength),
computeDefaults(fillerSchema, fillerSchema.defaults, definitions)
);
// then fill up the rest with either the item default or empty, up to minItems
return defaultEntries.concat(fillerEntries);
}
} else {
return [];
}
}
}
return defaults;
}