justus 0.5.3 → 0.5.5
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/dist/dts-generator.cjs +21 -3
- package/dist/dts-generator.cjs.map +1 -1
- package/dist/dts-generator.mjs +21 -3
- package/dist/dts-generator.mjs.map +1 -1
- package/dist/extra/arn.cjs +1 -1
- package/dist/extra/arn.cjs.map +1 -1
- package/dist/extra/arn.mjs +1 -1
- package/dist/extra/arn.mjs.map +1 -1
- package/dist/index.cjs +13 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +18 -6
- package/dist/index.mjs +9 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs +0 -7
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +7 -9
- package/dist/types.mjs +0 -6
- package/dist/types.mjs.map +1 -1
- package/dist/utilities.cjs +1 -0
- package/dist/utilities.cjs.map +1 -1
- package/dist/utilities.d.ts +2 -2
- package/dist/utilities.mjs +1 -0
- package/dist/utilities.mjs.map +1 -1
- package/dist/validators/array.cjs +6 -6
- package/dist/validators/array.cjs.map +1 -1
- package/dist/validators/array.d.ts +6 -6
- package/dist/validators/array.mjs +4 -4
- package/dist/validators/array.mjs.map +1 -1
- package/dist/validators/bigint.cjs +146 -0
- package/dist/validators/bigint.cjs.map +6 -0
- package/dist/validators/bigint.d.ts +46 -0
- package/dist/validators/bigint.mjs +118 -0
- package/dist/validators/bigint.mjs.map +6 -0
- package/dist/validators/boolean.cjs +5 -5
- package/dist/validators/boolean.cjs.map +1 -1
- package/dist/validators/boolean.d.ts +2 -2
- package/dist/validators/boolean.mjs +4 -4
- package/dist/validators/boolean.mjs.map +1 -1
- package/dist/validators/constant.cjs +2 -1
- package/dist/validators/constant.cjs.map +1 -1
- package/dist/validators/constant.d.ts +2 -2
- package/dist/validators/constant.mjs +2 -1
- package/dist/validators/constant.mjs.map +1 -1
- package/dist/validators/date.cjs +4 -4
- package/dist/validators/date.cjs.map +1 -1
- package/dist/validators/date.d.ts +2 -2
- package/dist/validators/date.mjs +3 -3
- package/dist/validators/date.mjs.map +1 -1
- package/dist/validators/never.cjs +1 -1
- package/dist/validators/never.cjs.map +1 -1
- package/dist/validators/never.mjs +2 -2
- package/dist/validators/never.mjs.map +1 -1
- package/dist/validators/number.cjs +9 -9
- package/dist/validators/number.cjs.map +1 -1
- package/dist/validators/number.d.ts +4 -4
- package/dist/validators/number.mjs +8 -8
- package/dist/validators/number.mjs.map +1 -1
- package/dist/validators/object.cjs +13 -11
- package/dist/validators/object.cjs.map +1 -1
- package/dist/validators/object.d.ts +2 -2
- package/dist/validators/object.mjs +12 -10
- package/dist/validators/object.mjs.map +1 -1
- package/dist/validators/optional.cjs +1 -1
- package/dist/validators/optional.cjs.map +1 -1
- package/dist/validators/optional.mjs +2 -2
- package/dist/validators/optional.mjs.map +1 -1
- package/dist/validators/string.cjs +6 -6
- package/dist/validators/string.cjs.map +1 -1
- package/dist/validators/string.d.ts +4 -4
- package/dist/validators/string.mjs +5 -5
- package/dist/validators/string.mjs.map +1 -1
- package/dist/validators/union.d.ts +2 -2
- package/package.json +3 -5
- package/src/dts-generator.ts +22 -3
- package/src/extra/arn.ts +1 -1
- package/src/index.ts +26 -8
- package/src/types.ts +7 -12
- package/src/utilities.ts +3 -1
- package/src/validators/array.ts +9 -7
- package/src/validators/bigint.ts +147 -0
- package/src/validators/boolean.ts +3 -3
- package/src/validators/constant.ts +4 -3
- package/src/validators/date.ts +2 -2
- package/src/validators/never.ts +2 -2
- package/src/validators/number.ts +10 -10
- package/src/validators/object.ts +11 -10
- package/src/validators/optional.ts +2 -2
- package/src/validators/string.ts +7 -7
- package/src/validators/union.ts +2 -2
package/dist/types.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/types.ts"],
|
|
4
|
-
"mappings": ";AAgBA,OAAO,iBAAiB,QAAQ;AAAA,EAC9B,i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;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AAC7B,sBAAyB;AAUlB,SAAS,aAAa,YAAmC;AAC9D,kCAAa,eAAe,QAAW,uCAAuC;AAG9E,MAAI,eAAe;AAAM,WAAO,KAAK,yBAAS,IAAI,UAAU,GAAG,IAAI;AAGnE,MAAW,WAAY,OAAO,eAAe,GAAG;AAC9C,WAAc,WAAY,OAAO,eAAe;AAAA,EAClD;AAGA,UAAQ,OAAO,YAAY;AAAA,IAEzB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,KAAK,yBAAS,IAAI,UAAU,GAAG,UAAU;AAAA,IAGlD,KAAK;AAEH,UAAI,MAAM,QAAQ,UAAU;AAAG,eAAO,KAAK,yBAAS,IAAI,OAAO,GAAG,UAAU;AAE5E,aAAO,KAAK,yBAAS,IAAI,QAAQ,GAAG,UAAoB;AAAA,IAG1D;AACE,YAAM,IAAI,UAAU,4BAA4B,OAAO,UAAU,GAAG;AAAA,EACxE;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/utilities.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Validation, Validator } from './types';
|
|
1
|
+
import type { InferInput, InferValidation, Validation, Validator } from './types';
|
|
2
2
|
/** Return the `Validator` for the given `Validation` */
|
|
3
|
-
export declare function getValidator(validation:
|
|
3
|
+
export declare function getValidator<V extends Validation>(validation: V): Validator<InferValidation<V>, InferInput<V>>;
|
package/dist/utilities.mjs
CHANGED
package/dist/utilities.mjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/utilities.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;
|
|
4
|
+
"mappings": ";AAAA,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AAUlB,SAAS,aAAa,YAAmC;AAC9D,eAAa,eAAe,QAAW,uCAAuC;AAG9E,MAAI,eAAe;AAAM,WAAO,KAAK,SAAS,IAAI,UAAU,GAAG,IAAI;AAGnE,MAAW,WAAY,OAAO,eAAe,GAAG;AAC9C,WAAc,WAAY,OAAO,eAAe;AAAA,EAClD;AAGA,UAAQ,OAAO,YAAY;AAAA,IAEzB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,KAAK,SAAS,IAAI,UAAU,GAAG,UAAU;AAAA,IAGlD,KAAK;AAEH,UAAI,MAAM,QAAQ,UAAU;AAAG,eAAO,KAAK,SAAS,IAAI,OAAO,GAAG,UAAU;AAE5E,aAAO,KAAK,SAAS,IAAI,QAAQ,GAAG,UAAoB;AAAA,IAG1D;AACE,YAAM,IAAI,UAAU,4BAA4B,OAAO,UAAU,GAAG;AAAA,EACxE;AACF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -23,8 +23,8 @@ __export(array_exports, {
|
|
|
23
23
|
AnyArrayValidator: () => AnyArrayValidator,
|
|
24
24
|
ArrayValidator: () => ArrayValidator,
|
|
25
25
|
array: () => array,
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
arrayOf: () => arrayOf,
|
|
27
|
+
arrayValidatorFactory: () => arrayValidatorFactory
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(array_exports);
|
|
30
30
|
var import_errors = require("../errors.cjs");
|
|
@@ -87,11 +87,11 @@ var ArrayValidator = class extends import_types.AbstractValidator {
|
|
|
87
87
|
return builder.assert(clone);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
-
function
|
|
90
|
+
function arrayValidatorFactory(constraints) {
|
|
91
91
|
const items = constraints.items ? (0, import_utilities.getValidator)(constraints.items) : import_any.any;
|
|
92
92
|
return new ArrayValidator({ ...constraints, items });
|
|
93
93
|
}
|
|
94
|
-
var array = (0, import_types.makeValidatorFactory)(new AnyArrayValidator(),
|
|
94
|
+
var array = (0, import_types.makeValidatorFactory)(new AnyArrayValidator(), arrayValidatorFactory);
|
|
95
95
|
function arrayOf(validation) {
|
|
96
96
|
return new ArrayValidator({ items: (0, import_utilities.getValidator)(validation) });
|
|
97
97
|
}
|
|
@@ -100,7 +100,7 @@ function arrayOf(validation) {
|
|
|
100
100
|
AnyArrayValidator,
|
|
101
101
|
ArrayValidator,
|
|
102
102
|
array,
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
arrayOf,
|
|
104
|
+
arrayValidatorFactory
|
|
105
105
|
});
|
|
106
106
|
//# sourceMappingURL=array.cjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/validators/array.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuE;AACvE,mBAAwD;AACxD,uBAA6B;AAC7B,iBAAoB;AAqBb,IAAM,oBAAN,cAAyC,+
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuE;AACvE,mBAAwD;AACxD,uBAA6B;AAC7B,iBAAoB;AAqBb,IAAM,oBAAN,cAAyC,+BAAuB;AAAA,EACrE,SAAS,OAAqB;AAC5B,wCAAiB,MAAM,QAAQ,KAAK,GAAG,yBAAyB;AAChE,WAAO,CAAE,GAAG,KAAM;AAAA,EACpB;AACF;AAGO,IAAM,iBAAN,cAAuC,+BAA4B;AAAA,EAC/D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,UAA0C,CAAC,GAAG;AACxD,UAAM;AAEN,UAAM;AAAA,MACJ,QAAQ;AAAA,MACR,WAAW,OAAO;AAAA,MAClB,WAAW;AAAA,MACX,cAAc;AAAA,IAChB,IAAI;AAEJ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AGjF,SAAS,QAA8B,YAAiE;AAC7G,SAAO,IAAI,eAAe,EAAE,WAAO,+BAAa,UAAU,EAAE,CAAC;AAC/D;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractValidator } from '../types';
|
|
2
|
-
import type { InferValidation, Validation, ValidationOptions, Validator } from '../types';
|
|
2
|
+
import type { InferInput, InferValidation, Validation, ValidationOptions, Validator } from '../types';
|
|
3
3
|
/** Constraints to validate an `Array` with. */
|
|
4
4
|
export interface ArrayConstraints<V extends Validation> {
|
|
5
5
|
/** The _maximum_ number of elements a valid `Array`: `value.length <= maxItems` */
|
|
@@ -12,11 +12,11 @@ export interface ArrayConstraints<V extends Validation> {
|
|
|
12
12
|
items?: V;
|
|
13
13
|
}
|
|
14
14
|
/** Basic validator for `Array` instances. */
|
|
15
|
-
export declare class AnyArrayValidator<T = any> extends AbstractValidator<T[]
|
|
15
|
+
export declare class AnyArrayValidator<T = any> extends AbstractValidator<T[]> {
|
|
16
16
|
validate(value: unknown): T[];
|
|
17
17
|
}
|
|
18
18
|
/** A validator for `Array` instances with constraints. */
|
|
19
|
-
export declare class ArrayValidator<T> extends AbstractValidator<T[]> {
|
|
19
|
+
export declare class ArrayValidator<T, I = T> extends AbstractValidator<T[], I[]> {
|
|
20
20
|
readonly maxItems: number;
|
|
21
21
|
readonly minItems: number;
|
|
22
22
|
readonly uniqueItems: boolean;
|
|
@@ -24,8 +24,8 @@ export declare class ArrayValidator<T> extends AbstractValidator<T[]> {
|
|
|
24
24
|
constructor(options?: ArrayConstraints<Validator<T>>);
|
|
25
25
|
validate(value: unknown, options?: ValidationOptions): T[];
|
|
26
26
|
}
|
|
27
|
-
export declare function
|
|
27
|
+
export declare function arrayValidatorFactory<V extends Validation>(constraints: ArrayConstraints<V>): ArrayValidator<InferValidation<V>, InferInput<V>>;
|
|
28
28
|
/** Validate `Array`s. */
|
|
29
|
-
export declare const array: typeof
|
|
29
|
+
export declare const array: typeof arrayValidatorFactory & AnyArrayValidator<any>;
|
|
30
30
|
/** Validate `Array`s containing only the specified elements. */
|
|
31
|
-
export declare function arrayOf<V extends Validation>(validation: V): Validator<InferValidation<V>[]>;
|
|
31
|
+
export declare function arrayOf<V extends Validation>(validation: V): Validator<InferValidation<V>[], InferInput<V>[]>;
|
|
@@ -59,11 +59,11 @@ var ArrayValidator = class extends AbstractValidator {
|
|
|
59
59
|
return builder.assert(clone);
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
function
|
|
62
|
+
function arrayValidatorFactory(constraints) {
|
|
63
63
|
const items = constraints.items ? getValidator(constraints.items) : any;
|
|
64
64
|
return new ArrayValidator({ ...constraints, items });
|
|
65
65
|
}
|
|
66
|
-
var array = makeValidatorFactory(new AnyArrayValidator(),
|
|
66
|
+
var array = makeValidatorFactory(new AnyArrayValidator(), arrayValidatorFactory);
|
|
67
67
|
function arrayOf(validation) {
|
|
68
68
|
return new ArrayValidator({ items: getValidator(validation) });
|
|
69
69
|
}
|
|
@@ -71,7 +71,7 @@ export {
|
|
|
71
71
|
AnyArrayValidator,
|
|
72
72
|
ArrayValidator,
|
|
73
73
|
array,
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
arrayOf,
|
|
75
|
+
arrayValidatorFactory
|
|
76
76
|
};
|
|
77
77
|
//# sourceMappingURL=array.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/validators/array.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,cAAc,kBAAkB,8BAA8B;AACvE,SAAS,mBAAmB,4BAA4B;AACxD,SAAS,oBAAoB;AAC7B,SAAS,WAAW;AAqBb,IAAM,oBAAN,cAAyC,
|
|
4
|
+
"mappings": ";AAAA,SAAS,cAAc,kBAAkB,8BAA8B;AACvE,SAAS,mBAAmB,4BAA4B;AACxD,SAAS,oBAAoB;AAC7B,SAAS,WAAW;AAqBb,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OAAO;AACL,gBAAM,CAAC,IAAI,MAAM,QAAQ;AAAA,QAC3B;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,OAAO,OAAO,CAAC;AAAA,MACzB;AAAA,IACF,CAAC;AAED,WAAO,QAAQ,OAAO,KAAK;AAAA,EAC7B;AACF;AAIO,SAAS,sBACZ,aACiD;AACnD,QAAM,QAAQ,YAAY,QAAQ,aAAa,YAAY,KAAK,IAAI;AACpE,SAAO,IAAI,eAAoB,EAAE,GAAG,aAAa,MAAM,CAAC;AAC1D;AAGO,IAAM,QAAQ,qBAAqB,IAAI,kBAAkB,GAAG,qBAAqB;AAGjF,SAAS,QAA8B,YAAiE;AAC7G,SAAO,IAAI,eAAe,EAAE,OAAO,aAAa,UAAU,EAAE,CAAC;AAC/D;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// validators/bigint.ts
|
|
21
|
+
var bigint_exports = {};
|
|
22
|
+
__export(bigint_exports, {
|
|
23
|
+
AnyBigIntValidator: () => AnyBigIntValidator,
|
|
24
|
+
BigIntValidator: () => BigIntValidator,
|
|
25
|
+
bigint: () => bigint,
|
|
26
|
+
bigintValidatorFactory: () => bigintValidatorFactory
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(bigint_exports);
|
|
29
|
+
var import_errors = require("../errors.cjs");
|
|
30
|
+
var import_types = require("../types.cjs");
|
|
31
|
+
var AnyBigIntValidator = class extends import_types.AbstractValidator {
|
|
32
|
+
validate(value) {
|
|
33
|
+
if (typeof value === "number") {
|
|
34
|
+
try {
|
|
35
|
+
value = BigInt(value);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
throw new import_errors.ValidationError("BigInt can not be parsed from number");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
(0, import_errors.assertValidation)(typeof value === "bigint", 'Value is not a "bigint"');
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var BigIntValidator = class extends import_types.AbstractValidator {
|
|
45
|
+
fromString;
|
|
46
|
+
fromNumber;
|
|
47
|
+
exclusiveMaximum;
|
|
48
|
+
exclusiveMinimum;
|
|
49
|
+
maximum;
|
|
50
|
+
minimum;
|
|
51
|
+
multipleOf;
|
|
52
|
+
brand;
|
|
53
|
+
constructor(constraints = {}) {
|
|
54
|
+
super();
|
|
55
|
+
const {
|
|
56
|
+
exclusiveMaximum,
|
|
57
|
+
exclusiveMinimum,
|
|
58
|
+
maximum,
|
|
59
|
+
minimum,
|
|
60
|
+
multipleOf,
|
|
61
|
+
fromString = false,
|
|
62
|
+
fromNumber = true
|
|
63
|
+
} = constraints;
|
|
64
|
+
if ("brand" in constraints)
|
|
65
|
+
this.brand = constraints.brand;
|
|
66
|
+
this.fromString = fromString;
|
|
67
|
+
this.fromNumber = fromNumber;
|
|
68
|
+
const _exclusiveMaximum = exclusiveMaximum === void 0 ? void 0 : BigInt(exclusiveMaximum);
|
|
69
|
+
const _exclusiveMinimum = exclusiveMinimum === void 0 ? void 0 : BigInt(exclusiveMinimum);
|
|
70
|
+
const _maximum = maximum === void 0 ? void 0 : BigInt(maximum);
|
|
71
|
+
const _minimum = minimum === void 0 ? void 0 : BigInt(minimum);
|
|
72
|
+
const _multipleOf = multipleOf === void 0 ? void 0 : BigInt(multipleOf);
|
|
73
|
+
if (_maximum !== void 0 && _minimum !== void 0) {
|
|
74
|
+
(0, import_errors.assertSchema)(_maximum >= _minimum, `Constraint "minimum" (${_minimum}) is greater than "maximum" (${_maximum})`);
|
|
75
|
+
}
|
|
76
|
+
if (_exclusiveMaximum !== void 0 && _minimum !== void 0) {
|
|
77
|
+
(0, import_errors.assertSchema)(
|
|
78
|
+
_exclusiveMaximum > _minimum,
|
|
79
|
+
`Constraint "exclusiveMaximum" (${_exclusiveMaximum}) must be greater than "minimum" (${_minimum})`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (_exclusiveMinimum !== void 0 && _maximum != void 0) {
|
|
83
|
+
(0, import_errors.assertSchema)(
|
|
84
|
+
_maximum > _exclusiveMinimum,
|
|
85
|
+
`Constraint "maximum" (${_maximum}) must be greater than "exclusiveMinimum" (${_exclusiveMinimum})`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (_exclusiveMinimum != void 0 && _exclusiveMaximum !== void 0) {
|
|
89
|
+
(0, import_errors.assertSchema)(
|
|
90
|
+
_exclusiveMaximum > _exclusiveMinimum,
|
|
91
|
+
`Constraint "exclusiveMaximum" (${_exclusiveMaximum}) must be greater than "exclusiveMinimum" (${_exclusiveMinimum})`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
if (_multipleOf !== void 0) {
|
|
95
|
+
(0, import_errors.assertSchema)(_multipleOf > 0, `Constraint "multipleOf" (${_multipleOf}) must be greater than zero`);
|
|
96
|
+
}
|
|
97
|
+
this.exclusiveMaximum = _exclusiveMaximum;
|
|
98
|
+
this.exclusiveMinimum = _exclusiveMinimum;
|
|
99
|
+
this.maximum = _maximum;
|
|
100
|
+
this.minimum = _minimum;
|
|
101
|
+
this.multipleOf = _multipleOf;
|
|
102
|
+
}
|
|
103
|
+
validate(value) {
|
|
104
|
+
if (typeof value === "string" && this.fromString || typeof value === "number" && this.fromNumber) {
|
|
105
|
+
try {
|
|
106
|
+
value = BigInt(value);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
throw new import_errors.ValidationError("BigInt can not be parsed from " + typeof value);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
(0, import_errors.assertValidation)(typeof value === "bigint", 'Value is not a "bigint"');
|
|
112
|
+
(0, import_errors.assertValidation)(
|
|
113
|
+
this.minimum === void 0 || value >= this.minimum,
|
|
114
|
+
`BigInt is less than ${this.minimum}`
|
|
115
|
+
);
|
|
116
|
+
(0, import_errors.assertValidation)(
|
|
117
|
+
this.maximum === void 0 || value <= this.maximum,
|
|
118
|
+
`BigInt is greater than ${this.maximum}`
|
|
119
|
+
);
|
|
120
|
+
(0, import_errors.assertValidation)(
|
|
121
|
+
this.exclusiveMinimum === void 0 || value > this.exclusiveMinimum,
|
|
122
|
+
`BigInt is less than or equal to ${this.exclusiveMinimum}`
|
|
123
|
+
);
|
|
124
|
+
(0, import_errors.assertValidation)(
|
|
125
|
+
this.exclusiveMaximum === void 0 || value < this.exclusiveMaximum,
|
|
126
|
+
`BigInt is greater than or equal to ${this.exclusiveMaximum}`
|
|
127
|
+
);
|
|
128
|
+
(0, import_errors.assertValidation)(
|
|
129
|
+
this.multipleOf === void 0 || !(value % this.multipleOf),
|
|
130
|
+
`BigInt is not a multiple of ${this.multipleOf}`
|
|
131
|
+
);
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
function bigintValidatorFactory(constraints) {
|
|
136
|
+
return new BigIntValidator(constraints);
|
|
137
|
+
}
|
|
138
|
+
var bigint = (0, import_types.makeValidatorFactory)(new AnyBigIntValidator(), bigintValidatorFactory);
|
|
139
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
140
|
+
0 && (module.exports = {
|
|
141
|
+
AnyBigIntValidator,
|
|
142
|
+
BigIntValidator,
|
|
143
|
+
bigint,
|
|
144
|
+
bigintValidatorFactory
|
|
145
|
+
});
|
|
146
|
+
//# sourceMappingURL=bigint.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/validators/bigint.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgE;AAChE,mBAAwD;AA+BjD,IAAM,qBAAN,cAAiC,+BAA0B;AAAA,EAChE,SAAS,OAAwB;AAC/B,QAAI,OAAO,UAAU,UAAU;AAC7B,UAAI;AACF,gBAAQ,OAAO,KAAK;AAAA,MACtB,SAAS,OAAO;AACd,cAAM,IAAI,8BAAgB,sCAAsC;AAAA,MAClE;AAAA,IACF;AACA,wCAAiB,OAAO,UAAU,UAAU,yBAAyB;AACrE,WAAO;AAAA,EACT;AACF;AAGO,IAAM,kBAAN,cAAyD,+BAA6B;AAAA,EAClF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,cAAiC,CAAC,GAAG;AAC/C,UAAM;AAEN,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb,aAAa;AAAA,IACf,IAAI;AAEJ,QAAI,WAAW;AAAa,WAAK,QAAe,YAAa;AAC7D,SAAK,aAAa;AAClB,SAAK,aAAa;AAElB,UAAM,oBAAoB,qBAAqB,SAAY,SAAY,OAAO,gBAAgB;AAC9F,UAAM,oBAAoB,qBAAqB,SAAY,SAAY,OAAO,gBAAgB;AAC9F,UAAM,WAAW,YAAY,SAAY,SAAY,O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AAAA,MAC7D,0BAA0B,KAAK,OAAO;AAAA,IAAE;AAC5C;AAAA,MAAkB,KAAK,qBAAqB,UAAe,QAAQ,KAAK;AAAA,MACpE,mCAAmC,KAAK,gBAAgB;AAAA,IAAE;AAC9D;AAAA,MAAkB,KAAK,qBAAqB,UAAe,QAAQ,KAAK;AAAA,MACpE,sCAAsC,KAAK,gBAAgB;AAAA,IAAE;AACjE;AAAA,MAAkB,KAAK,eAAe,UAAe,EAAE,QAAQ,KAAK;AAAA,MAChE,+BAA+B,KAAK,UAAU;AAAA,IAAE;AAEpD,WAAO;AAAA,EACT;AACF;AAKO,SAAS,uBAAuB,aAAmD;AACxF,SAAO,IAAI,gBAAgB,WAAW;AACxC;AAGO,IAAM,aAAS,mCAAqB,IAAI,mBAAmB,GAAG,sBAAsB;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AbstractValidator } from '../types';
|
|
2
|
+
import type { Branding } from '../types';
|
|
3
|
+
/** Constraints to validate a `bigint` with. */
|
|
4
|
+
export interface BigIntConstraints {
|
|
5
|
+
/** The value for which a `bigint` must be multiple of for it to be valid */
|
|
6
|
+
multipleOf?: bigint | number;
|
|
7
|
+
/** The _inclusive_ maximum value for a valid `bigint`: `value <= maximum` */
|
|
8
|
+
maximum?: bigint | number;
|
|
9
|
+
/** The _inclusive_ minimum value for a valid `bigint`: `value >= minimum` */
|
|
10
|
+
minimum?: bigint | number;
|
|
11
|
+
/** The _exclusive_ maximum value for a valid `bigint`: `value < exclusiveMaximum` */
|
|
12
|
+
exclusiveMaximum?: bigint | number;
|
|
13
|
+
/** The _exclusive_ minimum value for a valid `bigint`: `value > exclusiveMaximum` */
|
|
14
|
+
exclusiveMinimum?: bigint | number;
|
|
15
|
+
/** Allow bigints to be parsed from strings (e.g. `123.456` or `0x0CAFE`, default: `false`) */
|
|
16
|
+
fromString?: boolean;
|
|
17
|
+
/** Allow bigints to be parsed from numbers (default: `true`) */
|
|
18
|
+
fromNumber?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Constraints to validate a `bigint` with extra branding information. */
|
|
21
|
+
export interface BrandedBigIntConstraints<B extends string> extends BigIntConstraints {
|
|
22
|
+
/** The _brand_ of the string (will generate a `__brand_${B}` type property */
|
|
23
|
+
brand: B;
|
|
24
|
+
}
|
|
25
|
+
/** A `Validator` validating any `bigint`. */
|
|
26
|
+
export declare class AnyBigIntValidator extends AbstractValidator<bigint> {
|
|
27
|
+
validate(value: unknown): bigint;
|
|
28
|
+
}
|
|
29
|
+
/** A `Validator` validating `bigint`s with constaints. */
|
|
30
|
+
export declare class BigIntValidator<N extends bigint = bigint> extends AbstractValidator<N, bigint> {
|
|
31
|
+
readonly fromString: boolean;
|
|
32
|
+
readonly fromNumber: boolean;
|
|
33
|
+
readonly exclusiveMaximum?: bigint;
|
|
34
|
+
readonly exclusiveMinimum?: bigint;
|
|
35
|
+
readonly maximum?: bigint;
|
|
36
|
+
readonly minimum?: bigint;
|
|
37
|
+
readonly multipleOf?: bigint;
|
|
38
|
+
readonly brand?: string;
|
|
39
|
+
constructor(constraints?: BigIntConstraints);
|
|
40
|
+
validate(value: unknown): N;
|
|
41
|
+
}
|
|
42
|
+
export declare function bigintValidatorFactory(constraints: BigIntConstraints): BigIntValidator<bigint>;
|
|
43
|
+
export declare function bigintValidatorFactory<N extends bigint>(constraints: BigIntConstraints): BigIntValidator<N>;
|
|
44
|
+
export declare function bigintValidatorFactory<B extends string>(constraints: BrandedBigIntConstraints<B>): BigIntValidator<bigint & Branding<B>>;
|
|
45
|
+
/** Validate `bigint`s. */
|
|
46
|
+
export declare const bigint: typeof bigintValidatorFactory & AnyBigIntValidator;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// validators/bigint.ts
|
|
2
|
+
import { assertSchema, assertValidation, ValidationError } from "../errors.mjs";
|
|
3
|
+
import { AbstractValidator, makeValidatorFactory } from "../types.mjs";
|
|
4
|
+
var AnyBigIntValidator = class extends AbstractValidator {
|
|
5
|
+
validate(value) {
|
|
6
|
+
if (typeof value === "number") {
|
|
7
|
+
try {
|
|
8
|
+
value = BigInt(value);
|
|
9
|
+
} catch (error) {
|
|
10
|
+
throw new ValidationError("BigInt can not be parsed from number");
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
assertValidation(typeof value === "bigint", 'Value is not a "bigint"');
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var BigIntValidator = class extends AbstractValidator {
|
|
18
|
+
fromString;
|
|
19
|
+
fromNumber;
|
|
20
|
+
exclusiveMaximum;
|
|
21
|
+
exclusiveMinimum;
|
|
22
|
+
maximum;
|
|
23
|
+
minimum;
|
|
24
|
+
multipleOf;
|
|
25
|
+
brand;
|
|
26
|
+
constructor(constraints = {}) {
|
|
27
|
+
super();
|
|
28
|
+
const {
|
|
29
|
+
exclusiveMaximum,
|
|
30
|
+
exclusiveMinimum,
|
|
31
|
+
maximum,
|
|
32
|
+
minimum,
|
|
33
|
+
multipleOf,
|
|
34
|
+
fromString = false,
|
|
35
|
+
fromNumber = true
|
|
36
|
+
} = constraints;
|
|
37
|
+
if ("brand" in constraints)
|
|
38
|
+
this.brand = constraints.brand;
|
|
39
|
+
this.fromString = fromString;
|
|
40
|
+
this.fromNumber = fromNumber;
|
|
41
|
+
const _exclusiveMaximum = exclusiveMaximum === void 0 ? void 0 : BigInt(exclusiveMaximum);
|
|
42
|
+
const _exclusiveMinimum = exclusiveMinimum === void 0 ? void 0 : BigInt(exclusiveMinimum);
|
|
43
|
+
const _maximum = maximum === void 0 ? void 0 : BigInt(maximum);
|
|
44
|
+
const _minimum = minimum === void 0 ? void 0 : BigInt(minimum);
|
|
45
|
+
const _multipleOf = multipleOf === void 0 ? void 0 : BigInt(multipleOf);
|
|
46
|
+
if (_maximum !== void 0 && _minimum !== void 0) {
|
|
47
|
+
assertSchema(_maximum >= _minimum, `Constraint "minimum" (${_minimum}) is greater than "maximum" (${_maximum})`);
|
|
48
|
+
}
|
|
49
|
+
if (_exclusiveMaximum !== void 0 && _minimum !== void 0) {
|
|
50
|
+
assertSchema(
|
|
51
|
+
_exclusiveMaximum > _minimum,
|
|
52
|
+
`Constraint "exclusiveMaximum" (${_exclusiveMaximum}) must be greater than "minimum" (${_minimum})`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (_exclusiveMinimum !== void 0 && _maximum != void 0) {
|
|
56
|
+
assertSchema(
|
|
57
|
+
_maximum > _exclusiveMinimum,
|
|
58
|
+
`Constraint "maximum" (${_maximum}) must be greater than "exclusiveMinimum" (${_exclusiveMinimum})`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
if (_exclusiveMinimum != void 0 && _exclusiveMaximum !== void 0) {
|
|
62
|
+
assertSchema(
|
|
63
|
+
_exclusiveMaximum > _exclusiveMinimum,
|
|
64
|
+
`Constraint "exclusiveMaximum" (${_exclusiveMaximum}) must be greater than "exclusiveMinimum" (${_exclusiveMinimum})`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
if (_multipleOf !== void 0) {
|
|
68
|
+
assertSchema(_multipleOf > 0, `Constraint "multipleOf" (${_multipleOf}) must be greater than zero`);
|
|
69
|
+
}
|
|
70
|
+
this.exclusiveMaximum = _exclusiveMaximum;
|
|
71
|
+
this.exclusiveMinimum = _exclusiveMinimum;
|
|
72
|
+
this.maximum = _maximum;
|
|
73
|
+
this.minimum = _minimum;
|
|
74
|
+
this.multipleOf = _multipleOf;
|
|
75
|
+
}
|
|
76
|
+
validate(value) {
|
|
77
|
+
if (typeof value === "string" && this.fromString || typeof value === "number" && this.fromNumber) {
|
|
78
|
+
try {
|
|
79
|
+
value = BigInt(value);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
throw new ValidationError("BigInt can not be parsed from " + typeof value);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
assertValidation(typeof value === "bigint", 'Value is not a "bigint"');
|
|
85
|
+
assertValidation(
|
|
86
|
+
this.minimum === void 0 || value >= this.minimum,
|
|
87
|
+
`BigInt is less than ${this.minimum}`
|
|
88
|
+
);
|
|
89
|
+
assertValidation(
|
|
90
|
+
this.maximum === void 0 || value <= this.maximum,
|
|
91
|
+
`BigInt is greater than ${this.maximum}`
|
|
92
|
+
);
|
|
93
|
+
assertValidation(
|
|
94
|
+
this.exclusiveMinimum === void 0 || value > this.exclusiveMinimum,
|
|
95
|
+
`BigInt is less than or equal to ${this.exclusiveMinimum}`
|
|
96
|
+
);
|
|
97
|
+
assertValidation(
|
|
98
|
+
this.exclusiveMaximum === void 0 || value < this.exclusiveMaximum,
|
|
99
|
+
`BigInt is greater than or equal to ${this.exclusiveMaximum}`
|
|
100
|
+
);
|
|
101
|
+
assertValidation(
|
|
102
|
+
this.multipleOf === void 0 || !(value % this.multipleOf),
|
|
103
|
+
`BigInt is not a multiple of ${this.multipleOf}`
|
|
104
|
+
);
|
|
105
|
+
return value;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
function bigintValidatorFactory(constraints) {
|
|
109
|
+
return new BigIntValidator(constraints);
|
|
110
|
+
}
|
|
111
|
+
var bigint = makeValidatorFactory(new AnyBigIntValidator(), bigintValidatorFactory);
|
|
112
|
+
export {
|
|
113
|
+
AnyBigIntValidator,
|
|
114
|
+
BigIntValidator,
|
|
115
|
+
bigint,
|
|
116
|
+
bigintValidatorFactory
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=bigint.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/validators/bigint.ts"],
|
|
4
|
+
"mappings": ";AAAA,SAAS,cAAc,kBAAkB,uBAAuB;AAChE,SAAS,mBAAmB,4BAA4B;AA+BjD,IAAM,qBAAN,cAAiC,kBAA0B;AAAA,EAChE,SAAS,OAAwB;AAC/B,QAAI,OAAO,UAAU,UAAU;AAC7B,UAAI;AACF,gBAAQ,OAAO,KAAK;A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exports = {};
|
|
|
22
22
|
__export(boolean_exports, {
|
|
23
23
|
BooleanValidator: () => BooleanValidator,
|
|
24
24
|
boolean: () => boolean,
|
|
25
|
-
|
|
25
|
+
booleanValidatorFactory: () => booleanValidatorFactory
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(boolean_exports);
|
|
28
28
|
var import_errors = require("../errors.cjs");
|
|
@@ -35,7 +35,7 @@ var BooleanValidator = class extends import_types.AbstractValidator {
|
|
|
35
35
|
this.fromString = fromString;
|
|
36
36
|
}
|
|
37
37
|
validate(value) {
|
|
38
|
-
if (typeof value
|
|
38
|
+
if (typeof value === "string" && this.fromString) {
|
|
39
39
|
const string = value.toLowerCase();
|
|
40
40
|
const parsed = string === "true" ? true : string === "false" ? false : void 0;
|
|
41
41
|
(0, import_errors.assertValidation)(parsed !== void 0, "Boolean can not be parsed from string");
|
|
@@ -45,14 +45,14 @@ var BooleanValidator = class extends import_types.AbstractValidator {
|
|
|
45
45
|
return value;
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
function
|
|
48
|
+
function booleanValidatorFactory(constraints) {
|
|
49
49
|
return new BooleanValidator(constraints);
|
|
50
50
|
}
|
|
51
|
-
var boolean = (0, import_types.makeValidatorFactory)(new BooleanValidator(),
|
|
51
|
+
var boolean = (0, import_types.makeValidatorFactory)(new BooleanValidator(), booleanValidatorFactory);
|
|
52
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
53
53
|
0 && (module.exports = {
|
|
54
54
|
BooleanValidator,
|
|
55
55
|
boolean,
|
|
56
|
-
|
|
56
|
+
booleanValidatorFactory
|
|
57
57
|
});
|
|
58
58
|
//# sourceMappingURL=boolean.cjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/validators/boolean.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,mBAAwD;AAejD,IAAM,mBAAN,cAA+B,+BAA2B;AAAA,EACtD;AAAA,EAET,YAAY,cAAkC,CAAC,GAAG;AAChD,UAAM;AACN,UAAM,EAAE,aAAa,MAAM,IAAI;AAC/B,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,SAAS,OAAyB;AAEhC,QAAK,OAAO,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,mBAAwD;AAejD,IAAM,mBAAN,cAA+B,+BAA2B;AAAA,EACtD;AAAA,EAET,YAAY,cAAkC,CAAC,GAAG;AAChD,UAAM;AACN,UAAM,EAAE,aAAa,MAAM,IAAI;AAC/B,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,SAAS,OAAyB;AAEhC,QAAK,OAAO,UAAU,YAAc,KAAK,YAAa;AACpD,YAAM,SAAS,MAAM,YAAY;AACjC,YAAM,SAAS,WAAW,SAAS,OAAO,WAAW,UAAU,QAAQ;AACvE,0CAAiB,WAAW,QAAW,uCAAuC;AAC9E,cAAQ;AAAA,IACV;AAEA,wCAAiB,OAAO,UAAU,WAAW,0BAA0B;AACvE,WAAO;AAAA,EACT;AACF;AAEO,SAAS,wBAAwB,aAAmD;AACzF,SAAO,IAAI,iBAAiB,WAAW;AACzC;AAGO,IAAM,cAAU,mCAAqB,IAAI,iBAAiB,GAAG,uBAAuB;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -15,6 +15,6 @@ export declare class BooleanValidator extends AbstractValidator<boolean> {
|
|
|
15
15
|
constructor(constraints?: BooleanConstraints);
|
|
16
16
|
validate(value: unknown): boolean;
|
|
17
17
|
}
|
|
18
|
-
export declare function
|
|
18
|
+
export declare function booleanValidatorFactory(constraints: BooleanConstraints): BooleanValidator;
|
|
19
19
|
/** The `Validator` for `boolean`s. */
|
|
20
|
-
export declare const boolean: typeof
|
|
20
|
+
export declare const boolean: typeof booleanValidatorFactory & BooleanValidator;
|
|
@@ -9,7 +9,7 @@ var BooleanValidator = class extends AbstractValidator {
|
|
|
9
9
|
this.fromString = fromString;
|
|
10
10
|
}
|
|
11
11
|
validate(value) {
|
|
12
|
-
if (typeof value
|
|
12
|
+
if (typeof value === "string" && this.fromString) {
|
|
13
13
|
const string = value.toLowerCase();
|
|
14
14
|
const parsed = string === "true" ? true : string === "false" ? false : void 0;
|
|
15
15
|
assertValidation(parsed !== void 0, "Boolean can not be parsed from string");
|
|
@@ -19,13 +19,13 @@ var BooleanValidator = class extends AbstractValidator {
|
|
|
19
19
|
return value;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
function
|
|
22
|
+
function booleanValidatorFactory(constraints) {
|
|
23
23
|
return new BooleanValidator(constraints);
|
|
24
24
|
}
|
|
25
|
-
var boolean = makeValidatorFactory(new BooleanValidator(),
|
|
25
|
+
var boolean = makeValidatorFactory(new BooleanValidator(), booleanValidatorFactory);
|
|
26
26
|
export {
|
|
27
27
|
BooleanValidator,
|
|
28
28
|
boolean,
|
|
29
|
-
|
|
29
|
+
booleanValidatorFactory
|
|
30
30
|
};
|
|
31
31
|
//# sourceMappingURL=boolean.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/validators/boolean.ts"],
|
|
4
|
-
"mappings": ";AAAA,SAAS,wBAAwB;AACjC,SAAS,mBAAmB,4BAA4B;AAejD,IAAM,mBAAN,cAA+B,kBAA2B;AAAA,EACtD;AAAA,EAET,YAAY,cAAkC,CAAC,GAAG;AAChD,UAAM;AACN,UAAM,EAAE,aAAa,MAAM,IAAI;AAC/B,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,SAAS,OAAyB;AAEhC,QAAK,OAAO,
|
|
4
|
+
"mappings": ";AAAA,SAAS,wBAAwB;AACjC,SAAS,mBAAmB,4BAA4B;AAejD,IAAM,mBAAN,cAA+B,kBAA2B;AAAA,EACtD;AAAA,EAET,YAAY,cAAkC,CAAC,GAAG;AAChD,UAAM;AACN,UAAM,EAAE,aAAa,MAAM,IAAI;AAC/B,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,SAAS,OAAyB;AAEhC,QAAK,OAAO,UAAU,YAAc,KAAK,YAAa;AACpD,YAAM,SAAS,MAAM,YAAY;AACjC,YAAM,SAAS,WAAW,SAAS,OAAO,WAAW,UAAU,QAAQ;AACvE,uBAAiB,WAAW,QAAW,uCAAuC;AAC9E,cAAQ;AAAA,IACV;AAEA,qBAAiB,OAAO,UAAU,WAAW,0BAA0B;AACvE,WAAO;AAAA,EACT;AACF;AAEO,SAAS,wBAAwB,aAAmD;AACzF,SAAO,IAAI,iBAAiB,WAAW;AACzC;AAGO,IAAM,UAAU,qBAAqB,IAAI,iBAAiB,GAAG,uBAAuB;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -34,7 +34,8 @@ var ConstantValidator = class extends import_types.AbstractValidator {
|
|
|
34
34
|
this.constant = constant2;
|
|
35
35
|
}
|
|
36
36
|
validate(value) {
|
|
37
|
-
|
|
37
|
+
const extra = this.constant === null ? "" : ` (${typeof this.constant})`;
|
|
38
|
+
(0, import_errors.assertValidation)(value === this.constant, `Value does not match constant "${this.constant}"${extra}`);
|
|
38
39
|
return value;
|
|
39
40
|
}
|
|
40
41
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/validators/constant.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,sBAAyB;AACzB,mBAAkC;AAK3B,IAAM,oBAAN,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,sBAAyB;AACzB,mBAAkC;AAK3B,IAAM,oBAAN,cAAqF,+BAAqB;AAAA,EACtG;AAAA,EAET,YAAYA,WAAa;AACvB,UAAM;AACN,SAAK,WAAWA;AAAA,EAClB;AAAA,EAEA,SAAS,OAAmB;AAC1B,UAAM,QAAQ,KAAK,aAAa,OAAO,KAAK,KAAK,OAAO,KAAK,QAAQ;AACrE,wCAAiB,UAAU,KAAK,UAAU,kCAAkC,KAAK,QAAQ,IAAI,KAAK,EAAE;AACpG,WAAO;AAAA,EACT;AACF;AAGO,SAAS,SAA8DA,WAA2B;AACvG,SAAO,IAAI,kBAAkBA,SAAQ;AACvC;AAGA,yBAAS,IAAI,YAAY,iBAAiB;",
|
|
5
5
|
"names": ["constant"]
|
|
6
6
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AbstractValidator } from '../types';
|
|
2
2
|
import type { Validator } from '../types';
|
|
3
3
|
/** A `Validator` for _constants_. */
|
|
4
|
-
export declare class ConstantValidator<T extends string | number | boolean | null> extends AbstractValidator<T> {
|
|
4
|
+
export declare class ConstantValidator<T extends string | number | boolean | bigint | null> extends AbstractValidator<T> {
|
|
5
5
|
readonly constant: T;
|
|
6
6
|
constructor(constant: T);
|
|
7
7
|
validate(value: unknown): T;
|
|
8
8
|
}
|
|
9
9
|
/** Validate _constants_. */
|
|
10
|
-
export declare function constant<T extends string | number | boolean | null>(constant: T): Validator<T>;
|
|
10
|
+
export declare function constant<T extends string | number | boolean | bigint | null>(constant: T): Validator<T>;
|