Skip to content

Commit 5845946

Browse files
committed
lib: fixes validator message
1 parent d44a71a commit 5845946

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/internal/validators.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ const validateArray = hideStackFrames((value, name, minLength = 0) => {
304304
throw new ERR_INVALID_ARG_TYPE(name, 'Array', value);
305305
}
306306
if (value.length < minLength) {
307-
const reason = `must be longer than ${minLength}`;
307+
const reason = `must have a length of at least ${minLength}`;
308308
throw new ERR_INVALID_ARG_VALUE(name, value, reason);
309309
}
310310
});

test/parallel/test-validators.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ const invalidArgValueError = {
9393
assert.throws(() => {
9494
validateArray([], 'foo', 1);
9595
}, 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+
});
96104
}
97105

98106
{

0 commit comments

Comments
 (0)