We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4627bcf commit a84e6b0Copy full SHA for a84e6b0
2 files changed
lib/internal/validators.js
@@ -313,7 +313,7 @@ const validateArray = hideStackFrames((value, name, minLength = 0) => {
313
throw new ERR_INVALID_ARG_TYPE(name, 'Array', value);
314
}
315
if (value.length < minLength) {
316
- const reason = `must be longer than ${minLength}`;
+ const reason = `must have a length of at least ${minLength}`;
317
throw new ERR_INVALID_ARG_VALUE(name, value, reason);
318
319
});
test/parallel/test-validators.js
@@ -93,6 +93,14 @@ const invalidArgValueError = {
93
assert.throws(() => {
94
validateArray([], 'foo', 1);
95
}, invalidArgValueError);
96
+
97
+ validateArray([1, 2, 3], 'foo', 3);
98
+ assert.throws(() => {
99
+ validateArray([1, 2], 'foo', 3);
100
+ }, (err) => {
101
+ assert.ok(err.message.includes('at least 3'), `Expected "at least 3" in: ${err.message}`);
102
+ return true;
103
+ });
104
105
106
{
0 commit comments