bguard 0.0.5 → 0.0.6
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/lib/InferType.js +1 -19
- package/lib/InferType.js.map +1 -1
- package/lib/asserts/array/index.js +7 -86
- package/lib/asserts/array/index.js.map +1 -1
- package/lib/asserts/array/index.mjs +7 -59
- package/lib/asserts/array/index.mjs.map +1 -1
- package/lib/asserts/boolean/index.js +7 -114
- package/lib/asserts/boolean/index.js.map +1 -1
- package/lib/asserts/boolean/index.mjs +7 -87
- package/lib/asserts/boolean/index.mjs.map +1 -1
- package/lib/asserts/common/equalTo.js +4 -50
- package/lib/asserts/common/equalTo.js.map +1 -1
- package/lib/asserts/common/equalTo.mjs +4 -23
- package/lib/asserts/common/equalTo.mjs.map +1 -1
- package/lib/asserts/common/index.js +6 -68
- package/lib/asserts/common/index.js.map +1 -1
- package/lib/asserts/common/index.mjs +6 -41
- package/lib/asserts/common/index.mjs.map +1 -1
- package/lib/asserts/number/index.js +8 -108
- package/lib/asserts/number/index.js.map +1 -1
- package/lib/asserts/number/index.mjs +8 -81
- package/lib/asserts/number/index.mjs.map +1 -1
- package/lib/asserts/number/max.js +6 -47
- package/lib/asserts/number/max.js.map +1 -1
- package/lib/asserts/number/max.mjs +3 -17
- package/lib/asserts/number/max.mjs.map +1 -1
- package/lib/asserts/number/maxExcluded.js +6 -47
- package/lib/asserts/number/maxExcluded.js.map +1 -1
- package/lib/asserts/number/maxExcluded.mjs +3 -17
- package/lib/asserts/number/maxExcluded.mjs.map +1 -1
- package/lib/asserts/number/min.js +6 -47
- package/lib/asserts/number/min.js.map +1 -1
- package/lib/asserts/number/min.mjs +3 -17
- package/lib/asserts/number/min.mjs.map +1 -1
- package/lib/asserts/number/minExcluded.js +6 -47
- package/lib/asserts/number/minExcluded.js.map +1 -1
- package/lib/asserts/number/minExcluded.mjs +3 -17
- package/lib/asserts/number/minExcluded.mjs.map +1 -1
- package/lib/asserts/number/negative.js +6 -47
- package/lib/asserts/number/negative.js.map +1 -1
- package/lib/asserts/number/negative.mjs +3 -17
- package/lib/asserts/number/negative.mjs.map +1 -1
- package/lib/asserts/number/positive.js +6 -47
- package/lib/asserts/number/positive.js.map +1 -1
- package/lib/asserts/number/positive.mjs +3 -17
- package/lib/asserts/number/positive.mjs.map +1 -1
- package/lib/asserts/object/index.js +7 -90
- package/lib/asserts/object/index.js.map +1 -1
- package/lib/asserts/object/index.mjs +7 -63
- package/lib/asserts/object/index.mjs.map +1 -1
- package/lib/asserts/string/email.js +6 -47
- package/lib/asserts/string/email.js.map +1 -1
- package/lib/asserts/string/email.mjs +3 -17
- package/lib/asserts/string/email.mjs.map +1 -1
- package/lib/asserts/string/index.js +8 -108
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +8 -81
- package/lib/asserts/string/index.mjs.map +1 -1
- package/lib/asserts/string/maxLength.js +6 -47
- package/lib/asserts/string/maxLength.js.map +1 -1
- package/lib/asserts/string/maxLength.mjs +3 -17
- package/lib/asserts/string/maxLength.mjs.map +1 -1
- package/lib/asserts/string/minLength.js +6 -47
- package/lib/asserts/string/minLength.js.map +1 -1
- package/lib/asserts/string/minLength.mjs +3 -17
- package/lib/asserts/string/minLength.mjs.map +1 -1
- package/lib/asserts/string/regExp.js +6 -47
- package/lib/asserts/string/regExp.js.map +1 -1
- package/lib/asserts/string/regExp.mjs +3 -17
- package/lib/asserts/string/regExp.mjs.map +1 -1
- package/lib/chunk-2AP4OQMT.js +26 -0
- package/lib/chunk-2AP4OQMT.js.map +1 -0
- package/lib/chunk-32IQXZRK.mjs +13 -0
- package/lib/chunk-32IQXZRK.mjs.map +1 -0
- package/lib/chunk-3FEJUC3K.mjs +13 -0
- package/lib/chunk-3FEJUC3K.mjs.map +1 -0
- package/lib/chunk-5NCJN6D2.js +70 -0
- package/lib/chunk-5NCJN6D2.js.map +1 -0
- package/lib/chunk-5ZMICHV3.js +21 -0
- package/lib/chunk-5ZMICHV3.js.map +1 -0
- package/lib/chunk-63IQFNFO.mjs +27 -0
- package/lib/chunk-63IQFNFO.mjs.map +1 -0
- package/lib/chunk-A2SAWKJA.mjs +13 -0
- package/lib/chunk-A2SAWKJA.mjs.map +1 -0
- package/lib/chunk-A3UTB4RE.mjs +28 -0
- package/lib/chunk-A3UTB4RE.mjs.map +1 -0
- package/lib/chunk-A7I2JEQO.js +13 -0
- package/lib/chunk-A7I2JEQO.js.map +1 -0
- package/lib/chunk-AJ4WV5DG.mjs +13 -0
- package/lib/chunk-AJ4WV5DG.mjs.map +1 -0
- package/lib/chunk-APTTIN2L.js +42 -0
- package/lib/chunk-APTTIN2L.js.map +1 -0
- package/lib/chunk-AXOP6HPJ.js +14 -0
- package/lib/chunk-AXOP6HPJ.js.map +1 -0
- package/lib/chunk-BGMR7A6X.mjs +13 -0
- package/lib/chunk-BGMR7A6X.mjs.map +1 -0
- package/lib/chunk-FCFO5J5Y.mjs +14 -0
- package/lib/chunk-FCFO5J5Y.mjs.map +1 -0
- package/lib/chunk-GEZME6V2.mjs +39 -0
- package/lib/chunk-GEZME6V2.mjs.map +1 -0
- package/lib/chunk-GNBSKTFV.js +27 -0
- package/lib/chunk-GNBSKTFV.js.map +1 -0
- package/lib/chunk-IQ3QYABE.js +32 -0
- package/lib/chunk-IQ3QYABE.js.map +1 -0
- package/lib/chunk-K2S3FS5K.js +13 -0
- package/lib/chunk-K2S3FS5K.js.map +1 -0
- package/lib/chunk-KCBOOOTF.mjs +13 -0
- package/lib/chunk-KCBOOOTF.mjs.map +1 -0
- package/lib/chunk-L6A7NXUJ.js +13 -0
- package/lib/chunk-L6A7NXUJ.js.map +1 -0
- package/lib/chunk-L7HUXYFV.mjs +42 -0
- package/lib/chunk-L7HUXYFV.mjs.map +1 -0
- package/lib/chunk-LHTJHMKJ.mjs +27 -0
- package/lib/chunk-LHTJHMKJ.mjs.map +1 -0
- package/lib/chunk-NOADI6PO.mjs +21 -0
- package/lib/chunk-NOADI6PO.mjs.map +1 -0
- package/lib/chunk-NWY33MFU.js +13 -0
- package/lib/chunk-NWY33MFU.js.map +1 -0
- package/lib/chunk-P3Y6IWFA.mjs +70 -0
- package/lib/chunk-P3Y6IWFA.mjs.map +1 -0
- package/lib/chunk-PDVXBE27.js +27 -0
- package/lib/chunk-PDVXBE27.js.map +1 -0
- package/lib/chunk-PJP63SJT.js +13 -0
- package/lib/chunk-PJP63SJT.js.map +1 -0
- package/lib/chunk-QJOXKH7A.mjs +26 -0
- package/lib/chunk-QJOXKH7A.mjs.map +1 -0
- package/lib/chunk-QKGQ4XZC.js +13 -0
- package/lib/chunk-QKGQ4XZC.js.map +1 -0
- package/lib/chunk-QYLH5ZAC.mjs +32 -0
- package/lib/chunk-QYLH5ZAC.mjs.map +1 -0
- package/lib/chunk-VPFIIM2X.js +39 -0
- package/lib/chunk-VPFIIM2X.js.map +1 -0
- package/lib/chunk-YXHH5BF6.js +28 -0
- package/lib/chunk-YXHH5BF6.js.map +1 -0
- package/lib/core.js +6 -107
- package/lib/core.js.map +1 -1
- package/lib/core.mjs +5 -78
- package/lib/core.mjs.map +1 -1
- package/lib/exceptions.js +9 -50
- package/lib/exceptions.js.map +1 -1
- package/lib/exceptions.mjs +5 -19
- package/lib/exceptions.mjs.map +1 -1
- package/lib/index.js +29 -283
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +34 -252
- package/lib/index.mjs.map +1 -1
- package/lib/parseSchema.js +5 -115
- package/lib/parseSchema.js.map +1 -1
- package/lib/parseSchema.mjs +5 -88
- package/lib/parseSchema.mjs.map +1 -1
- package/lib/schemas/ArraySchema.js +6 -81
- package/lib/schemas/ArraySchema.js.map +1 -1
- package/lib/schemas/ArraySchema.mjs +6 -54
- package/lib/schemas/ArraySchema.mjs.map +1 -1
- package/lib/schemas/BooleanSchema.js +6 -109
- package/lib/schemas/BooleanSchema.js.map +1 -1
- package/lib/schemas/BooleanSchema.mjs +6 -82
- package/lib/schemas/BooleanSchema.mjs.map +1 -1
- package/lib/schemas/CommonSchema.js +5 -63
- package/lib/schemas/CommonSchema.js.map +1 -1
- package/lib/schemas/CommonSchema.mjs +5 -36
- package/lib/schemas/CommonSchema.mjs.map +1 -1
- package/lib/schemas/NumberSchema.js +7 -103
- package/lib/schemas/NumberSchema.js.map +1 -1
- package/lib/schemas/NumberSchema.mjs +7 -76
- package/lib/schemas/NumberSchema.mjs.map +1 -1
- package/lib/schemas/ObjectSchema.js +6 -85
- package/lib/schemas/ObjectSchema.js.map +1 -1
- package/lib/schemas/ObjectSchema.mjs +6 -58
- package/lib/schemas/ObjectSchema.mjs.map +1 -1
- package/lib/schemas/StringSchema.js +7 -103
- package/lib/schemas/StringSchema.js.map +1 -1
- package/lib/schemas/StringSchema.mjs +7 -76
- package/lib/schemas/StringSchema.mjs.map +1 -1
- package/package.json +4 -3
- package/lib/__tests__/ArraySchema.test.d.mts +0 -2
- package/lib/__tests__/ArraySchema.test.d.ts +0 -2
- package/lib/__tests__/ArraySchema.test.js +0 -201
- package/lib/__tests__/ArraySchema.test.js.map +0 -1
- package/lib/__tests__/ArraySchema.test.mjs +0 -199
- package/lib/__tests__/ArraySchema.test.mjs.map +0 -1
- package/lib/__tests__/BooleanSchema.test.d.mts +0 -2
- package/lib/__tests__/BooleanSchema.test.d.ts +0 -2
- package/lib/__tests__/BooleanSchema.test.js +0 -219
- package/lib/__tests__/BooleanSchema.test.js.map +0 -1
- package/lib/__tests__/BooleanSchema.test.mjs +0 -217
- package/lib/__tests__/BooleanSchema.test.mjs.map +0 -1
- package/lib/__tests__/CommonSchema.test.d.mts +0 -2
- package/lib/__tests__/CommonSchema.test.d.ts +0 -2
- package/lib/__tests__/CommonSchema.test.js +0 -253
- package/lib/__tests__/CommonSchema.test.js.map +0 -1
- package/lib/__tests__/CommonSchema.test.mjs +0 -251
- package/lib/__tests__/CommonSchema.test.mjs.map +0 -1
- package/lib/__tests__/MixTypes.test.d.mts +0 -2
- package/lib/__tests__/MixTypes.test.d.ts +0 -2
- package/lib/__tests__/MixTypes.test.js +0 -165
- package/lib/__tests__/MixTypes.test.js.map +0 -1
- package/lib/__tests__/MixTypes.test.mjs +0 -163
- package/lib/__tests__/MixTypes.test.mjs.map +0 -1
- package/lib/__tests__/NumberSchema.test.d.mts +0 -2
- package/lib/__tests__/NumberSchema.test.d.ts +0 -2
- package/lib/__tests__/NumberSchema.test.js +0 -253
- package/lib/__tests__/NumberSchema.test.js.map +0 -1
- package/lib/__tests__/NumberSchema.test.mjs +0 -251
- package/lib/__tests__/NumberSchema.test.mjs.map +0 -1
- package/lib/__tests__/ObjectSchema.test.d.mts +0 -2
- package/lib/__tests__/ObjectSchema.test.d.ts +0 -2
- package/lib/__tests__/ObjectSchema.test.js +0 -356
- package/lib/__tests__/ObjectSchema.test.js.map +0 -1
- package/lib/__tests__/ObjectSchema.test.mjs +0 -354
- package/lib/__tests__/ObjectSchema.test.mjs.map +0 -1
- package/lib/__tests__/StringSchema.test.d.mts +0 -2
- package/lib/__tests__/StringSchema.test.d.ts +0 -2
- package/lib/__tests__/StringSchema.test.js +0 -228
- package/lib/__tests__/StringSchema.test.js.map +0 -1
- package/lib/__tests__/StringSchema.test.mjs +0 -226
- package/lib/__tests__/StringSchema.test.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","../../../src/asserts/string/minLength.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACA;ACUO,IAAM,UAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,WAAA,EAAA,GAAwB;AACzC,EAAA,GAAA,CAAI,QAAA,CAAS,OAAA,EAAS,QAAA;AACpB,IAAA,6CAAA,QAAe,EAAU,QAAA,EAAU,WAAA,EAAa,iDAAiD,CAAA;AACrG,CAAA;ADVF;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","sourcesContent":[null,"import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not less than a specified minimum length.\n *\n * @param {number} expected - The minimum required length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is less than the expected length.\n *\n * @example\n * const schema = string().custom(minLength(5));\n * parseSchema(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseSchema(schema, 'adequate'); // Valid\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length < expected)\n throwException(expected, received, pathToError, 'The received value length is less than expected');\n };\n"]}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
received;
|
|
5
|
-
pathToError;
|
|
6
|
-
message;
|
|
7
|
-
constructor(expected, received, pathToError, message) {
|
|
8
|
-
super();
|
|
9
|
-
this.expected = expected;
|
|
10
|
-
this.received = received;
|
|
11
|
-
this.pathToError = pathToError;
|
|
12
|
-
this.message = message;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
function throwException(expected, received, pathToError, message) {
|
|
16
|
-
throw new ValidationError(expected, received, pathToError, message);
|
|
17
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
throwException
|
|
3
|
+
} from "../../chunk-QJOXKH7A.mjs";
|
|
18
4
|
|
|
19
5
|
// src/asserts/string/minLength.ts
|
|
20
6
|
var minLength = (expected) => (received, pathToError) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/string/minLength.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not less than a specified minimum length.\n *\n * @param {number} expected - The minimum required length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is less than the expected length.\n *\n * @example\n * const schema = string().custom(minLength(5));\n * parseSchema(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseSchema(schema, 'adequate'); // Valid\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length < expected)\n throwException(expected, received, pathToError, 'The received value length is less than expected');\n };\n"],"mappings":";;;;;AAcO,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,SAAS,SAAS;AACpB,mBAAe,UAAU,UAAU,aAAa,iDAAiD;AACrG;","names":[]}
|
|
@@ -1,54 +1,13 @@
|
|
|
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);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var regExp_exports = {};
|
|
22
|
-
__export(regExp_exports, {
|
|
23
|
-
regExp: () => regExp
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(regExp_exports);
|
|
26
|
-
|
|
27
|
-
// src/exceptions.ts
|
|
28
|
-
var ValidationError = class extends Error {
|
|
29
|
-
expected;
|
|
30
|
-
received;
|
|
31
|
-
pathToError;
|
|
32
|
-
message;
|
|
33
|
-
constructor(expected, received, pathToError, message) {
|
|
34
|
-
super();
|
|
35
|
-
this.expected = expected;
|
|
36
|
-
this.received = received;
|
|
37
|
-
this.pathToError = pathToError;
|
|
38
|
-
this.message = message;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
function throwException(expected, received, pathToError, message) {
|
|
42
|
-
throw new ValidationError(expected, received, pathToError, message);
|
|
43
|
-
}
|
|
3
|
+
var _chunk2AP4OQMTjs = require('../../chunk-2AP4OQMT.js');
|
|
44
4
|
|
|
45
5
|
// src/asserts/string/regExp.ts
|
|
46
6
|
var regExp = (expected) => (received, pathToError) => {
|
|
47
7
|
if (!expected.test(received))
|
|
48
|
-
throwException(expected, received, pathToError, "The received value does not match the required text pattern");
|
|
8
|
+
_chunk2AP4OQMTjs.throwException.call(void 0, expected, received, pathToError, "The received value does not match the required text pattern");
|
|
49
9
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.regExp = regExp;
|
|
54
13
|
//# sourceMappingURL=regExp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","../../../src/asserts/string/regExp.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACA;ACUO,IAAM,OAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,WAAA,EAAA,GAAwB;AACzC,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA;AACzB,IAAA,6CAAA,QAAe,EAAU,QAAA,EAAU,WAAA,EAAa,6DAA6D,CAAA;AACjH,CAAA;ADVF;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","sourcesContent":[null,"import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a string value matches a specified regular expression pattern.\n *\n * @param {RegExp} expected - The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the received value does not match the expected pattern.\n *\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseSchema(schema, 'valid123'); // Valid\n * parseSchema(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (!expected.test(received))\n throwException(expected, received, pathToError, 'The received value does not match the required text pattern');\n };\n"]}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
received;
|
|
5
|
-
pathToError;
|
|
6
|
-
message;
|
|
7
|
-
constructor(expected, received, pathToError, message) {
|
|
8
|
-
super();
|
|
9
|
-
this.expected = expected;
|
|
10
|
-
this.received = received;
|
|
11
|
-
this.pathToError = pathToError;
|
|
12
|
-
this.message = message;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
function throwException(expected, received, pathToError, message) {
|
|
16
|
-
throw new ValidationError(expected, received, pathToError, message);
|
|
17
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
throwException
|
|
3
|
+
} from "../../chunk-QJOXKH7A.mjs";
|
|
18
4
|
|
|
19
5
|
// src/asserts/string/regExp.ts
|
|
20
6
|
var regExp = (expected) => (received, pathToError) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/string/regExp.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a string value matches a specified regular expression pattern.\n *\n * @param {RegExp} expected - The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the received value does not match the expected pattern.\n *\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseSchema(schema, 'valid123'); // Valid\n * parseSchema(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (!expected.test(received))\n throwException(expected, received, pathToError, 'The received value does not match the required text pattern');\n };\n"],"mappings":";;;;;AAcO,IAAM,SACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,CAAC,SAAS,KAAK,QAAQ;AACzB,mBAAe,UAAU,UAAU,aAAa,6DAA6D;AACjH;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/exceptions.ts
|
|
2
|
+
var ValidationError = class extends Error {
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
constructor(expected, received, pathToError, message) {
|
|
8
|
+
super();
|
|
9
|
+
this.expected = expected;
|
|
10
|
+
this.received = received;
|
|
11
|
+
this.pathToError = pathToError;
|
|
12
|
+
this.message = message;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var BuildSchemaError = class extends Error {
|
|
16
|
+
};
|
|
17
|
+
function throwException(expected, received, pathToError, message) {
|
|
18
|
+
throw new ValidationError(expected, received, pathToError, message);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
exports.ValidationError = ValidationError; exports.BuildSchemaError = BuildSchemaError; exports.throwException = throwException;
|
|
26
|
+
//# sourceMappingURL=chunk-2AP4OQMT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-2AP4OQMT.js","../src/exceptions.ts"],"names":[],"mappings":"AAAA;ACAO,IAAM,gBAAA,EAAN,MAAA,QAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAA,CAAY,QAAA,EAAmB,QAAA,EAAmB,WAAA,EAAqB,OAAA,EAAiB;AACtF,IAAA,KAAA,CAAM,CAAA;AACN,IAAA,IAAA,CAAK,SAAA,EAAW,QAAA;AAChB,IAAA,IAAA,CAAK,SAAA,EAAW,QAAA;AAChB,IAAA,IAAA,CAAK,YAAA,EAAc,WAAA;AACnB,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA;AAAA,EACjB;AACF,CAAA;AAEO,IAAM,iBAAA,EAAN,MAAA,QAA+B,MAAM;AAAC,CAAA;AAEtC,SAAS,cAAA,CAAe,QAAA,EAAmB,QAAA,EAAmB,WAAA,EAAqB,OAAA,EAAwB;AAChH,EAAA,MAAM,IAAI,eAAA,CAAgB,QAAA,EAAU,QAAA,EAAU,WAAA,EAAa,OAAO,CAAA;AACpE;ADCA;AACA;AACE;AACA;AACA;AACF,gIAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-2AP4OQMT.js","sourcesContent":[null,"export class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nexport function throwException(expected: unknown, received: unknown, pathToError: string, message: string): never {\n throw new ValidationError(expected, received, pathToError, message);\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ObjectSchema
|
|
3
|
+
} from "./chunk-QYLH5ZAC.mjs";
|
|
4
|
+
|
|
5
|
+
// src/asserts/object/index.ts
|
|
6
|
+
function object(shapeSchema) {
|
|
7
|
+
return new ObjectSchema({ type: [], requiredValidations: [] }, shapeSchema);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
object
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-32IQXZRK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/asserts/object/index.ts"],"sourcesContent":["import { ObjectShapeSchemaType } from '../../schemas/CommonSchema';\nimport { ObjectSchema, WithObject } from '../../schemas/ObjectSchema';\n\n/**\n * Creates a new schema for validating objects where each property must match the specified schema.\n *\n * @template T\n * @param {T} shapeSchema - The schema that each property of the object must match.\n * @returns {WithObject<T>} A new instance of `ObjectSchema` for validating objects with properties matching the specified schema.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number()\n * });\n * parseSchema(schema, { name: 'John', age: 30 }); // Validates successfully\n * parseSchema(schema, { name: 'John', age: '30' }); // Throws a validation error\n */\nexport function object<T extends ObjectShapeSchemaType>(shapeSchema: T): WithObject<T> {\n return new ObjectSchema({ type: [], requiredValidations: [] }, shapeSchema) as WithObject<T>;\n}\n"],"mappings":";;;;;AAkBO,SAAS,OAAwC,aAA+B;AACrF,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,EAAE,GAAG,WAAW;AAC5E;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BooleanSchema
|
|
3
|
+
} from "./chunk-GEZME6V2.mjs";
|
|
4
|
+
|
|
5
|
+
// src/asserts/boolean/index.ts
|
|
6
|
+
function boolean() {
|
|
7
|
+
return new BooleanSchema({ type: ["boolean"], requiredValidations: [] });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
boolean
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-3FEJUC3K.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/asserts/boolean/index.ts"],"sourcesContent":["import { BooleanSchema } from '../../schemas/BooleanSchema';\n\n/**\n * Creates a new schema for validating boolean values.\n *\n * @returns {BooleanSchema} A new instance of `BooleanSchema` for validating booleans.\n *\n * @example\n * const schema = boolean();\n * parseSchema(schema, true); // Validates successfully\n * parseSchema(schema, 'true'); // Throws a validation error\n */\nexport function boolean(): BooleanSchema {\n return new BooleanSchema({ type: ['boolean'], requiredValidations: [] });\n}\n"],"mappings":";;;;;AAYO,SAAS,UAAyB;AACvC,SAAO,IAAI,cAAc,EAAE,MAAM,CAAC,SAAS,GAAG,qBAAqB,CAAC,EAAE,CAAC;AACzE;","names":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk2AP4OQMTjs = require('./chunk-2AP4OQMT.js');
|
|
4
|
+
|
|
5
|
+
// src/core.ts
|
|
6
|
+
var ctxSymbol = Symbol("contextSymbol");
|
|
7
|
+
function innerCheck(schema, receivedValue, pathToError) {
|
|
8
|
+
const ctx = schema[ctxSymbol];
|
|
9
|
+
if (receivedValue === void 0) {
|
|
10
|
+
if (!ctx.isOptional) _chunk2AP4OQMTjs.throwException.call(void 0, "Required", receivedValue, pathToError, "The required value is missing");
|
|
11
|
+
return receivedValue;
|
|
12
|
+
}
|
|
13
|
+
if (receivedValue === null) {
|
|
14
|
+
if (!ctx.isNullable) _chunk2AP4OQMTjs.throwException.call(void 0, "Not null", receivedValue, pathToError, "Value should not be null");
|
|
15
|
+
return receivedValue;
|
|
16
|
+
}
|
|
17
|
+
if (ctx.array) {
|
|
18
|
+
if (!Array.isArray(receivedValue))
|
|
19
|
+
_chunk2AP4OQMTjs.throwException.call(void 0, "Array", receivedValue, pathToError, "Expected an array but received a different type");
|
|
20
|
+
const schema2 = ctx.array;
|
|
21
|
+
receivedValue.forEach((elem, i) => {
|
|
22
|
+
innerCheck(schema2, elem, `${pathToError}[${i}]`);
|
|
23
|
+
});
|
|
24
|
+
return receivedValue;
|
|
25
|
+
}
|
|
26
|
+
const typeOfVal = typeof receivedValue;
|
|
27
|
+
if (ctx.object) {
|
|
28
|
+
if (typeOfVal !== "object")
|
|
29
|
+
_chunk2AP4OQMTjs.throwException.call(void 0, "Object", receivedValue, pathToError, "Expected an object but received a different type");
|
|
30
|
+
if (Array.isArray(receivedValue))
|
|
31
|
+
_chunk2AP4OQMTjs.throwException.call(void 0,
|
|
32
|
+
"Object",
|
|
33
|
+
receivedValue,
|
|
34
|
+
pathToError,
|
|
35
|
+
"Expected an object but received an array. Invalid type of data"
|
|
36
|
+
);
|
|
37
|
+
const shapeSchema = ctx.object;
|
|
38
|
+
for (const keyPerReceivedValue of Object.keys(receivedValue)) {
|
|
39
|
+
if (shapeSchema[keyPerReceivedValue] === void 0)
|
|
40
|
+
_chunk2AP4OQMTjs.throwException.call(void 0, "Not allowed", keyPerReceivedValue, pathToError, "This key is not allowed in the object");
|
|
41
|
+
}
|
|
42
|
+
for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {
|
|
43
|
+
const receivedObjectValuePropery = receivedValue[keyOfSchema];
|
|
44
|
+
if (receivedObjectValuePropery === void 0) {
|
|
45
|
+
if (!valueOfSchema[ctxSymbol].isOptional)
|
|
46
|
+
_chunk2AP4OQMTjs.throwException.call(void 0,
|
|
47
|
+
"Required",
|
|
48
|
+
receivedObjectValuePropery,
|
|
49
|
+
pathToError,
|
|
50
|
+
"Missing required property in the object"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
innerCheck(valueOfSchema, receivedObjectValuePropery, `${pathToError}.${keyOfSchema}`);
|
|
54
|
+
}
|
|
55
|
+
return receivedValue;
|
|
56
|
+
}
|
|
57
|
+
if (ctx.type.length) {
|
|
58
|
+
if (!ctx.type.includes(typeOfVal)) _chunk2AP4OQMTjs.throwException.call(void 0, ctx.type, typeOfVal, pathToError, "Invalid type of data");
|
|
59
|
+
}
|
|
60
|
+
ctx.requiredValidations.forEach((requiredValidation) => {
|
|
61
|
+
requiredValidation(receivedValue, pathToError);
|
|
62
|
+
});
|
|
63
|
+
return receivedValue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
exports.ctxSymbol = ctxSymbol; exports.innerCheck = innerCheck;
|
|
70
|
+
//# sourceMappingURL=chunk-5NCJN6D2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-5NCJN6D2.js","../src/core.ts"],"names":["schema"],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACJO,IAAM,UAAA,EAAY,MAAA,CAAO,eAAe,CAAA;AAKxC,SAAS,UAAA,CAAW,MAAA,EAAsB,aAAA,EAAwB,WAAA,EAAqB;AAC5F,EAAA,MAAM,IAAA,EAAM,MAAA,CAAO,SAAS,CAAA;AAC5B,EAAA,GAAA,CAAI,cAAA,IAAkB,KAAA,CAAA,EAAW;AAC/B,IAAA,GAAA,CAAI,CAAC,GAAA,CAAI,UAAA,EAAY,6CAAA,UAAe,EAAY,aAAA,EAAe,WAAA,EAAa,+BAA+B,CAAA;AAC3G,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,cAAA,IAAkB,IAAA,EAAM;AAC1B,IAAA,GAAA,CAAI,CAAC,GAAA,CAAI,UAAA,EAAY,6CAAA,UAAe,EAAY,aAAA,EAAe,WAAA,EAAa,0BAA0B,CAAA;AACtG,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,GAAA,CAAI,KAAA,EAAO;AACb,IAAA,GAAA,CAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,aAAa,CAAA;AAC9B,MAAA,6CAAA,OAAe,EAAS,aAAA,EAAe,WAAA,EAAa,iDAAiD,CAAA;AACvG,IAAA,MAAMA,QAAAA,EAAS,GAAA,CAAI,KAAA;AAEnB,IAAA,aAAA,CAAc,OAAA,CAAQ,CAAC,IAAA,EAAM,CAAA,EAAA,GAAM;AACjC,MAAA,UAAA,CAAWA,OAAAA,EAAQ,IAAA,EAAM,CAAA,EAAA;AAC1B,IAAA;AAEM,IAAA;AACT,EAAA;AAEyB,EAAA;AAET,EAAA;AACI,IAAA;AACS,MAAA;AACT,IAAA;AAChB,MAAA;AACE,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACF,MAAA;AACsB,IAAA;AACb,IAAA;AACO,MAAA;AACC,QAAA;AACnB,IAAA;AAEyB,IAAA;AACjB,MAAA;AACF,MAAA;AACiB,QAAA;AACjB,UAAA;AACE,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACF,UAAA;AACJ,MAAA;AAC0B,MAAA;AAC5B,IAAA;AAEO,IAAA;AACT,EAAA;AAEqB,EAAA;AACI,IAAA;AACzB,EAAA;AAEwB,EAAA;AACH,IAAA;AACpB,EAAA;AAEM,EAAA;AACT;ADTiC;AACA;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-5NCJN6D2.js","sourcesContent":[null,"export const ctxSymbol = Symbol('contextSymbol');\n\nimport { throwException } from './exceptions';\nimport type { CommonSchema } from './schemas/CommonSchema';\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, pathToError: string) {\n const ctx = schema[ctxSymbol];\n if (receivedValue === undefined) {\n if (!ctx.isOptional) throwException('Required', receivedValue, pathToError, 'The required value is missing');\n return receivedValue;\n }\n\n if (receivedValue === null) {\n if (!ctx.isNullable) throwException('Not null', receivedValue, pathToError, 'Value should not be null');\n return receivedValue;\n }\n\n if (ctx.array) {\n if (!Array.isArray(receivedValue))\n throwException('Array', receivedValue, pathToError, 'Expected an array but received a different type');\n const schema = ctx.array;\n\n receivedValue.forEach((elem, i) => {\n innerCheck(schema, elem, `${pathToError}[${i}]`);\n });\n\n return receivedValue;\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (ctx.object) {\n if (typeOfVal !== 'object')\n throwException('Object', receivedValue, pathToError, 'Expected an object but received a different type');\n if (Array.isArray(receivedValue))\n throwException(\n 'Object',\n receivedValue,\n pathToError,\n 'Expected an object but received an array. Invalid type of data',\n );\n const shapeSchema = ctx.object;\n for (const keyPerReceivedValue of Object.keys(receivedValue)) {\n if (shapeSchema[keyPerReceivedValue] === undefined)\n throwException('Not allowed', keyPerReceivedValue, pathToError, 'This key is not allowed in the object');\n }\n\n for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {\n const receivedObjectValuePropery = (receivedValue as Record<string, unknown>)[keyOfSchema];\n if (receivedObjectValuePropery === undefined) {\n if (!valueOfSchema[ctxSymbol].isOptional)\n throwException(\n 'Required',\n receivedObjectValuePropery,\n pathToError,\n 'Missing required property in the object',\n );\n }\n innerCheck(valueOfSchema, receivedObjectValuePropery, `${pathToError}.${keyOfSchema}`);\n }\n\n return receivedValue;\n }\n\n if (ctx.type.length) {\n if (!ctx.type.includes(typeOfVal)) throwException(ctx.type, typeOfVal, pathToError, 'Invalid type of data');\n }\n\n ctx.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, pathToError);\n });\n\n return receivedValue;\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk5NCJN6D2js = require('./chunk-5NCJN6D2.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunk2AP4OQMTjs = require('./chunk-2AP4OQMT.js');
|
|
7
|
+
|
|
8
|
+
// src/parseSchema.ts
|
|
9
|
+
function parseSchema(schema, receivedValue) {
|
|
10
|
+
try {
|
|
11
|
+
return _chunk5NCJN6D2js.innerCheck.call(void 0, schema, receivedValue, "");
|
|
12
|
+
} catch (e) {
|
|
13
|
+
if (e instanceof _chunk2AP4OQMTjs.ValidationError) throw e;
|
|
14
|
+
throw new Error("Something unexpected happened");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
exports.parseSchema = parseSchema;
|
|
21
|
+
//# sourceMappingURL=chunk-5ZMICHV3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-5ZMICHV3.js","../src/parseSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACwBO,SAAS,WAAA,CAAoC,MAAA,EAAW,aAAA,EAAsC;AACnG,EAAA,IAAI;AACF,IAAA,OAAO,yCAAA,MAAW,EAAQ,aAAA,EAAe,EAAE,CAAA;AAAA,EAC7C,EAAA,MAAA,CAAS,CAAA,EAAG;AACV,IAAA,GAAA,CAAI,EAAA,WAAa,gCAAA,EAAiB,MAAM,CAAA;AAExC,IAAA,MAAM,IAAI,KAAA,CAAM,+BAA+B,CAAA;AAAA,EACjD;AACF;ADvBA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-5ZMICHV3.js","sourcesContent":[null,"import { InferType } from './InferType';\nimport { innerCheck } from './core';\nimport { ValidationError } from './exceptions';\nimport { CommonSchema } from './schemas/CommonSchema';\n\n/**\n * Parses and validates a value against the provided schema, returning a type-safe result.\n *\n * This function will throw a `ValidationError` if the value does not conform to the schema.\n * The inferred TypeScript type of the returned value will match the structure defined by the schema.\n *\n * @template T\n * @param {T} schema - The schema to validate the received value against. This schema dictates the expected structure and type of the value.\n * @param {unknown} receivedValue - The value to be validated and parsed according to the schema.\n * @returns {InferType<T>} The validated value, with its TypeScript type inferred from the schema.\n *\n * @throws {ValidationError} If the received value does not match the schema, a `ValidationError` will be thrown.\n * @throws {Error} If an unexpected error occurs during validation, an error will be thrown with a generic message.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number(),\n * });\n *\n * const result = parseSchema(schema, { name: 'Alice', age: 30 });\n * // result will be inferred as { name: string; age: number }\n *\n * parseSchema(schema, { name: 'Alice', age: '30' });\n * // Throws ValidationError because 'age' should be a number, not a string.\n */\nexport function parseSchema<T extends CommonSchema>(schema: T, receivedValue: unknown): InferType<T> {\n try {\n return innerCheck(schema, receivedValue, '') as InferType<T>;\n } catch (e) {\n if (e instanceof ValidationError) throw e;\n /* istanbul ignore next */\n throw new Error('Something unexpected happened');\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
equalTo
|
|
3
|
+
} from "./chunk-FCFO5J5Y.mjs";
|
|
4
|
+
import {
|
|
5
|
+
CommonSchema
|
|
6
|
+
} from "./chunk-L7HUXYFV.mjs";
|
|
7
|
+
|
|
8
|
+
// src/schemas/NumberSchema.ts
|
|
9
|
+
var NumberSchema = class extends CommonSchema {
|
|
10
|
+
_number = 1;
|
|
11
|
+
/**
|
|
12
|
+
* Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
13
|
+
*
|
|
14
|
+
* @param expectedValue - The value that the schema must exactly match.
|
|
15
|
+
* @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type
|
|
16
|
+
*
|
|
17
|
+
* @example - number().equalTo(42); // Infers the type 42
|
|
18
|
+
*/
|
|
19
|
+
equalTo(expectedValue) {
|
|
20
|
+
return this.custom(equalTo(expectedValue));
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
NumberSchema
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-63IQFNFO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/NumberSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/common/equalTo';\n\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 1;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;AAIO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,QAA0B,eAAuC;AAC/D,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AACF;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArraySchema
|
|
3
|
+
} from "./chunk-A3UTB4RE.mjs";
|
|
4
|
+
|
|
5
|
+
// src/asserts/array/index.ts
|
|
6
|
+
function array(arraySchema) {
|
|
7
|
+
return new ArraySchema({ type: [], requiredValidations: [] }, arraySchema);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
array
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-A2SAWKJA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/asserts/array/index.ts"],"sourcesContent":["import { ArraySchema, WithArray } from '../../schemas/ArraySchema';\nimport { CommonSchema } from '../../schemas/CommonSchema';\n\n/**\n * Creates a new schema for validating arrays where each element must match the specified schema.\n *\n * @template T\n * @param {T} arraySchema - The schema that each element of the array must match.\n * @returns {WithArray<T>} A new instance of `ArraySchema` for validating arrays of elements that match the specified schema.\n *\n * @example\n * const schema = array(string());\n * parseSchema(schema, ['hello', 'world']); // Validates successfully\n * parseSchema(schema, ['hello', 123]); // Throws a validation error\n */\nexport function array<T extends CommonSchema>(arraySchema: T): WithArray<T> {\n return new ArraySchema({ type: [], requiredValidations: [] }, arraySchema) as WithArray<T>;\n}\n"],"mappings":";;;;;AAeO,SAAS,MAA8B,aAA8B;AAC1E,SAAO,IAAI,YAAY,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,EAAE,GAAG,WAAW;AAC3E;","names":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CommonSchema
|
|
3
|
+
} from "./chunk-L7HUXYFV.mjs";
|
|
4
|
+
import {
|
|
5
|
+
ctxSymbol
|
|
6
|
+
} from "./chunk-P3Y6IWFA.mjs";
|
|
7
|
+
import {
|
|
8
|
+
BuildSchemaError
|
|
9
|
+
} from "./chunk-QJOXKH7A.mjs";
|
|
10
|
+
|
|
11
|
+
// src/schemas/ArraySchema.ts
|
|
12
|
+
var ArraySchema = class extends CommonSchema {
|
|
13
|
+
_array = 1;
|
|
14
|
+
constructor(ctx, arraySchema) {
|
|
15
|
+
super(ctx);
|
|
16
|
+
this.validateArrayEntry(arraySchema);
|
|
17
|
+
this[ctxSymbol].array = arraySchema;
|
|
18
|
+
}
|
|
19
|
+
validateArrayEntry(arraySchema) {
|
|
20
|
+
if (!arraySchema) throw new BuildSchemaError("Missing schema in array method");
|
|
21
|
+
if (!(arraySchema instanceof CommonSchema)) throw new BuildSchemaError("Invalid schema in array method");
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
ArraySchema
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=chunk-A3UTB4RE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/ArraySchema.ts"],"sourcesContent":["import { ctxSymbol } from '../core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class ArraySchema extends CommonSchema {\n _array = 1;\n constructor(ctx: ValidatorContext, arraySchema: CommonSchema) {\n super(ctx);\n this.validateArrayEntry(arraySchema);\n this[ctxSymbol].array = arraySchema;\n }\n\n private validateArrayEntry(arraySchema: CommonSchema) {\n if (!arraySchema) throw new BuildSchemaError('Missing schema in array method');\n if (!(arraySchema instanceof CommonSchema)) throw new BuildSchemaError('Invalid schema in array method');\n }\n}\n\nexport type WithArray<Y extends CommonSchema> = ArraySchema & { validation_array: Y };\nexport type ExtractFromArray<T> = T extends WithArray<infer X> ? X : never;\n"],"mappings":";;;;;;;;;;;AAIO,IAAM,cAAN,cAA0B,aAAa;AAAA,EAC5C,SAAS;AAAA,EACT,YAAY,KAAuB,aAA2B;AAC5D,UAAM,GAAG;AACT,SAAK,mBAAmB,WAAW;AACnC,SAAK,SAAS,EAAE,QAAQ;AAAA,EAC1B;AAAA,EAEQ,mBAAmB,aAA2B;AACpD,QAAI,CAAC,YAAa,OAAM,IAAI,iBAAiB,gCAAgC;AAC7E,QAAI,EAAE,uBAAuB,cAAe,OAAM,IAAI,iBAAiB,gCAAgC;AAAA,EACzG;AACF;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkVPFIIM2Xjs = require('./chunk-VPFIIM2X.js');
|
|
4
|
+
|
|
5
|
+
// src/asserts/boolean/index.ts
|
|
6
|
+
function boolean() {
|
|
7
|
+
return new (0, _chunkVPFIIM2Xjs.BooleanSchema)({ type: ["boolean"], requiredValidations: [] });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.boolean = boolean;
|
|
13
|
+
//# sourceMappingURL=chunk-A7I2JEQO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-A7I2JEQO.js","../src/asserts/boolean/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,OAAA,CAAA,EAAyB;AACvC,EAAA,OAAO,IAAI,mCAAA,CAAc,EAAE,IAAA,EAAM,CAAC,SAAS,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACzE;ADNA;AACA;AACE;AACF,0BAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-A7I2JEQO.js","sourcesContent":[null,"import { BooleanSchema } from '../../schemas/BooleanSchema';\n\n/**\n * Creates a new schema for validating boolean values.\n *\n * @returns {BooleanSchema} A new instance of `BooleanSchema` for validating booleans.\n *\n * @example\n * const schema = boolean();\n * parseSchema(schema, true); // Validates successfully\n * parseSchema(schema, 'true'); // Throws a validation error\n */\nexport function boolean(): BooleanSchema {\n return new BooleanSchema({ type: ['boolean'], requiredValidations: [] });\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CommonSchema
|
|
3
|
+
} from "./chunk-L7HUXYFV.mjs";
|
|
4
|
+
|
|
5
|
+
// src/asserts/common/index.ts
|
|
6
|
+
function oneOfTypes(valueTypes) {
|
|
7
|
+
return new CommonSchema({ type: valueTypes, requiredValidations: [] });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
oneOfTypes
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-AJ4WV5DG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/asserts/common/index.ts"],"sourcesContent":["import { CommonSchema, MapMixTypes, PrimitiveType, WithMix } from '../../schemas/CommonSchema';\n\n/**\n * Creates a new schema for validating values that can match any one of the specified primitive types.\n *\n * @template T\n * @param {T} valueTypes - An array of primitive types that the value can match.\n * @returns {WithMix<MapMixTypes<T>>} A new schema for validating values that can match any of the specified types.\n *\n * @example\n * const schema = oneOfTypes(['string', 'number']);\n * parseSchema(schema, 'hello'); // Validates successfully\n * parseSchema(schema, 42); // Validates successfully\n * parseSchema(schema, true); // Throws a validation error\n */\nexport function oneOfTypes<T extends PrimitiveType[]>(valueTypes: T): WithMix<MapMixTypes<T>> {\n return new CommonSchema({ type: valueTypes, requiredValidations: [] }) as WithMix<MapMixTypes<T>>;\n}\n"],"mappings":";;;;;AAeO,SAAS,WAAsC,YAAwC;AAC5F,SAAO,IAAI,aAAa,EAAE,MAAM,YAAY,qBAAqB,CAAC,EAAE,CAAC;AACvE;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk5NCJN6D2js = require('./chunk-5NCJN6D2.js');
|
|
4
|
+
|
|
5
|
+
// src/schemas/CommonSchema.ts
|
|
6
|
+
var CommonSchema = class {
|
|
7
|
+
|
|
8
|
+
constructor(ctx) {
|
|
9
|
+
this[_chunk5NCJN6D2js.ctxSymbol] = ctx;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @param validators - One or more custom validation functions.
|
|
13
|
+
* @returns {this} The schema instance with the added custom validation.
|
|
14
|
+
*/
|
|
15
|
+
custom(...validators) {
|
|
16
|
+
this[_chunk5NCJN6D2js.ctxSymbol].requiredValidations.push(...validators);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Marks the schema as nullable, allowing the value to be `null`.
|
|
21
|
+
*
|
|
22
|
+
* @returns {WithNull<this>} The schema instance marked as nullable.
|
|
23
|
+
*/
|
|
24
|
+
nullable() {
|
|
25
|
+
this[_chunk5NCJN6D2js.ctxSymbol].isNullable = true;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Marks the schema as optional, allowing the value to be `undefined`.
|
|
30
|
+
*
|
|
31
|
+
* @returns {WithUndefined<this>}} The schema instance marked as optional.
|
|
32
|
+
*/
|
|
33
|
+
optional() {
|
|
34
|
+
this[_chunk5NCJN6D2js.ctxSymbol].isOptional = true;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
exports.CommonSchema = CommonSchema;
|
|
42
|
+
//# sourceMappingURL=chunk-APTTIN2L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-APTTIN2L.js","../src/schemas/CommonSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACYO,IAAM,aAAA,EAAN,MAAmB;AAAA,EACxB;AAAU,EACV,WAAA,CAAY,GAAA,EAAuB;AACjC,IAAA,IAAA,CAAK,0BAAS,EAAA,EAAI,GAAA;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAA,CAAA,GAAU,UAAA,EAAwC;AAChD,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,mBAAA,CAAoB,IAAA,CAAK,GAAG,UAAU,CAAA;AACtD,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAA,CAAA,EAA2B;AACzB,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAA,CAAA,EAAgC;AAC9B,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AACF,CAAA;ADbA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-APTTIN2L.js","sourcesContent":[null,"import { ctxSymbol } from '../core';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RequiredValidation = (received: any, pathToError: string) => void;\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport type PrimitiveType = 'number' | 'string' | 'boolean' | 'undefined' | 'object' | 'function' | 'symbol' | 'bigint';\nexport interface ValidatorContext {\n type: PrimitiveType[];\n isNullable?: boolean;\n isOptional?: boolean;\n requiredValidations: RequiredValidation[];\n array?: CommonSchema;\n object?: ObjectShapeSchemaType;\n}\n\nexport class CommonSchema {\n [ctxSymbol]: ValidatorContext;\n constructor(ctx: ValidatorContext) {\n this[ctxSymbol] = ctx;\n }\n\n /**\n * @param validators - One or more custom validation functions.\n * @returns {this} The schema instance with the added custom validation.\n */\n custom(...validators: RequiredValidation[]): this {\n this[ctxSymbol].requiredValidations.push(...validators);\n return this;\n }\n\n /**\n * Marks the schema as nullable, allowing the value to be `null`.\n *\n * @returns {WithNull<this>} The schema instance marked as nullable.\n */\n nullable(): WithNull<this> {\n this[ctxSymbol].isNullable = true;\n return this as WithNull<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {WithUndefined<this>}} The schema instance marked as optional.\n */\n optional(): WithUndefined<this> {\n this[ctxSymbol].isOptional = true;\n return this as WithUndefined<this>;\n }\n}\n\nexport type WithNull<T extends CommonSchema> = T & { validation_null: true };\nexport type WithUndefined<T extends CommonSchema> = T & { validation_undefined: true };\n\ntype TypeMapping = {\n number: number;\n string: string;\n boolean: boolean;\n undefined: undefined;\n object: object;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n function: Function;\n symbol: symbol;\n bigint: bigint;\n};\n\nexport type WithMix<Y = unknown> = CommonSchema & { validation_mix: Y };\nexport type ExtractFromMix<T> = T extends WithMix<infer X> ? X : never;\n\nexport type MapMixTypes<T extends PrimitiveType[]> = T extends (infer U)[]\n ? U extends keyof TypeMapping\n ? TypeMapping[U]\n : never\n : never;\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk2AP4OQMTjs = require('./chunk-2AP4OQMT.js');
|
|
4
|
+
|
|
5
|
+
// src/asserts/common/equalTo.ts
|
|
6
|
+
var equalTo = (expected) => (received, pathToError) => {
|
|
7
|
+
if (expected !== received)
|
|
8
|
+
_chunk2AP4OQMTjs.throwException.call(void 0, expected, received, pathToError, "The received value is not equal to expected");
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.equalTo = equalTo;
|
|
14
|
+
//# sourceMappingURL=chunk-AXOP6HPJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-AXOP6HPJ.js","../src/asserts/common/equalTo.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACuBO,IAAM,QAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,WAAA,EAAA,GAAwB;AACzC,EAAA,GAAA,CAAI,SAAA,IAAa,QAAA;AACf,IAAA,6CAAA,QAAe,EAAU,QAAA,EAAU,WAAA,EAAa,6CAA6C,CAAA;AACjG,CAAA;ADvBF;AACA;AACE;AACF,0BAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-AXOP6HPJ.js","sourcesContent":[null,"import { throwException } from '../../exceptions';\nimport { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Creates a custom assertion that checks if a value is equal to the expected value.\n *\n * This assertion can be used within a `.custom` method to enforce that a value strictly matches the expected value.\n * It will throw a `ValidationError` if the values are not equal.\n *\n * @param {unknown} expected - The value that the received value is expected to match.\n * @returns {RequiredValidation} A function that takes the received value and the path to the error,\n * and throws a `ValidationError` if the received value does not equal the expected value.\n *\n * @throws {ValidationError} If the received value does not match the expected value.\n *\n * @example\n * import { number, equalTo } from 'bguard';\n *\n * // Define a schema with a custom assertion\n * const schema = number().custom(equalTo(5));\n *\n * // This will pass\n * parseSchema(schema, 5);\n *\n * // This will throw a ValidationError\n * parseSchema(schema, 3);\n */\nexport const equalTo =\n (expected: unknown): RequiredValidation =>\n (received: number, pathToError: string) => {\n if (expected !== received)\n throwException(expected, received, pathToError, 'The received value is not equal to expected');\n };\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NumberSchema
|
|
3
|
+
} from "./chunk-63IQFNFO.mjs";
|
|
4
|
+
|
|
5
|
+
// src/asserts/number/index.ts
|
|
6
|
+
function number() {
|
|
7
|
+
return new NumberSchema({ type: ["number"], requiredValidations: [] });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
number
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-BGMR7A6X.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/asserts/number/index.ts"],"sourcesContent":["import { NumberSchema } from '../../schemas/NumberSchema';\n\n/**\n * Creates a new schema for validating number values.\n *\n * @returns {NumberSchema} A new instance of `NumberSchema` for validating numbers.\n *\n * @example\n * const schema = number();\n * parseSchema(schema, 42); // Validates successfully\n * parseSchema(schema, '42'); // Throws a validation error\n */\nexport function number(): NumberSchema {\n return new NumberSchema({ type: ['number'], requiredValidations: [] });\n}\n"],"mappings":";;;;;AAYO,SAAS,SAAuB;AACrC,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,QAAQ,GAAG,qBAAqB,CAAC,EAAE,CAAC;AACvE;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
throwException
|
|
3
|
+
} from "./chunk-QJOXKH7A.mjs";
|
|
4
|
+
|
|
5
|
+
// src/asserts/common/equalTo.ts
|
|
6
|
+
var equalTo = (expected) => (received, pathToError) => {
|
|
7
|
+
if (expected !== received)
|
|
8
|
+
throwException(expected, received, pathToError, "The received value is not equal to expected");
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
equalTo
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-FCFO5J5Y.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/asserts/common/equalTo.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Creates a custom assertion that checks if a value is equal to the expected value.\n *\n * This assertion can be used within a `.custom` method to enforce that a value strictly matches the expected value.\n * It will throw a `ValidationError` if the values are not equal.\n *\n * @param {unknown} expected - The value that the received value is expected to match.\n * @returns {RequiredValidation} A function that takes the received value and the path to the error,\n * and throws a `ValidationError` if the received value does not equal the expected value.\n *\n * @throws {ValidationError} If the received value does not match the expected value.\n *\n * @example\n * import { number, equalTo } from 'bguard';\n *\n * // Define a schema with a custom assertion\n * const schema = number().custom(equalTo(5));\n *\n * // This will pass\n * parseSchema(schema, 5);\n *\n * // This will throw a ValidationError\n * parseSchema(schema, 3);\n */\nexport const equalTo =\n (expected: unknown): RequiredValidation =>\n (received: number, pathToError: string) => {\n if (expected !== received)\n throwException(expected, received, pathToError, 'The received value is not equal to expected');\n };\n"],"mappings":";;;;;AA2BO,IAAM,UACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,aAAa;AACf,mBAAe,UAAU,UAAU,aAAa,6CAA6C;AACjG;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CommonSchema
|
|
3
|
+
} from "./chunk-L7HUXYFV.mjs";
|
|
4
|
+
import {
|
|
5
|
+
throwException
|
|
6
|
+
} from "./chunk-QJOXKH7A.mjs";
|
|
7
|
+
|
|
8
|
+
// src/schemas/BooleanSchema.ts
|
|
9
|
+
var isBoolean = (expected) => (received, pathToError) => {
|
|
10
|
+
if (received !== expected) throwException(expected, received, pathToError, `The received value is not ${expected}`);
|
|
11
|
+
};
|
|
12
|
+
var BooleanSchema = class extends CommonSchema {
|
|
13
|
+
_boolean = 1;
|
|
14
|
+
/**
|
|
15
|
+
* Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.
|
|
16
|
+
*
|
|
17
|
+
* @returns - The schema instance restricted to the value true, with the true value inferred as the TypeScript type
|
|
18
|
+
*
|
|
19
|
+
* @example - boolean().onlyTrue(); // Infers the type true
|
|
20
|
+
*/
|
|
21
|
+
onlyTrue() {
|
|
22
|
+
return this.custom(isBoolean(true));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Restricts the schema to exactly match the boolean value false and infers the false value as the TypeScript type.
|
|
26
|
+
*
|
|
27
|
+
* @returns - The schema instance restricted to the value false, with the false value inferred as the TypeScript type
|
|
28
|
+
*
|
|
29
|
+
* @example - boolean().onlyFalse(); // Infers the type false
|
|
30
|
+
*/
|
|
31
|
+
onlyFalse() {
|
|
32
|
+
return this.custom(isBoolean(false));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
BooleanSchema
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=chunk-GEZME6V2.mjs.map
|