MCPcopy Index your code
hub / github.com/validatorjs/validator.js / isByteLength

Function isByteLength

src/lib/isByteLength.js:4–17  ·  view source on GitHub ↗
(str, options)

Source from the content-addressed store, hash-verified

2
3/* eslint-disable prefer-rest-params */
4export default function isByteLength(str, options) {
5 assertString(str);
6 let min;
7 let max;
8 if (typeof (options) === 'object') {
9 min = options.min || 0;
10 max = options.max;
11 } else { // backwards compatibility: isByteLength(str, min [, max])
12 min = arguments[1];
13 max = arguments[2];
14 }
15 const len = encodeURI(str).split(/%..|./).length - 1;
16 return len >= min && (typeof max === 'undefined' || len <= max);
17}

Callers 1

isEmailFunction · 0.85

Calls 1

assertStringFunction · 0.85

Tested by

no test coverage detected