diff --git a/src/lib/isByteLength.js b/src/lib/isByteLength.js index 619d7f604..99f0d25ad 100644 --- a/src/lib/isByteLength.js +++ b/src/lib/isByteLength.js @@ -9,7 +9,7 @@ export default function isByteLength(str, options) { min = options.min || 0; max = options.max; } else { // backwards compatibility: isByteLength(str, min [, max]) - min = arguments[1]; + min = arguments[1] || 0; max = arguments[2]; } const len = encodeURI(str).split(/%..|./).length - 1; diff --git a/test/validators.test.js b/test/validators.test.js index 9c867efae..610e76605 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -5727,6 +5727,12 @@ describe('Validators', () => { valid: [''], invalid: ['g', 'a'], }); + test({ + validator: 'isByteLength', + args: [undefined, 3], + valid: ['abc', 'de', 'g', 'a', ''], + invalid: ['abcd', 'gm'], + }); });