Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,25 @@
options = options || {};
cb = cb || utils.createPromiseCallback();

assert(typeof dataArray === 'object' && dataArray.length,
'The data argument must be an array with length > 0');
assert(typeof dataArray === 'object' && Array.isArray(dataArray),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it configurable in order to ensure backward compatibility ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added sir

'The data argument must be an array');

Check failure on line 516 in lib/dao.js

View workflow job for this annotation

GitHub Actions / Code Lint

Expected indentation of 4 spaces but found 2
assert(typeof options === 'object', 'The options argument must be an object');
assert(typeof cb === 'function', 'The cb argument must be a function');
// If the dataArray is empty, we return an empty array or an error
if (dataArray.length === 0) {
if (options.allowEmptyArray === true) {
process.nextTick(function() {

Check failure on line 522 in lib/dao.js

View workflow job for this annotation

GitHub Actions / Code Lint

Expected indentation of 6 spaces but found 5
cb(null, []);
});
} else {
process.nextTick(function() {
const err = new Error('The data argument must be an array with length > 0');
err.statusCode = 400;
cb(err);
});
}
return cb.promise;
}

const validationPromises = [];
for (let index = 0; index < dataArray.length; index++) {
Expand Down
Loading