Skip to content

Commit

Permalink
check collection name to be no empty string before running function o…
Browse files Browse the repository at this point in the history
…n it for pluralize
  • Loading branch information
ShubhamEHRAccount committed Aug 14, 2024
1 parent b6a30a4 commit 516bd88
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ exports.toCollectionName = function(name, pluralize) {
return name;
}
if (typeof pluralize === 'function') {
if (typeof name !== 'string') {
throw new TypeError('Collection name must be a string');
}
if (name.length === 0) {
throw new TypeError('Collection name cannot be empty');
}
return pluralize(name);
}
return name;
Expand Down

0 comments on commit 516bd88

Please sign in to comment.