valgen 5.3.0 → 5.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/cjs/core/context.js +2 -3
- package/cjs/core/validator.js +4 -4
- package/cjs/index.js +5 -5
- package/cjs/rules/format-rules/is-alpha.js +52 -0
- package/cjs/rules/format-rules/is-ascii.js +40 -0
- package/cjs/rules/format-rules/is-base64.js +40 -0
- package/cjs/rules/format-rules/is-btc-address.js +40 -0
- package/cjs/rules/format-rules/is-credit-card.js +40 -0
- package/cjs/rules/format-rules/is-decimal.js +41 -0
- package/cjs/rules/format-rules/is-ean.js +40 -0
- package/cjs/rules/format-rules/is-email.js +97 -0
- package/cjs/rules/format-rules/is-eth-address.js +40 -0
- package/cjs/rules/format-rules/is-fqdn.js +44 -0
- package/cjs/rules/format-rules/is-hash.js +40 -0
- package/cjs/rules/format-rules/is-hex-color.js +40 -0
- package/cjs/rules/format-rules/is-hex.js +40 -0
- package/cjs/rules/format-rules/is-iban.js +52 -0
- package/cjs/rules/format-rules/is-ip.js +52 -0
- package/cjs/rules/format-rules/is-issn.js +44 -0
- package/cjs/rules/format-rules/is-jwt.js +40 -0
- package/cjs/rules/format-rules/is-lowercase.js +52 -0
- package/cjs/rules/format-rules/is-mac-address.js +45 -0
- package/cjs/rules/format-rules/is-mobile-phone.js +43 -0
- package/cjs/rules/{is-object-id.js → format-rules/is-object-id.js} +3 -3
- package/cjs/rules/format-rules/is-passport-number.js +40 -0
- package/cjs/rules/format-rules/is-port.js +40 -0
- package/cjs/rules/format-rules/is-url.js +40 -0
- package/cjs/rules/format-rules/is-uuid.js +40 -0
- package/cjs/rules/format-rules/is-vat-number.js +40 -0
- package/cjs/rules/{is-regexp.js → format-rules/matches.js} +8 -5
- package/cjs/rules/index.js +49 -22
- package/cjs/rules/logical-rules/is-defined.js +30 -0
- package/cjs/rules/{is-empty.js → logical-rules/is-empty.js} +1 -1
- package/cjs/rules/{range.js → logical-rules/range.js} +63 -38
- package/cjs/rules/{is-any.js → type-rules/is-any.js} +1 -1
- package/cjs/rules/{is-array.js → type-rules/is-array.js} +2 -4
- package/cjs/rules/{is-bigint.js → type-rules/is-bigint.js} +2 -3
- package/cjs/rules/{is-boolean.js → type-rules/is-boolean.js} +1 -1
- package/cjs/rules/{is-date.js → type-rules/is-date.js} +5 -5
- package/cjs/rules/{is-enum.js → type-rules/is-enum.js} +6 -5
- package/cjs/rules/{is-integer.js → type-rules/is-integer.js} +2 -3
- package/cjs/rules/{is-null.js → type-rules/is-null.js} +2 -28
- package/cjs/rules/{is-number.js → type-rules/is-number.js} +2 -3
- package/cjs/rules/{is-object.js → type-rules/is-object.js} +3 -4
- package/cjs/rules/{is-record.js → type-rules/is-record.js} +1 -1
- package/cjs/rules/{is-string.js → type-rules/is-string.js} +1 -1
- package/cjs/rules/{is-tuple.js → type-rules/is-tuple.js} +2 -3
- package/cjs/rules/utility-rules/exists.js +16 -0
- package/cjs/rules/utility-rules/get-length.js +24 -0
- package/cjs/rules/utility-rules/optional.js +16 -0
- package/cjs/rules/{pipe.js → utility-rules/pipe.js} +1 -1
- package/cjs/rules/utility-rules/required.js +18 -0
- package/cjs/rules/{union.js → utility-rules/union.js} +2 -2
- package/esm/core/context.js +2 -3
- package/esm/core/validator.js +4 -4
- package/esm/index.js +3 -3
- package/esm/rules/format-rules/is-alpha.js +24 -0
- package/esm/rules/format-rules/is-ascii.js +13 -0
- package/esm/rules/format-rules/is-base64.js +13 -0
- package/esm/rules/format-rules/is-btc-address.js +13 -0
- package/esm/rules/format-rules/is-credit-card.js +13 -0
- package/esm/rules/format-rules/is-decimal.js +14 -0
- package/esm/rules/format-rules/is-ean.js +13 -0
- package/esm/rules/format-rules/is-email.js +70 -0
- package/esm/rules/format-rules/is-eth-address.js +13 -0
- package/esm/rules/format-rules/is-fqdn.js +17 -0
- package/esm/rules/format-rules/is-hash.js +13 -0
- package/esm/rules/format-rules/is-hex-color.js +13 -0
- package/esm/rules/format-rules/is-hex.js +13 -0
- package/esm/rules/format-rules/is-iban.js +24 -0
- package/esm/rules/format-rules/is-ip.js +24 -0
- package/esm/rules/format-rules/is-issn.js +17 -0
- package/esm/rules/format-rules/is-jwt.js +13 -0
- package/esm/rules/format-rules/is-lowercase.js +24 -0
- package/esm/rules/format-rules/is-mac-address.js +18 -0
- package/esm/rules/format-rules/is-mobile-phone.js +16 -0
- package/esm/rules/{is-object-id.js → format-rules/is-object-id.js} +3 -3
- package/esm/rules/format-rules/is-passport-number.js +13 -0
- package/esm/rules/format-rules/is-port.js +13 -0
- package/esm/rules/format-rules/is-url.js +13 -0
- package/esm/rules/format-rules/is-uuid.js +13 -0
- package/esm/rules/format-rules/is-vat-number.js +13 -0
- package/esm/rules/{is-regexp.js → format-rules/matches.js} +6 -3
- package/esm/rules/index.js +49 -22
- package/esm/rules/logical-rules/is-defined.js +25 -0
- package/esm/rules/{is-empty.js → logical-rules/is-empty.js} +1 -1
- package/esm/rules/{range.js → logical-rules/range.js} +59 -36
- package/esm/rules/{is-any.js → type-rules/is-any.js} +1 -1
- package/esm/rules/{is-array.js → type-rules/is-array.js} +2 -4
- package/esm/rules/{is-bigint.js → type-rules/is-bigint.js} +2 -3
- package/esm/rules/{is-boolean.js → type-rules/is-boolean.js} +1 -1
- package/esm/rules/{is-date.js → type-rules/is-date.js} +5 -5
- package/esm/rules/{is-enum.js → type-rules/is-enum.js} +6 -5
- package/esm/rules/{is-integer.js → type-rules/is-integer.js} +2 -3
- package/esm/rules/{is-null.js → type-rules/is-null.js} +1 -25
- package/esm/rules/{is-number.js → type-rules/is-number.js} +2 -3
- package/esm/rules/{is-object.js → type-rules/is-object.js} +3 -4
- package/esm/rules/{is-record.js → type-rules/is-record.js} +1 -1
- package/esm/rules/{is-string.js → type-rules/is-string.js} +1 -1
- package/esm/rules/{is-tuple.js → type-rules/is-tuple.js} +2 -3
- package/esm/rules/utility-rules/exists.js +12 -0
- package/esm/rules/utility-rules/get-length.js +20 -0
- package/esm/rules/utility-rules/optional.js +12 -0
- package/esm/rules/{pipe.js → utility-rules/pipe.js} +1 -1
- package/esm/rules/utility-rules/required.js +14 -0
- package/esm/rules/{union.js → utility-rules/union.js} +2 -2
- package/package.json +3 -3
- package/typings/index.d.ts +4 -4
- package/typings/rules/format-rules/is-alpha.d.ts +11 -0
- package/typings/rules/format-rules/is-ascii.d.ts +6 -0
- package/typings/rules/format-rules/is-base64.d.ts +9 -0
- package/typings/rules/format-rules/is-btc-address.d.ts +6 -0
- package/typings/rules/format-rules/is-credit-card.d.ts +9 -0
- package/typings/rules/format-rules/is-decimal.d.ts +7 -0
- package/typings/rules/format-rules/is-ean.d.ts +6 -0
- package/typings/rules/format-rules/is-email.d.ts +62 -0
- package/typings/rules/format-rules/is-eth-address.d.ts +6 -0
- package/typings/rules/format-rules/is-fqdn.d.ts +13 -0
- package/typings/rules/format-rules/is-hash.d.ts +8 -0
- package/typings/rules/format-rules/is-hex-color.d.ts +6 -0
- package/typings/rules/format-rules/is-hex.d.ts +6 -0
- package/typings/rules/format-rules/is-iban.d.ts +11 -0
- package/typings/rules/format-rules/is-ip.d.ts +11 -0
- package/typings/rules/format-rules/is-issn.d.ts +14 -0
- package/typings/rules/format-rules/is-jwt.d.ts +6 -0
- package/typings/rules/format-rules/is-lowercase.d.ts +11 -0
- package/typings/rules/format-rules/is-mac-address.d.ts +21 -0
- package/typings/rules/format-rules/is-mobile-phone.d.ts +20 -0
- package/typings/rules/{is-object-id.d.ts → format-rules/is-object-id.d.ts} +2 -2
- package/typings/rules/format-rules/is-passport-number.d.ts +6 -0
- package/typings/rules/format-rules/is-port.d.ts +6 -0
- package/typings/rules/format-rules/is-url.d.ts +9 -0
- package/typings/rules/format-rules/is-uuid.d.ts +6 -0
- package/typings/rules/format-rules/is-vat-number.d.ts +6 -0
- package/typings/rules/format-rules/matches.d.ts +9 -0
- package/typings/rules/index.d.ts +49 -22
- package/typings/rules/logical-rules/is-defined.d.ts +11 -0
- package/typings/rules/{is-empty.d.ts → logical-rules/is-empty.d.ts} +3 -3
- package/typings/rules/{range.d.ts → logical-rules/range.d.ts} +14 -4
- package/typings/rules/type-rules/is-any.d.ts +5 -0
- package/typings/rules/{is-array.d.ts → type-rules/is-array.d.ts} +2 -2
- package/typings/rules/{is-bigint.d.ts → type-rules/is-bigint.d.ts} +2 -2
- package/typings/rules/{is-boolean.d.ts → type-rules/is-boolean.d.ts} +2 -2
- package/typings/rules/{is-date.d.ts → type-rules/is-date.d.ts} +3 -3
- package/typings/rules/{is-enum.d.ts → type-rules/is-enum.d.ts} +1 -1
- package/typings/rules/{is-integer.d.ts → type-rules/is-integer.d.ts} +2 -2
- package/typings/rules/type-rules/is-null.d.ts +11 -0
- package/typings/rules/{is-number.d.ts → type-rules/is-number.d.ts} +2 -2
- package/typings/rules/{is-object.d.ts → type-rules/is-object.d.ts} +1 -1
- package/typings/rules/{is-record.d.ts → type-rules/is-record.d.ts} +2 -2
- package/typings/rules/{is-string.d.ts → type-rules/is-string.d.ts} +5 -5
- package/typings/rules/{is-tuple.d.ts → type-rules/is-tuple.d.ts} +2 -8
- package/typings/rules/utility-rules/exists.d.ts +6 -0
- package/typings/rules/utility-rules/get-length.d.ts +11 -0
- package/typings/rules/utility-rules/optional.d.ts +7 -0
- package/typings/rules/{pipe.d.ts → utility-rules/pipe.d.ts} +1 -1
- package/typings/rules/utility-rules/required.d.ts +7 -0
- package/typings/rules/utility-rules/union.d.ts +5 -0
- package/cjs/rules/length.js +0 -41
- package/cjs/rules/optional.js +0 -44
- package/cjs/rules/string-formats.js +0 -377
- package/esm/rules/length.js +0 -35
- package/esm/rules/optional.js +0 -38
- package/esm/rules/string-formats.js +0 -322
- package/typings/rules/is-any.d.ts +0 -5
- package/typings/rules/is-null.d.ts +0 -21
- package/typings/rules/is-regexp.d.ts +0 -9
- package/typings/rules/length.d.ts +0 -21
- package/typings/rules/optional.d.ts +0 -17
- package/typings/rules/string-formats.d.ts +0 -166
- package/typings/rules/union.d.ts +0 -5
package/cjs/rules/index.js
CHANGED
|
@@ -14,25 +14,52 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./is-any.js"), exports);
|
|
18
|
-
__exportStar(require("./is-array.js"), exports);
|
|
19
|
-
__exportStar(require("./is-bigint.js"), exports);
|
|
20
|
-
__exportStar(require("./is-boolean.js"), exports);
|
|
21
|
-
__exportStar(require("./is-date.js"), exports);
|
|
22
|
-
__exportStar(require("./is-
|
|
23
|
-
__exportStar(require("./is-
|
|
24
|
-
__exportStar(require("./is-
|
|
25
|
-
__exportStar(require("./is-
|
|
26
|
-
__exportStar(require("./is-
|
|
27
|
-
__exportStar(require("./is-
|
|
28
|
-
__exportStar(require("./is-
|
|
29
|
-
__exportStar(require("./is-
|
|
30
|
-
__exportStar(require("./is-
|
|
31
|
-
__exportStar(require("./is-
|
|
32
|
-
__exportStar(require("./is-
|
|
33
|
-
__exportStar(require("./
|
|
34
|
-
__exportStar(require("./
|
|
35
|
-
__exportStar(require("./
|
|
36
|
-
__exportStar(require("./
|
|
37
|
-
__exportStar(require("./
|
|
38
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./type-rules/is-any.js"), exports);
|
|
18
|
+
__exportStar(require("./type-rules/is-array.js"), exports);
|
|
19
|
+
__exportStar(require("./type-rules/is-bigint.js"), exports);
|
|
20
|
+
__exportStar(require("./type-rules/is-boolean.js"), exports);
|
|
21
|
+
__exportStar(require("./type-rules/is-date.js"), exports);
|
|
22
|
+
__exportStar(require("./type-rules/is-enum.js"), exports);
|
|
23
|
+
__exportStar(require("./type-rules/is-integer.js"), exports);
|
|
24
|
+
__exportStar(require("./type-rules/is-null.js"), exports);
|
|
25
|
+
__exportStar(require("./type-rules/is-number.js"), exports);
|
|
26
|
+
__exportStar(require("./type-rules/is-object.js"), exports);
|
|
27
|
+
__exportStar(require("./type-rules/is-record.js"), exports);
|
|
28
|
+
__exportStar(require("./type-rules/is-string.js"), exports);
|
|
29
|
+
__exportStar(require("./type-rules/is-tuple.js"), exports);
|
|
30
|
+
__exportStar(require("./format-rules/is-alpha.js"), exports);
|
|
31
|
+
__exportStar(require("./format-rules/is-ascii.js"), exports);
|
|
32
|
+
__exportStar(require("./format-rules/is-base64.js"), exports);
|
|
33
|
+
__exportStar(require("./format-rules/is-btc-address.js"), exports);
|
|
34
|
+
__exportStar(require("./format-rules/is-credit-card.js"), exports);
|
|
35
|
+
__exportStar(require("./format-rules/is-decimal.js"), exports);
|
|
36
|
+
__exportStar(require("./format-rules/is-ean.js"), exports);
|
|
37
|
+
__exportStar(require("./format-rules/is-email.js"), exports);
|
|
38
|
+
__exportStar(require("./format-rules/is-eth-address.js"), exports);
|
|
39
|
+
__exportStar(require("./format-rules/is-fqdn.js"), exports);
|
|
40
|
+
__exportStar(require("./format-rules/is-hash.js"), exports);
|
|
41
|
+
__exportStar(require("./format-rules/is-hex.js"), exports);
|
|
42
|
+
__exportStar(require("./format-rules/is-hex-color.js"), exports);
|
|
43
|
+
__exportStar(require("./format-rules/is-iban.js"), exports);
|
|
44
|
+
__exportStar(require("./format-rules/is-ip.js"), exports);
|
|
45
|
+
__exportStar(require("./format-rules/is-issn.js"), exports);
|
|
46
|
+
__exportStar(require("./format-rules/is-jwt.js"), exports);
|
|
47
|
+
__exportStar(require("./format-rules/is-lowercase.js"), exports);
|
|
48
|
+
__exportStar(require("./format-rules/is-mac-address.js"), exports);
|
|
49
|
+
__exportStar(require("./format-rules/is-mobile-phone.js"), exports);
|
|
50
|
+
__exportStar(require("./format-rules/is-object-id.js"), exports);
|
|
51
|
+
__exportStar(require("./format-rules/is-passport-number.js"), exports);
|
|
52
|
+
__exportStar(require("./format-rules/is-port.js"), exports);
|
|
53
|
+
__exportStar(require("./format-rules/is-url.js"), exports);
|
|
54
|
+
__exportStar(require("./format-rules/is-uuid.js"), exports);
|
|
55
|
+
__exportStar(require("./format-rules/is-vat-number.js"), exports);
|
|
56
|
+
__exportStar(require("./format-rules/matches.js"), exports);
|
|
57
|
+
__exportStar(require("./logical-rules/is-defined.js"), exports);
|
|
58
|
+
__exportStar(require("./logical-rules/is-empty.js"), exports);
|
|
59
|
+
__exportStar(require("./logical-rules/range.js"), exports);
|
|
60
|
+
__exportStar(require("./utility-rules/exists.js"), exports);
|
|
61
|
+
__exportStar(require("./utility-rules/get-length.js"), exports);
|
|
62
|
+
__exportStar(require("./utility-rules/optional.js"), exports);
|
|
63
|
+
__exportStar(require("./utility-rules/pipe.js"), exports);
|
|
64
|
+
__exportStar(require("./utility-rules/required.js"), exports);
|
|
65
|
+
__exportStar(require("./utility-rules/union.js"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isUndefined = exports.isDefined = void 0;
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
|
+
/**
|
|
6
|
+
* Validates if value is not "undefined" nor "null"
|
|
7
|
+
* @validator isDefined
|
|
8
|
+
*/
|
|
9
|
+
function isDefined(options) {
|
|
10
|
+
return (0, index_js_1.validator)('is-defined', function (input, context, _this) {
|
|
11
|
+
if (input !== undefined)
|
|
12
|
+
return input;
|
|
13
|
+
context.fail(_this, `Is not defined`, input);
|
|
14
|
+
}, options);
|
|
15
|
+
}
|
|
16
|
+
exports.isDefined = isDefined;
|
|
17
|
+
/**
|
|
18
|
+
* Validates if value is "undefined"
|
|
19
|
+
* @validator isUndefined
|
|
20
|
+
*/
|
|
21
|
+
function isUndefined(options) {
|
|
22
|
+
return (0, index_js_1.validator)('isUndefined', function (input, context, _this) {
|
|
23
|
+
if (options?.coerce || context.coerce)
|
|
24
|
+
return undefined;
|
|
25
|
+
if (input === undefined)
|
|
26
|
+
return;
|
|
27
|
+
context.fail(_this, `{{label}} mustn\'t be defined`, input);
|
|
28
|
+
}, options);
|
|
29
|
+
}
|
|
30
|
+
exports.isUndefined = isUndefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isNotEmpty = exports.isEmpty = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Checks if value is an empty. Value should be string, array, set, map or object
|
|
7
7
|
* @validator isEmpty
|
|
@@ -1,7 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const index_js_1 = require("
|
|
3
|
+
exports.lengthMax = exports.lengthMin = exports.isLte = exports.isLt = exports.isGte = exports.isGt = exports.range = void 0;
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
|
+
const get_length_js_1 = require("../utility-rules/get-length.js");
|
|
6
|
+
const pipe_js_1 = require("../utility-rules/pipe.js");
|
|
7
|
+
/**
|
|
8
|
+
* Checks if value is between minValue and maxValue
|
|
9
|
+
* @validator range
|
|
10
|
+
*/
|
|
11
|
+
function range(minValue, maxValue, options) {
|
|
12
|
+
return (0, index_js_1.validator)('range', function (input, context, _this) {
|
|
13
|
+
if ((typeof minValue === 'number' || typeof minValue === 'bigint') &&
|
|
14
|
+
(typeof maxValue === 'number' || typeof maxValue === 'bigint') &&
|
|
15
|
+
(typeof input === 'number' || typeof input === 'bigint') &&
|
|
16
|
+
input >= minValue &&
|
|
17
|
+
input <= maxValue)
|
|
18
|
+
return input;
|
|
19
|
+
if (minValue instanceof Date &&
|
|
20
|
+
maxValue instanceof Date &&
|
|
21
|
+
input instanceof Date &&
|
|
22
|
+
input >= minValue &&
|
|
23
|
+
input <= maxValue)
|
|
24
|
+
return input;
|
|
25
|
+
if (typeof minValue === 'string' &&
|
|
26
|
+
typeof maxValue === 'string' &&
|
|
27
|
+
typeof input === 'string' &&
|
|
28
|
+
input >= minValue &&
|
|
29
|
+
input <= maxValue)
|
|
30
|
+
return input;
|
|
31
|
+
context.fail(_this, `Value must be between ${minValue} and ${maxValue}`, input);
|
|
32
|
+
}, options);
|
|
33
|
+
}
|
|
34
|
+
exports.range = range;
|
|
5
35
|
function isGt(minValue, options) {
|
|
6
36
|
return (0, index_js_1.validator)('isGt', function (input, context, _this) {
|
|
7
37
|
if ((typeof minValue === 'number' || typeof minValue === 'bigint') &&
|
|
@@ -10,11 +40,11 @@ function isGt(minValue, options) {
|
|
|
10
40
|
return input;
|
|
11
41
|
if (minValue instanceof Date && input instanceof Date && input > minValue)
|
|
12
42
|
return input;
|
|
13
|
-
if (typeof minValue === 'string' &&
|
|
14
|
-
|
|
15
|
-
|
|
43
|
+
if (typeof minValue === 'string' &&
|
|
44
|
+
typeof input === 'string' &&
|
|
45
|
+
(input > minValue || (options?.caseInsensitive && input.toLowerCase() > minValue.toLowerCase())))
|
|
16
46
|
return input;
|
|
17
|
-
context.fail(_this, `{{label}} must be greater than ${
|
|
47
|
+
context.fail(_this, `{{label}} must be greater than ${typeof minValue === 'string' ? `"${minValue}"` : minValue}`, input);
|
|
18
48
|
}, options);
|
|
19
49
|
}
|
|
20
50
|
exports.isGt = isGt;
|
|
@@ -26,11 +56,11 @@ function isGte(minValue, options) {
|
|
|
26
56
|
return input;
|
|
27
57
|
if (minValue instanceof Date && input instanceof Date && input >= minValue)
|
|
28
58
|
return input;
|
|
29
|
-
if (typeof minValue === 'string' &&
|
|
30
|
-
|
|
31
|
-
|
|
59
|
+
if (typeof minValue === 'string' &&
|
|
60
|
+
typeof input === 'string' &&
|
|
61
|
+
(input >= minValue || (options?.caseInsensitive && input.toLowerCase() >= minValue.toLowerCase())))
|
|
32
62
|
return input;
|
|
33
|
-
context.fail(_this, `{{label}} must be greater than or equal to ${
|
|
63
|
+
context.fail(_this, `{{label}} must be greater than or equal to ${typeof minValue === 'string' ? `"${minValue}"` : minValue}`, input);
|
|
34
64
|
}, options);
|
|
35
65
|
}
|
|
36
66
|
exports.isGte = isGte;
|
|
@@ -42,48 +72,43 @@ function isLt(maxValue, options) {
|
|
|
42
72
|
return input;
|
|
43
73
|
if (maxValue instanceof Date && input instanceof Date && input < maxValue)
|
|
44
74
|
return input;
|
|
45
|
-
if (typeof maxValue === 'string' &&
|
|
46
|
-
|
|
47
|
-
|
|
75
|
+
if (typeof maxValue === 'string' &&
|
|
76
|
+
typeof input === 'string' &&
|
|
77
|
+
(input < maxValue || (options?.caseInsensitive && input.toLowerCase() < maxValue.toLowerCase())))
|
|
48
78
|
return input;
|
|
49
|
-
context.fail(_this, `{{label}} must be lover than ${
|
|
79
|
+
context.fail(_this, `{{label}} must be lover than ${typeof maxValue === 'string' ? `"${maxValue}"` : maxValue}`, input);
|
|
50
80
|
}, options);
|
|
51
81
|
}
|
|
52
82
|
exports.isLt = isLt;
|
|
53
83
|
function isLte(maxValue, options) {
|
|
54
|
-
return (0, index_js_1.validator)('
|
|
84
|
+
return (0, index_js_1.validator)('isLte', function (input, context, _this) {
|
|
55
85
|
if ((typeof maxValue === 'number' || typeof maxValue === 'bigint') &&
|
|
56
86
|
(typeof input === 'number' || typeof input === 'bigint') &&
|
|
57
87
|
input <= maxValue)
|
|
58
88
|
return input;
|
|
59
89
|
if (maxValue instanceof Date && input instanceof Date && input <= maxValue)
|
|
60
90
|
return input;
|
|
61
|
-
if (typeof maxValue === 'string' &&
|
|
62
|
-
|
|
63
|
-
|
|
91
|
+
if (typeof maxValue === 'string' &&
|
|
92
|
+
typeof input === 'string' &&
|
|
93
|
+
(input <= maxValue || (options?.caseInsensitive && input.toLowerCase() <= maxValue.toLowerCase())))
|
|
64
94
|
return input;
|
|
65
|
-
context.fail(_this, `{{label}} must be lover than or equal to ${
|
|
95
|
+
context.fail(_this, `{{label}} must be lover than or equal to ${typeof maxValue === 'string' ? `"${maxValue}"` : maxValue}`, input);
|
|
66
96
|
}, options);
|
|
67
97
|
}
|
|
68
98
|
exports.isLte = isLte;
|
|
69
99
|
/**
|
|
70
|
-
* Checks
|
|
71
|
-
* @validator
|
|
100
|
+
* Checks the length is at least "minValue"
|
|
101
|
+
* @validator lengthMin
|
|
72
102
|
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return input;
|
|
86
|
-
context.fail(_this, `Value must be between ${minValue} and ${maxValue}`, input);
|
|
87
|
-
}, options);
|
|
88
|
-
}
|
|
89
|
-
exports.range = range;
|
|
103
|
+
const lengthMin = (minValue) => (0, pipe_js_1.allOf)((0, pipe_js_1.pipe)((0, get_length_js_1.getLength)(), isGte(minValue, {
|
|
104
|
+
onFail: () => `The length of {{label}} must be at least ${minValue}`,
|
|
105
|
+
})));
|
|
106
|
+
exports.lengthMin = lengthMin;
|
|
107
|
+
/**
|
|
108
|
+
* Checks if the length is at most "maxValue"
|
|
109
|
+
* @validator lengthMax
|
|
110
|
+
*/
|
|
111
|
+
const lengthMax = (maxValue) => (0, pipe_js_1.allOf)((0, pipe_js_1.pipe)((0, get_length_js_1.getLength)(), isLte(maxValue, {
|
|
112
|
+
onFail: () => `The length of {{label}} must be at most ${maxValue}`,
|
|
113
|
+
})));
|
|
114
|
+
exports.lengthMax = lengthMax;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isAny = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Does nothing, just returns original input value.
|
|
7
7
|
* @validator isAny
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isArray = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Validates if value is "array" and applies validation for each item.
|
|
7
7
|
* Converts input value to array if coerce option is set to 'true'.
|
|
@@ -28,9 +28,7 @@ function isArray(itemValidator, options) {
|
|
|
28
28
|
v = input[i];
|
|
29
29
|
itemContext.scope = input;
|
|
30
30
|
// itemContext.location = location + '[' + i + ']';
|
|
31
|
-
itemContext.location = context.location
|
|
32
|
-
? context.location + `[${i}]`
|
|
33
|
-
: `<Array>[${i}]`;
|
|
31
|
+
itemContext.location = context.location ? context.location + `[${i}]` : `<Array>[${i}]`;
|
|
34
32
|
itemContext.index = i;
|
|
35
33
|
v = itemValidator(v, itemContext);
|
|
36
34
|
out.push(v);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isBigint = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Validates if value is "BigInt".
|
|
7
7
|
* Converts input value to number if coerce option is set to 'true'.
|
|
@@ -12,8 +12,7 @@ function isBigint(options) {
|
|
|
12
12
|
const coerce = options?.coerce || context.coerce;
|
|
13
13
|
if (typeof input === 'bigint')
|
|
14
14
|
return input;
|
|
15
|
-
if ((typeof input === 'number' && !isNaN(input)) ||
|
|
16
|
-
(typeof input === 'string' && coerce))
|
|
15
|
+
if ((typeof input === 'number' && !isNaN(input)) || (typeof input === 'string' && coerce))
|
|
17
16
|
return BigInt(input);
|
|
18
17
|
const t = typeof input === 'string' ? 'String ' : '';
|
|
19
18
|
context.fail(_this, `${t}"{{value}}" is not a valid BigInt value`, input);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isBoolean = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
const TRUE_PATTERN = /^true|t|1|yes|y$/i;
|
|
6
6
|
const FALSE_PATTERN = /^false|f|0|no|n$/i;
|
|
7
7
|
/**
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDateString = exports.isDate = void 0;
|
|
4
4
|
const date_fns_1 = require("date-fns");
|
|
5
|
-
const index_js_1 = require("
|
|
5
|
+
const index_js_1 = require("../../core/index.js");
|
|
6
6
|
/* eslint-disable-next-line max-len */ // noinspection RegExpUnnecessaryNonCapturingGroup
|
|
7
|
-
const DATE_PATTERN =
|
|
7
|
+
const DATE_PATTERN =
|
|
8
|
+
// eslint-disable-next-line max-len
|
|
9
|
+
/^(\d{4})(?:-(0[0-9]|1[0-2]))?(?:-([0-2][0-9]|3[0-1]))?(?:[T ](([0-1][0-9]|2[0-4]):([0-5][0-9])(?::([0-5][0-9]))?(?:\.(\d{0,3}))?)?((?:[+-](0[0-9]|1[0-2])(?::(\d{2}))?)|Z)?)?$/;
|
|
8
10
|
/**
|
|
9
11
|
* Validates if value is instance of "Date".
|
|
10
12
|
* Converts input value to Date if coerce option is set to 'true'.
|
|
@@ -85,9 +87,7 @@ function isDateString(options) {
|
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
else if (input instanceof Date) {
|
|
88
|
-
return trim === 'date'
|
|
89
|
-
? (0, date_fns_1.formatISO)(input, { representation: 'date' })
|
|
90
|
-
: (0, date_fns_1.formatISO)(input).substring(0, 19);
|
|
90
|
+
return trim === 'date' ? (0, date_fns_1.formatISO)(input, { representation: 'date' }) : (0, date_fns_1.formatISO)(input).substring(0, 19);
|
|
91
91
|
}
|
|
92
92
|
context.fail(_this, `"{{value}}" is not a valid date string`, input, { ...options });
|
|
93
93
|
}, options);
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isEnum = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Validates if given value is one of enum values.
|
|
7
7
|
* @validator isEnum
|
|
8
8
|
*/
|
|
9
9
|
function isEnum(values, options) {
|
|
10
|
-
const caseInSensitive = !!
|
|
10
|
+
const caseInSensitive = !!options?.caseInSensitive;
|
|
11
11
|
const enumName = options?.enumName;
|
|
12
12
|
// Prepare an object for fast lookup
|
|
13
|
-
const valObj = (Array.isArray(values) ? values : [values])
|
|
14
|
-
.reduce((a, v) => {
|
|
13
|
+
const valObj = (Array.isArray(values) ? values : [values]).reduce((a, v) => {
|
|
15
14
|
if (typeof v === 'string' && caseInSensitive)
|
|
16
15
|
a[v.toUpperCase()] = true;
|
|
17
16
|
else
|
|
@@ -21,7 +20,9 @@ function isEnum(values, options) {
|
|
|
21
20
|
return (0, index_js_1.validator)('isEnum', function (input, context, _this) {
|
|
22
21
|
if (input != null && valObj[typeof input === 'string' && caseInSensitive ? input.toUpperCase() : input])
|
|
23
22
|
return input;
|
|
24
|
-
context.fail(_this, `Value must be one of enumeration member${enumName ? ` (${enumName})` : ''}`, input, {
|
|
23
|
+
context.fail(_this, `Value must be one of enumeration member${enumName ? ` (${enumName})` : ''}`, input, {
|
|
24
|
+
enum: enumName,
|
|
25
|
+
});
|
|
25
26
|
}, options);
|
|
26
27
|
}
|
|
27
28
|
exports.isEnum = isEnum;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isInteger = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Validates if value is "integer".
|
|
7
7
|
* Converts input value to integer number if coerce option is set to 'true'.
|
|
@@ -21,8 +21,7 @@ function isInteger(options) {
|
|
|
21
21
|
}
|
|
22
22
|
if (typeof input === 'number' && !isNaN(input) && Number.isInteger(input))
|
|
23
23
|
return input;
|
|
24
|
-
const t = typeof input === 'bigint' ? 'BigInt ' :
|
|
25
|
-
(typeof input === 'string' ? 'String ' : '');
|
|
24
|
+
const t = typeof input === 'bigint' ? 'BigInt ' : typeof input === 'string' ? 'String ' : '';
|
|
26
25
|
context.fail(_this, `${t}"{{value}}" is not a valid integer value`, input);
|
|
27
26
|
}, options);
|
|
28
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const index_js_1 = require("
|
|
3
|
+
exports.isNullish = exports.isNull = void 0;
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Validates if value is "null".
|
|
7
7
|
* @validator isNull
|
|
@@ -32,29 +32,3 @@ function isNullish(options) {
|
|
|
32
32
|
}, options);
|
|
33
33
|
}
|
|
34
34
|
exports.isNullish = isNullish;
|
|
35
|
-
/**
|
|
36
|
-
* Validates if value is not "undefined" nor "null"
|
|
37
|
-
* @validator isDefined
|
|
38
|
-
*/
|
|
39
|
-
function isDefined(options) {
|
|
40
|
-
return (0, index_js_1.validator)('is-defined', function (input, context, _this) {
|
|
41
|
-
if (input !== undefined)
|
|
42
|
-
return input;
|
|
43
|
-
context.fail(_this, `Is not defined`, input);
|
|
44
|
-
}, options);
|
|
45
|
-
}
|
|
46
|
-
exports.isDefined = isDefined;
|
|
47
|
-
/**
|
|
48
|
-
* Validates if value is "undefined"
|
|
49
|
-
* @validator isUndefined
|
|
50
|
-
*/
|
|
51
|
-
function isUndefined(options) {
|
|
52
|
-
return (0, index_js_1.validator)('isUndefined', function (input, context, _this) {
|
|
53
|
-
if (options?.coerce || context.coerce)
|
|
54
|
-
return undefined;
|
|
55
|
-
if (input === undefined)
|
|
56
|
-
return;
|
|
57
|
-
context.fail(_this, `{{label}} mustn\'t be defined`, input);
|
|
58
|
-
}, options);
|
|
59
|
-
}
|
|
60
|
-
exports.isUndefined = isUndefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isNumber = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Validates if value is "number".
|
|
7
7
|
* Converts input value to number if coerce option is set to 'true'.
|
|
@@ -21,8 +21,7 @@ function isNumber(options) {
|
|
|
21
21
|
}
|
|
22
22
|
if (typeof input === 'number' && !isNaN(input))
|
|
23
23
|
return input;
|
|
24
|
-
const t = typeof input === 'bigint' ? 'BigInt ' :
|
|
25
|
-
(typeof input === 'string' ? 'String ' : '');
|
|
24
|
+
const t = typeof input === 'bigint' ? 'BigInt ' : typeof input === 'string' ? 'String ' : '';
|
|
26
25
|
context.fail(_this, `${t}"{{value}}" is not a valid number value`, input);
|
|
27
26
|
}, options);
|
|
28
27
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isObject = void 0;
|
|
4
|
-
const constants_js_1 = require("
|
|
5
|
-
const index_js_1 = require("
|
|
4
|
+
const constants_js_1 = require("../../constants.js");
|
|
5
|
+
const index_js_1 = require("../../core/index.js");
|
|
6
6
|
/**
|
|
7
7
|
* Validates object according to schema
|
|
8
8
|
* Converts properties according to schema rules if coerce option is set to 'true'.
|
|
@@ -69,8 +69,7 @@ function isObject(schema, options) {
|
|
|
69
69
|
inputKey = keys[i];
|
|
70
70
|
schemaKey = caseInSensitive ? inputKey.toLowerCase() : inputKey;
|
|
71
71
|
v = input[inputKey];
|
|
72
|
-
_propRule = propertyRules[schemaKey] ||
|
|
73
|
-
((0, index_js_1.isValidator)(additionalFields) ? additionalFields : undefined);
|
|
72
|
+
_propRule = propertyRules[schemaKey] || ((0, index_js_1.isValidator)(additionalFields) ? additionalFields : undefined);
|
|
74
73
|
if (_propRule) {
|
|
75
74
|
if (processedSchemaKeys[schemaKey])
|
|
76
75
|
continue;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isRecord = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Validates record object according to given "key" and "value" rules
|
|
7
7
|
* Converts properties according to rules if coerce option is set to 'true'.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.trimStart = exports.trimEnd = exports.trim = exports.stringSplit = exports.stringReplace = exports.isString = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Validates if value is "string".
|
|
7
7
|
* Converts input value to string if coerce option is set to 'true'.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isTuple = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
function isTuple(items, options) {
|
|
6
6
|
return (0, index_js_1.validator)('isTuple', function (input, context, _this) {
|
|
7
7
|
const coerce = options?.coerce || context.coerce;
|
|
@@ -25,8 +25,7 @@ function isTuple(items, options) {
|
|
|
25
25
|
itemContext.label = context.label ? context.label + `[${i}]` : undefined;
|
|
26
26
|
itemContext.index = i;
|
|
27
27
|
itemContext.location = location + '[' + i + ']';
|
|
28
|
-
itemContext.label = (itemContext.label || itemContext.property || 'Value at ') +
|
|
29
|
-
`[${i}]`;
|
|
28
|
+
itemContext.label = (itemContext.label || itemContext.property || 'Value at ') + `[${i}]`;
|
|
30
29
|
v = itemRule(input[i], itemContext);
|
|
31
30
|
out.push(v);
|
|
32
31
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exists = void 0;
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
|
+
/**
|
|
6
|
+
* Validates if property exists
|
|
7
|
+
* @validator exists
|
|
8
|
+
*/
|
|
9
|
+
function exists(options) {
|
|
10
|
+
return (0, index_js_1.validator)('exists', function (input, context, _this) {
|
|
11
|
+
if (input !== undefined || (context.scope && Object.getOwnPropertyDescriptor(context.scope, input)))
|
|
12
|
+
return input;
|
|
13
|
+
context.fail(_this, `{{label}} must exist`, input);
|
|
14
|
+
}, options);
|
|
15
|
+
}
|
|
16
|
+
exports.exists = exists;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLength = void 0;
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
|
+
/**
|
|
6
|
+
* Returns length of an Array, String, ArrayBuffer, Buffer or any object with the "length" property.
|
|
7
|
+
* @validator getLength
|
|
8
|
+
*/
|
|
9
|
+
function getLength() {
|
|
10
|
+
return (0, index_js_1.validator)('getLength', function (input, context, _this) {
|
|
11
|
+
if (typeof input === 'string')
|
|
12
|
+
return input.length;
|
|
13
|
+
if (Array.isArray(input))
|
|
14
|
+
return input.length;
|
|
15
|
+
if (input instanceof ArrayBuffer)
|
|
16
|
+
return input.byteLength;
|
|
17
|
+
if (input && typeof input === 'object' && typeof input.length === 'number')
|
|
18
|
+
return input.length;
|
|
19
|
+
if (input && typeof input === 'object' && typeof input.size === 'number')
|
|
20
|
+
return input.size;
|
|
21
|
+
context.fail(_this, `Unable to get length of {{label}}`, input);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.getLength = getLength;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.optional = void 0;
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
|
+
/**
|
|
6
|
+
* Makes sub-rule optional
|
|
7
|
+
* @validator optional
|
|
8
|
+
*/
|
|
9
|
+
function optional(nested, options) {
|
|
10
|
+
return (0, index_js_1.validator)('optional', function (input, context) {
|
|
11
|
+
if (input == null)
|
|
12
|
+
return input;
|
|
13
|
+
return nested(input, context);
|
|
14
|
+
}, options);
|
|
15
|
+
}
|
|
16
|
+
exports.optional = optional;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.required = void 0;
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
|
+
/**
|
|
6
|
+
* Makes sub-rule required
|
|
7
|
+
* @validator required
|
|
8
|
+
*/
|
|
9
|
+
function required(nested, options) {
|
|
10
|
+
return (0, index_js_1.validator)('required', function (input, context, _this) {
|
|
11
|
+
if (input == null) {
|
|
12
|
+
context.fail(_this, `{{label}} is required`, input);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
return nested(input, context);
|
|
16
|
+
}, options);
|
|
17
|
+
}
|
|
18
|
+
exports.required = required;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.union = void 0;
|
|
4
|
-
const index_js_1 = require("
|
|
4
|
+
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
@@ -13,7 +13,7 @@ function union(codecs) {
|
|
|
13
13
|
let v;
|
|
14
14
|
let passed = false;
|
|
15
15
|
// Mock fail method to prevent errors
|
|
16
|
-
context.fail = () => passed = false;
|
|
16
|
+
context.fail = () => (passed = false);
|
|
17
17
|
for (i = 0; i < l; i++) {
|
|
18
18
|
c = codecs[i];
|
|
19
19
|
try {
|