diff --git a/lib/internal/validators.js b/lib/internal/validators.js index 110b045a063460..d2add7faa30a9e 100644 --- a/lib/internal/validators.js +++ b/lib/internal/validators.js @@ -304,7 +304,7 @@ const validateArray = hideStackFrames((value, name, minLength = 0) => { throw new ERR_INVALID_ARG_TYPE(name, 'Array', value); } if (value.length < minLength) { - const reason = `must be longer than ${minLength}`; + const reason = `must have a length of at least ${minLength}`; throw new ERR_INVALID_ARG_VALUE(name, value, reason); } }); diff --git a/test/parallel/test-validators.js b/test/parallel/test-validators.js index 848fa0c27bbebe..8acb04f3d072bc 100644 --- a/test/parallel/test-validators.js +++ b/test/parallel/test-validators.js @@ -93,6 +93,14 @@ const invalidArgValueError = { assert.throws(() => { validateArray([], 'foo', 1); }, invalidArgValueError); + + validateArray([1, 2, 3], 'foo', 3); + assert.throws(() => { + validateArray([1, 2], 'foo', 3); + }, (err) => { + assert.ok(err.message.includes('at least 3'), `Expected "at least 3" in: ${err.message}`); + return true; + }); } {