bguard 0.0.8 → 0.1.0
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/README.md +507 -23
- package/lib/{CommonSchema-BIe85W_A.d.mts → CommonSchema-BbGNki0L.d.ts} +7 -4
- package/lib/{CommonSchema-BIe85W_A.d.ts → CommonSchema-CjsYE4dC.d.mts} +7 -4
- package/lib/InferType.d.mts +2 -1
- package/lib/InferType.d.ts +2 -1
- package/lib/asserts/array/index.d.mts +4 -3
- package/lib/asserts/array/index.d.ts +4 -3
- package/lib/asserts/array/index.js +6 -6
- package/lib/asserts/array/index.mjs +5 -5
- package/lib/asserts/boolean/index.d.mts +4 -3
- package/lib/asserts/boolean/index.d.ts +4 -3
- package/lib/asserts/boolean/index.js +7 -6
- package/lib/asserts/boolean/index.js.map +1 -1
- package/lib/asserts/boolean/index.mjs +6 -5
- package/lib/asserts/mix/equalTo.d.mts +22 -0
- package/lib/asserts/mix/equalTo.d.ts +22 -0
- package/lib/asserts/mix/equalTo.js +9 -0
- package/lib/asserts/mix/equalTo.js.map +1 -0
- package/lib/asserts/mix/equalTo.mjs +9 -0
- package/lib/asserts/{common → mix}/index.d.mts +5 -4
- package/lib/asserts/{common → mix}/index.d.ts +5 -4
- package/lib/asserts/mix/index.js +10 -0
- package/lib/asserts/mix/index.js.map +1 -0
- package/lib/asserts/mix/index.mjs +10 -0
- package/lib/asserts/mix/oneOfValues.d.mts +23 -0
- package/lib/asserts/mix/oneOfValues.d.ts +23 -0
- package/lib/asserts/mix/oneOfValues.js +9 -0
- package/lib/asserts/mix/oneOfValues.js.map +1 -0
- package/lib/asserts/mix/oneOfValues.mjs +9 -0
- package/lib/asserts/number/index.d.mts +4 -3
- package/lib/asserts/number/index.d.ts +4 -3
- package/lib/asserts/number/index.js +10 -7
- package/lib/asserts/number/index.js.map +1 -1
- package/lib/asserts/number/index.mjs +9 -6
- package/lib/asserts/number/max.d.mts +15 -10
- package/lib/asserts/number/max.d.ts +15 -10
- package/lib/asserts/number/max.js +11 -4
- package/lib/asserts/number/max.js.map +1 -1
- package/lib/asserts/number/max.mjs +12 -5
- package/lib/asserts/number/max.mjs.map +1 -1
- package/lib/asserts/number/maxExcluded.d.mts +14 -9
- package/lib/asserts/number/maxExcluded.d.ts +14 -9
- package/lib/asserts/number/maxExcluded.js +11 -4
- package/lib/asserts/number/maxExcluded.js.map +1 -1
- package/lib/asserts/number/maxExcluded.mjs +12 -5
- package/lib/asserts/number/maxExcluded.mjs.map +1 -1
- package/lib/asserts/number/min.d.mts +15 -10
- package/lib/asserts/number/min.d.ts +15 -10
- package/lib/asserts/number/min.js +11 -4
- package/lib/asserts/number/min.js.map +1 -1
- package/lib/asserts/number/min.mjs +12 -5
- package/lib/asserts/number/min.mjs.map +1 -1
- package/lib/asserts/number/minExcluded.d.mts +15 -10
- package/lib/asserts/number/minExcluded.d.ts +15 -10
- package/lib/asserts/number/minExcluded.js +11 -4
- package/lib/asserts/number/minExcluded.js.map +1 -1
- package/lib/asserts/number/minExcluded.mjs +12 -5
- package/lib/asserts/number/minExcluded.mjs.map +1 -1
- package/lib/asserts/number/negative.d.mts +14 -9
- package/lib/asserts/number/negative.d.ts +14 -9
- package/lib/asserts/number/negative.js +11 -3
- package/lib/asserts/number/negative.js.map +1 -1
- package/lib/asserts/number/negative.mjs +12 -4
- package/lib/asserts/number/negative.mjs.map +1 -1
- package/lib/asserts/number/positive.d.mts +14 -9
- package/lib/asserts/number/positive.d.ts +14 -9
- package/lib/asserts/number/positive.js +11 -3
- package/lib/asserts/number/positive.js.map +1 -1
- package/lib/asserts/number/positive.mjs +12 -4
- package/lib/asserts/number/positive.mjs.map +1 -1
- package/lib/asserts/object/index.d.mts +4 -3
- package/lib/asserts/object/index.d.ts +4 -3
- package/lib/asserts/object/index.js +6 -6
- package/lib/asserts/object/index.mjs +5 -5
- package/lib/asserts/string/email.d.mts +13 -9
- package/lib/asserts/string/email.d.ts +13 -9
- package/lib/asserts/string/email.js +11 -4
- package/lib/asserts/string/email.js.map +1 -1
- package/lib/asserts/string/email.mjs +12 -5
- package/lib/asserts/string/email.mjs.map +1 -1
- package/lib/asserts/string/index.d.mts +4 -3
- package/lib/asserts/string/index.d.ts +4 -3
- package/lib/asserts/string/index.js +10 -7
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +9 -6
- package/lib/asserts/string/maxLength.d.mts +14 -9
- package/lib/asserts/string/maxLength.d.ts +14 -9
- package/lib/asserts/string/maxLength.js +11 -4
- package/lib/asserts/string/maxLength.js.map +1 -1
- package/lib/asserts/string/maxLength.mjs +12 -5
- package/lib/asserts/string/maxLength.mjs.map +1 -1
- package/lib/asserts/string/minLength.d.mts +14 -9
- package/lib/asserts/string/minLength.d.ts +14 -9
- package/lib/asserts/string/minLength.js +11 -4
- package/lib/asserts/string/minLength.js.map +1 -1
- package/lib/asserts/string/minLength.mjs +12 -5
- package/lib/asserts/string/minLength.mjs.map +1 -1
- package/lib/asserts/string/regExp.d.mts +14 -9
- package/lib/asserts/string/regExp.d.ts +14 -9
- package/lib/asserts/string/regExp.js +11 -4
- package/lib/asserts/string/regExp.js.map +1 -1
- package/lib/asserts/string/regExp.mjs +12 -5
- package/lib/asserts/string/regExp.mjs.map +1 -1
- package/lib/{chunk-32IQXZRK.mjs → chunk-2PM3K3OE.mjs} +2 -2
- package/lib/{chunk-32IQXZRK.mjs.map → chunk-2PM3K3OE.mjs.map} +1 -1
- package/lib/chunk-3HTYHE2X.mjs +54 -0
- package/lib/chunk-3HTYHE2X.mjs.map +1 -0
- package/lib/chunk-3O4WCRC2.mjs +21 -0
- package/lib/chunk-3O4WCRC2.mjs.map +1 -0
- package/lib/chunk-4CYIMDP2.js +21 -0
- package/lib/chunk-4CYIMDP2.js.map +1 -0
- package/lib/{chunk-QKGQ4XZC.js → chunk-4RNK3I74.js} +3 -3
- package/lib/{chunk-QKGQ4XZC.js.map → chunk-4RNK3I74.js.map} +1 -1
- package/lib/chunk-5BVJ6YMH.js +54 -0
- package/lib/chunk-5BVJ6YMH.js.map +1 -0
- package/lib/chunk-6TH3DBDK.js +53 -0
- package/lib/chunk-6TH3DBDK.js.map +1 -0
- package/lib/chunk-7XFLH6R2.mjs +44 -0
- package/lib/chunk-7XFLH6R2.mjs.map +1 -0
- package/lib/{chunk-BGMR7A6X.mjs → chunk-B6TFELXR.mjs} +2 -2
- package/lib/{chunk-BGMR7A6X.mjs.map → chunk-B6TFELXR.mjs.map} +1 -1
- package/lib/{chunk-GEZME6V2.mjs → chunk-CCBCDJXS.mjs} +11 -6
- package/lib/chunk-CCBCDJXS.mjs.map +1 -0
- package/lib/chunk-CLG3QRZC.mjs +47 -0
- package/lib/chunk-CLG3QRZC.mjs.map +1 -0
- package/lib/chunk-DJSLA2ZV.js +27 -0
- package/lib/chunk-DJSLA2ZV.js.map +1 -0
- package/lib/{chunk-L7HUXYFV.mjs → chunk-DPBE7TAQ.mjs} +2 -2
- package/lib/chunk-DPBE7TAQ.mjs.map +1 -0
- package/lib/{chunk-APTTIN2L.js → chunk-EGEHSELT.js} +6 -6
- package/lib/chunk-EGEHSELT.js.map +1 -0
- package/lib/chunk-F5MSBL33.js +50 -0
- package/lib/chunk-F5MSBL33.js.map +1 -0
- package/lib/chunk-FTLRX2XG.mjs +50 -0
- package/lib/chunk-FTLRX2XG.mjs.map +1 -0
- package/lib/chunk-H7CPKW53.js +47 -0
- package/lib/chunk-H7CPKW53.js.map +1 -0
- package/lib/{chunk-A7I2JEQO.js → chunk-HDSGCAHH.js} +3 -3
- package/lib/{chunk-A7I2JEQO.js.map → chunk-HDSGCAHH.js.map} +1 -1
- package/lib/{chunk-L6A7NXUJ.js → chunk-IEUXIOL6.js} +3 -3
- package/lib/{chunk-L6A7NXUJ.js.map → chunk-IEUXIOL6.js.map} +1 -1
- package/lib/chunk-IRG4OQAB.js +63 -0
- package/lib/chunk-IRG4OQAB.js.map +1 -0
- package/lib/chunk-J4VKFJQK.js +21 -0
- package/lib/chunk-J4VKFJQK.js.map +1 -0
- package/lib/{chunk-A2SAWKJA.mjs → chunk-JDGZCBXF.mjs} +2 -2
- package/lib/{chunk-A2SAWKJA.mjs.map → chunk-JDGZCBXF.mjs.map} +1 -1
- package/lib/chunk-JSGZ7DKT.js +14 -0
- package/lib/chunk-JSGZ7DKT.js.map +1 -0
- package/lib/{chunk-AJ4WV5DG.mjs → chunk-MRISXZQ4.mjs} +3 -3
- package/lib/chunk-MRISXZQ4.mjs.map +1 -0
- package/lib/{chunk-A3UTB4RE.mjs → chunk-NDQM5OL4.mjs} +4 -4
- package/lib/chunk-NDQM5OL4.mjs.map +1 -0
- package/lib/chunk-NNFYXHLU.mjs +21 -0
- package/lib/chunk-NNFYXHLU.mjs.map +1 -0
- package/lib/{chunk-KCBOOOTF.mjs → chunk-NTC2XQ36.mjs} +2 -2
- package/lib/{chunk-KCBOOOTF.mjs.map → chunk-NTC2XQ36.mjs.map} +1 -1
- package/lib/chunk-PG2R7P7G.mjs +27 -0
- package/lib/chunk-PG2R7P7G.mjs.map +1 -0
- package/lib/chunk-PH2PMUZP.mjs +63 -0
- package/lib/chunk-PH2PMUZP.mjs.map +1 -0
- package/lib/chunk-QQNQ4IDN.js +13 -0
- package/lib/chunk-QQNQ4IDN.js.map +1 -0
- package/lib/{chunk-PJP63SJT.js → chunk-RL4MSI7R.js} +3 -3
- package/lib/{chunk-PJP63SJT.js.map → chunk-RL4MSI7R.js.map} +1 -1
- package/lib/chunk-RQH4LXBW.js +47 -0
- package/lib/chunk-RQH4LXBW.js.map +1 -0
- package/lib/chunk-RRQOET3X.js +28 -0
- package/lib/chunk-RRQOET3X.js.map +1 -0
- package/lib/chunk-RYVUYVEE.mjs +14 -0
- package/lib/chunk-RYVUYVEE.mjs.map +1 -0
- package/lib/{chunk-QYLH5ZAC.mjs → chunk-TCQY2R3U.mjs} +25 -4
- package/lib/chunk-TCQY2R3U.mjs.map +1 -0
- package/lib/{chunk-K2S3FS5K.js → chunk-VHEA4JZ5.js} +3 -3
- package/lib/{chunk-K2S3FS5K.js.map → chunk-VHEA4JZ5.js.map} +1 -1
- package/lib/{chunk-VPFIIM2X.js → chunk-WBERBAL4.js} +11 -6
- package/lib/chunk-WBERBAL4.js.map +1 -0
- package/lib/chunk-WK4O3HH4.js +44 -0
- package/lib/chunk-WK4O3HH4.js.map +1 -0
- package/lib/{chunk-3FEJUC3K.mjs → chunk-YML32TPA.mjs} +2 -2
- package/lib/{chunk-3FEJUC3K.mjs.map → chunk-YML32TPA.mjs.map} +1 -1
- package/lib/chunk-YUESB2WV.mjs +47 -0
- package/lib/chunk-YUESB2WV.mjs.map +1 -0
- package/lib/codeGen.d.mts +7 -0
- package/lib/codeGen.d.ts +7 -0
- package/lib/codeGen.js +51 -0
- package/lib/codeGen.js.map +1 -0
- package/lib/codeGen.mjs +51 -0
- package/lib/codeGen.mjs.map +1 -0
- package/lib/commonTypes.d.mts +31 -0
- package/lib/commonTypes.d.ts +31 -0
- package/lib/commonTypes.js +1 -0
- package/lib/commonTypes.js.map +1 -0
- package/lib/commonTypes.mjs +1 -0
- package/lib/exceptions.d.mts +4 -2
- package/lib/exceptions.d.ts +4 -2
- package/lib/exceptions.js +2 -2
- package/lib/exceptions.mjs +3 -3
- package/lib/helpers/core.d.mts +2 -0
- package/lib/helpers/core.d.ts +2 -0
- package/lib/helpers/core.js +10 -0
- package/lib/helpers/core.js.map +1 -0
- package/lib/helpers/core.mjs +10 -0
- package/lib/helpers/core.mjs.map +1 -0
- package/lib/helpers/setStrictType.d.mts +6 -0
- package/lib/helpers/setStrictType.d.ts +6 -0
- package/lib/helpers/setStrictType.js +9 -0
- package/lib/helpers/setStrictType.js.map +1 -0
- package/lib/helpers/setStrictType.mjs +9 -0
- package/lib/helpers/setStrictType.mjs.map +1 -0
- package/lib/index.d.mts +7 -4
- package/lib/index.d.ts +7 -4
- package/lib/index.js +31 -17
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +38 -24
- package/lib/parse.d.mts +66 -0
- package/lib/parse.d.ts +66 -0
- package/lib/parse.js +10 -0
- package/lib/parse.js.map +1 -0
- package/lib/parse.mjs +10 -0
- package/lib/parse.mjs.map +1 -0
- package/lib/{parseSchema.d.mts → parseOrFail.d.mts} +16 -5
- package/lib/{parseSchema.d.ts → parseOrFail.d.ts} +16 -5
- package/lib/parseOrFail.js +10 -0
- package/lib/parseOrFail.js.map +1 -0
- package/lib/parseOrFail.mjs +10 -0
- package/lib/parseOrFail.mjs.map +1 -0
- package/lib/schemas/ArraySchema.d.mts +2 -1
- package/lib/schemas/ArraySchema.d.ts +2 -1
- package/lib/schemas/ArraySchema.js +5 -5
- package/lib/schemas/ArraySchema.mjs +4 -4
- package/lib/schemas/BooleanSchema.d.mts +2 -1
- package/lib/schemas/BooleanSchema.d.ts +2 -1
- package/lib/schemas/BooleanSchema.js +6 -5
- package/lib/schemas/BooleanSchema.js.map +1 -1
- package/lib/schemas/BooleanSchema.mjs +5 -4
- package/lib/schemas/CommonSchema.d.mts +2 -1
- package/lib/schemas/CommonSchema.d.ts +2 -1
- package/lib/schemas/CommonSchema.js +4 -4
- package/lib/schemas/CommonSchema.mjs +3 -3
- package/lib/schemas/NumberSchema.d.mts +12 -1
- package/lib/schemas/NumberSchema.d.ts +12 -1
- package/lib/schemas/NumberSchema.js +9 -6
- package/lib/schemas/NumberSchema.js.map +1 -1
- package/lib/schemas/NumberSchema.mjs +8 -5
- package/lib/schemas/ObjectSchema.d.mts +20 -1
- package/lib/schemas/ObjectSchema.d.ts +20 -1
- package/lib/schemas/ObjectSchema.js +5 -5
- package/lib/schemas/ObjectSchema.mjs +4 -4
- package/lib/schemas/StringSchema.d.mts +12 -1
- package/lib/schemas/StringSchema.d.ts +12 -1
- package/lib/schemas/StringSchema.js +9 -6
- package/lib/schemas/StringSchema.js.map +1 -1
- package/lib/schemas/StringSchema.mjs +8 -5
- package/lib/translationMap.d.mts +12 -0
- package/lib/translationMap.d.ts +12 -0
- package/lib/translationMap.js +14 -0
- package/lib/translationMap.js.map +1 -0
- package/lib/translationMap.mjs +14 -0
- package/lib/translationMap.mjs.map +1 -0
- package/package.json +35 -18
- package/lib/asserts/common/equalTo.d.mts +0 -29
- package/lib/asserts/common/equalTo.d.ts +0 -29
- package/lib/asserts/common/equalTo.js +0 -8
- package/lib/asserts/common/equalTo.js.map +0 -1
- package/lib/asserts/common/equalTo.mjs +0 -8
- package/lib/asserts/common/index.js +0 -10
- package/lib/asserts/common/index.js.map +0 -1
- package/lib/asserts/common/index.mjs +0 -10
- package/lib/chunk-2AP4OQMT.js +0 -26
- package/lib/chunk-2AP4OQMT.js.map +0 -1
- package/lib/chunk-5NCJN6D2.js +0 -70
- package/lib/chunk-5NCJN6D2.js.map +0 -1
- package/lib/chunk-5ZMICHV3.js +0 -21
- package/lib/chunk-5ZMICHV3.js.map +0 -1
- package/lib/chunk-63IQFNFO.mjs +0 -27
- package/lib/chunk-63IQFNFO.mjs.map +0 -1
- package/lib/chunk-A3UTB4RE.mjs.map +0 -1
- package/lib/chunk-AJ4WV5DG.mjs.map +0 -1
- package/lib/chunk-APTTIN2L.js.map +0 -1
- package/lib/chunk-AXOP6HPJ.js +0 -14
- package/lib/chunk-AXOP6HPJ.js.map +0 -1
- package/lib/chunk-FCFO5J5Y.mjs +0 -14
- package/lib/chunk-FCFO5J5Y.mjs.map +0 -1
- package/lib/chunk-GEZME6V2.mjs.map +0 -1
- package/lib/chunk-GNBSKTFV.js +0 -27
- package/lib/chunk-GNBSKTFV.js.map +0 -1
- package/lib/chunk-IQ3QYABE.js +0 -32
- package/lib/chunk-IQ3QYABE.js.map +0 -1
- package/lib/chunk-L7HUXYFV.mjs.map +0 -1
- package/lib/chunk-LHTJHMKJ.mjs +0 -27
- package/lib/chunk-LHTJHMKJ.mjs.map +0 -1
- package/lib/chunk-NOADI6PO.mjs +0 -21
- package/lib/chunk-NOADI6PO.mjs.map +0 -1
- package/lib/chunk-NWY33MFU.js +0 -13
- package/lib/chunk-NWY33MFU.js.map +0 -1
- package/lib/chunk-P3Y6IWFA.mjs +0 -70
- package/lib/chunk-P3Y6IWFA.mjs.map +0 -1
- package/lib/chunk-PDVXBE27.js +0 -27
- package/lib/chunk-PDVXBE27.js.map +0 -1
- package/lib/chunk-QJOXKH7A.mjs +0 -26
- package/lib/chunk-QJOXKH7A.mjs.map +0 -1
- package/lib/chunk-QYLH5ZAC.mjs.map +0 -1
- package/lib/chunk-VPFIIM2X.js.map +0 -1
- package/lib/chunk-YXHH5BF6.js +0 -28
- package/lib/chunk-YXHH5BF6.js.map +0 -1
- package/lib/core.d.mts +0 -1
- package/lib/core.d.ts +0 -1
- package/lib/core.js +0 -10
- package/lib/core.js.map +0 -1
- package/lib/core.mjs +0 -10
- package/lib/parseSchema.js +0 -9
- package/lib/parseSchema.js.map +0 -1
- package/lib/parseSchema.mjs +0 -9
- /package/lib/asserts/{common → mix}/equalTo.mjs.map +0 -0
- /package/lib/asserts/{common → mix}/index.mjs.map +0 -0
- /package/lib/{core.mjs.map → asserts/mix/oneOfValues.mjs.map} +0 -0
- /package/lib/{parseSchema.mjs.map → commonTypes.mjs.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
package/lib/chunk-AXOP6HPJ.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
package/lib/chunk-FCFO5J5Y.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/BooleanSchema.ts"],"sourcesContent":["import { CommonSchema } from './CommonSchema';\nimport { throwException } from '../exceptions';\n\nconst isBoolean = (expected: boolean) => (received: boolean, pathToError: string) => {\n if (received !== expected) throwException(expected, received, pathToError, `The received value is not ${expected}`);\n};\n\nexport class BooleanSchema extends CommonSchema {\n _boolean = 1;\n\n /**\n * Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value true, with the true value inferred as the TypeScript type\n *\n * @example - boolean().onlyTrue(); // Infers the type true\n */\n onlyTrue(): WithBoolean<this, true> {\n return this.custom(isBoolean(true)) as WithBoolean<this, true>;\n }\n\n /**\n * Restricts the schema to exactly match the boolean value false and infers the false value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value false, with the false value inferred as the TypeScript type\n *\n * @example - boolean().onlyFalse(); // Infers the type false\n */\n onlyFalse(): WithBoolean<this, false> {\n return this.custom(isBoolean(false)) as WithBoolean<this, false>;\n }\n}\n\nexport type WithBoolean<T extends BooleanSchema, Y = boolean> = T & { validation_boolean: Y };\nexport type ExtractFromBoolean<T> = T extends WithBoolean<BooleanSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;AAGA,IAAM,YAAY,CAAC,aAAsB,CAAC,UAAmB,gBAAwB;AACnF,MAAI,aAAa,SAAU,gBAAe,UAAU,UAAU,aAAa,6BAA6B,QAAQ,EAAE;AACpH;AAEO,IAAM,gBAAN,cAA4B,aAAa;AAAA,EAC9C,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASX,WAAoC;AAClC,WAAO,KAAK,OAAO,UAAU,IAAI,CAAC;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,YAAsC;AACpC,WAAO,KAAK,OAAO,UAAU,KAAK,CAAC;AAAA,EACrC;AACF;","names":[]}
|
package/lib/chunk-GNBSKTFV.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
-
|
|
3
|
-
var _chunkAXOP6HPJjs = require('./chunk-AXOP6HPJ.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkAPTTIN2Ljs = require('./chunk-APTTIN2L.js');
|
|
7
|
-
|
|
8
|
-
// src/schemas/NumberSchema.ts
|
|
9
|
-
var NumberSchema = (_class = class extends _chunkAPTTIN2Ljs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
10
|
-
__init() {this._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(_chunkAXOP6HPJjs.equalTo.call(void 0, expectedValue));
|
|
21
|
-
}
|
|
22
|
-
}, _class);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
exports.NumberSchema = NumberSchema;
|
|
27
|
-
//# sourceMappingURL=chunk-GNBSKTFV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-GNBSKTFV.js","../src/schemas/NumberSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACHO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AACF,UAAA;ADIA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-GNBSKTFV.js","sourcesContent":[null,"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"]}
|
package/lib/chunk-IQ3QYABE.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
-
|
|
3
|
-
var _chunkAPTTIN2Ljs = require('./chunk-APTTIN2L.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunk5NCJN6D2js = require('./chunk-5NCJN6D2.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunk2AP4OQMTjs = require('./chunk-2AP4OQMT.js');
|
|
10
|
-
|
|
11
|
-
// src/schemas/ObjectSchema.ts
|
|
12
|
-
var ObjectSchema = (_class = class extends _chunkAPTTIN2Ljs.CommonSchema {
|
|
13
|
-
__init() {this._object = 1}
|
|
14
|
-
constructor(ctx, shapeSchema) {
|
|
15
|
-
super(ctx);_class.prototype.__init.call(this);;
|
|
16
|
-
this.validateObjectEntry(shapeSchema);
|
|
17
|
-
this[_chunk5NCJN6D2js.ctxSymbol].object = shapeSchema;
|
|
18
|
-
}
|
|
19
|
-
validateObjectEntry(shapeSchema) {
|
|
20
|
-
if (!shapeSchema) throw new (0, _chunk2AP4OQMTjs.BuildSchemaError)("Missing schema in object method");
|
|
21
|
-
if (shapeSchema instanceof _chunkAPTTIN2Ljs.CommonSchema) throw new (0, _chunk2AP4OQMTjs.BuildSchemaError)("Invalid schema in object");
|
|
22
|
-
for (const [key, value] of Object.entries(shapeSchema)) {
|
|
23
|
-
if (!(value instanceof _chunkAPTTIN2Ljs.CommonSchema))
|
|
24
|
-
throw new (0, _chunk2AP4OQMTjs.BuildSchemaError)(`Invalid schema in object method for property '${key}'`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}, _class);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
exports.ObjectSchema = ObjectSchema;
|
|
32
|
-
//# sourceMappingURL=chunk-IQ3QYABE.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-IQ3QYABE.js","../src/schemas/ObjectSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACV,WAAA,CAAY,GAAA,EAAuB,WAAA,EAAoC;AACrE,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,mBAAA,CAAoB,WAAW,CAAA;AACpC,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,OAAA,EAAS,WAAA;AAAA,EAC3B;AAAA,EAEQ,mBAAA,CAAoB,WAAA,EAAoC;AAC9D,IAAA,GAAA,CAAI,CAAC,WAAA,EAAa,MAAM,IAAI,sCAAA,CAAiB,iCAAiC,CAAA;AAC9E,IAAA,GAAA,CAAI,YAAA,WAAuB,6BAAA,EAAc,MAAM,IAAI,sCAAA,CAAiB,0BAA0B,CAAA;AAC9F,IAAA,IAAA,CAAA,MAAW,CAAC,GAAA,EAAK,KAAK,EAAA,GAAK,MAAA,CAAO,OAAA,CAAQ,WAAW,CAAA,EAAG;AACtD,MAAA,GAAA,CAAI,CAAA,CAAE,MAAA,WAAiB,6BAAA,CAAA;AACrB,QAAA,MAAM,IAAI,sCAAA,CAAiB,CAAA,8CAAA,EAAiD,GAAG,CAAA,CAAA,CAAG,CAAA;AAAA,IACtF;AAAA,EACF;AACF,UAAA;ADOA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-IQ3QYABE.js","sourcesContent":[null,"import { ctxSymbol } from '../core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ObjectShapeSchemaType, ValidatorContext } from './CommonSchema';\n\nexport class ObjectSchema extends CommonSchema {\n _object = 1;\n constructor(ctx: ValidatorContext, shapeSchema: ObjectShapeSchemaType) {\n super(ctx);\n this.validateObjectEntry(shapeSchema);\n this[ctxSymbol].object = shapeSchema;\n }\n\n private validateObjectEntry(shapeSchema: ObjectShapeSchemaType) {\n if (!shapeSchema) throw new BuildSchemaError('Missing schema in object method');\n if (shapeSchema instanceof CommonSchema) throw new BuildSchemaError('Invalid schema in object');\n for (const [key, value] of Object.entries(shapeSchema)) {\n if (!(value instanceof CommonSchema))\n throw new BuildSchemaError(`Invalid schema in object method for property '${key}'`);\n }\n }\n}\n\nexport type WithObject<Y extends ObjectShapeSchemaType> = ObjectSchema & { validation_object: Y };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/CommonSchema.ts"],"sourcesContent":["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"],"mappings":";;;;;AAgBO,IAAM,eAAN,MAAmB;AAAA,EACxB,CAAC,SAAS;AAAA,EACV,YAAY,KAAuB;AACjC,SAAK,SAAS,IAAI;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,YAAwC;AAChD,SAAK,SAAS,EAAE,oBAAoB,KAAK,GAAG,UAAU;AACtD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAA2B;AACzB,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAgC;AAC9B,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/lib/chunk-LHTJHMKJ.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
equalTo
|
|
3
|
-
} from "./chunk-FCFO5J5Y.mjs";
|
|
4
|
-
import {
|
|
5
|
-
CommonSchema
|
|
6
|
-
} from "./chunk-L7HUXYFV.mjs";
|
|
7
|
-
|
|
8
|
-
// src/schemas/StringSchema.ts
|
|
9
|
-
var StringSchema = class extends CommonSchema {
|
|
10
|
-
_string = 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 - string().equalTo('hello'); // Infers the type 'hello'
|
|
18
|
-
*/
|
|
19
|
-
equalTo(expectedValue) {
|
|
20
|
-
return this.custom(equalTo(expectedValue));
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
StringSchema
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=chunk-LHTJHMKJ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/StringSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/common/equalTo';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 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 - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n}\n\nexport type WithString<T extends StringSchema, Y = string> = T & { validation_string: Y };\nexport type ExtractFromString<T> = T extends WithString<StringSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;AAGO,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":[]}
|
package/lib/chunk-NOADI6PO.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
innerCheck
|
|
3
|
-
} from "./chunk-P3Y6IWFA.mjs";
|
|
4
|
-
import {
|
|
5
|
-
ValidationError
|
|
6
|
-
} from "./chunk-QJOXKH7A.mjs";
|
|
7
|
-
|
|
8
|
-
// src/parseSchema.ts
|
|
9
|
-
function parseSchema(schema, receivedValue) {
|
|
10
|
-
try {
|
|
11
|
-
return innerCheck(schema, receivedValue, "");
|
|
12
|
-
} catch (e) {
|
|
13
|
-
if (e instanceof ValidationError) throw e;
|
|
14
|
-
throw new Error("Something unexpected happened");
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
parseSchema
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=chunk-NOADI6PO.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parseSchema.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;AA+BO,SAAS,YAAoC,QAAW,eAAsC;AACnG,MAAI;AACF,WAAO,WAAW,QAAQ,eAAe,EAAE;AAAA,EAC7C,SAAS,GAAG;AACV,QAAI,aAAa,gBAAiB,OAAM;AAExC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AACF;","names":[]}
|
package/lib/chunk-NWY33MFU.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkAPTTIN2Ljs = require('./chunk-APTTIN2L.js');
|
|
4
|
-
|
|
5
|
-
// src/asserts/common/index.ts
|
|
6
|
-
function oneOfTypes(valueTypes) {
|
|
7
|
-
return new (0, _chunkAPTTIN2Ljs.CommonSchema)({ type: valueTypes, requiredValidations: [] });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.oneOfTypes = oneOfTypes;
|
|
13
|
-
//# sourceMappingURL=chunk-NWY33MFU.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-NWY33MFU.js","../src/asserts/common/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACWO,SAAS,UAAA,CAAsC,UAAA,EAAwC;AAC5F,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,UAAA,EAAY,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADTA;AACA;AACE;AACF,gCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-NWY33MFU.js","sourcesContent":[null,"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"]}
|
package/lib/chunk-P3Y6IWFA.mjs
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
throwException
|
|
3
|
-
} from "./chunk-QJOXKH7A.mjs";
|
|
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) throwException("Required", receivedValue, pathToError, "The required value is missing");
|
|
11
|
-
return receivedValue;
|
|
12
|
-
}
|
|
13
|
-
if (receivedValue === null) {
|
|
14
|
-
if (!ctx.isNullable) throwException("Not null", receivedValue, pathToError, "Value should not be null");
|
|
15
|
-
return receivedValue;
|
|
16
|
-
}
|
|
17
|
-
if (ctx.array) {
|
|
18
|
-
if (!Array.isArray(receivedValue))
|
|
19
|
-
throwException("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
|
-
throwException("Object", receivedValue, pathToError, "Expected an object but received a different type");
|
|
30
|
-
if (Array.isArray(receivedValue))
|
|
31
|
-
throwException(
|
|
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
|
-
throwException("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
|
-
throwException(
|
|
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)) throwException(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
|
-
export {
|
|
67
|
-
ctxSymbol,
|
|
68
|
-
innerCheck
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=chunk-P3Y6IWFA.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core.ts"],"sourcesContent":["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"],"mappings":";;;;;AAAO,IAAM,YAAY,OAAO,eAAe;AAKxC,SAAS,WAAW,QAAsB,eAAwB,aAAqB;AAC5F,QAAM,MAAM,OAAO,SAAS;AAC5B,MAAI,kBAAkB,QAAW;AAC/B,QAAI,CAAC,IAAI,WAAY,gBAAe,YAAY,eAAe,aAAa,+BAA+B;AAC3G,WAAO;AAAA,EACT;AAEA,MAAI,kBAAkB,MAAM;AAC1B,QAAI,CAAC,IAAI,WAAY,gBAAe,YAAY,eAAe,aAAa,0BAA0B;AACtG,WAAO;AAAA,EACT;AAEA,MAAI,IAAI,OAAO;AACb,QAAI,CAAC,MAAM,QAAQ,aAAa;AAC9B,qBAAe,SAAS,eAAe,aAAa,iDAAiD;AACvG,UAAMA,UAAS,IAAI;AAEnB,kBAAc,QAAQ,CAAC,MAAM,MAAM;AACjC,iBAAWA,SAAQ,MAAM,GAAG,WAAW,IAAI,CAAC,GAAG;AAAA,IACjD,CAAC;AAED,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO;AAEzB,MAAI,IAAI,QAAQ;AACd,QAAI,cAAc;AAChB,qBAAe,UAAU,eAAe,aAAa,kDAAkD;AACzG,QAAI,MAAM,QAAQ,aAAa;AAC7B;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACF,UAAM,cAAc,IAAI;AACxB,eAAW,uBAAuB,OAAO,KAAK,aAAa,GAAG;AAC5D,UAAI,YAAY,mBAAmB,MAAM;AACvC,uBAAe,eAAe,qBAAqB,aAAa,uCAAuC;AAAA,IAC3G;AAEA,eAAW,CAAC,aAAa,aAAa,KAAK,OAAO,QAAQ,WAAW,GAAG;AACtE,YAAM,6BAA8B,cAA0C,WAAW;AACzF,UAAI,+BAA+B,QAAW;AAC5C,YAAI,CAAC,cAAc,SAAS,EAAE;AAC5B;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,MACJ;AACA,iBAAW,eAAe,4BAA4B,GAAG,WAAW,IAAI,WAAW,EAAE;AAAA,IACvF;AAEA,WAAO;AAAA,EACT;AAEA,MAAI,IAAI,KAAK,QAAQ;AACnB,QAAI,CAAC,IAAI,KAAK,SAAS,SAAS,EAAG,gBAAe,IAAI,MAAM,WAAW,aAAa,sBAAsB;AAAA,EAC5G;AAEA,MAAI,oBAAoB,QAAQ,CAAC,uBAAuB;AACtD,uBAAmB,eAAe,WAAW;AAAA,EAC/C,CAAC;AAED,SAAO;AACT;","names":["schema"]}
|
package/lib/chunk-PDVXBE27.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
-
|
|
3
|
-
var _chunkAXOP6HPJjs = require('./chunk-AXOP6HPJ.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkAPTTIN2Ljs = require('./chunk-APTTIN2L.js');
|
|
7
|
-
|
|
8
|
-
// src/schemas/StringSchema.ts
|
|
9
|
-
var StringSchema = (_class = class extends _chunkAPTTIN2Ljs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
10
|
-
__init() {this._string = 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 - string().equalTo('hello'); // Infers the type 'hello'
|
|
18
|
-
*/
|
|
19
|
-
equalTo(expectedValue) {
|
|
20
|
-
return this.custom(_chunkAXOP6HPJjs.equalTo.call(void 0, expectedValue));
|
|
21
|
-
}
|
|
22
|
-
}, _class);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
exports.StringSchema = StringSchema;
|
|
27
|
-
//# sourceMappingURL=chunk-PDVXBE27.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-PDVXBE27.js","../src/schemas/StringSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACJO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUV,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AACF,UAAA;ADKA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-PDVXBE27.js","sourcesContent":[null,"import { equalTo } from '../asserts/common/equalTo';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 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 - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n}\n\nexport type WithString<T extends StringSchema, Y = string> = T & { validation_string: Y };\nexport type ExtractFromString<T> = T extends WithString<StringSchema, infer Y> ? Y : never;\n"]}
|
package/lib/chunk-QJOXKH7A.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// src/exceptions.ts
|
|
2
|
-
var ValidationError = class extends Error {
|
|
3
|
-
expected;
|
|
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
|
-
var BuildSchemaError = class extends Error {
|
|
16
|
-
};
|
|
17
|
-
function throwException(expected, received, pathToError, message) {
|
|
18
|
-
throw new ValidationError(expected, received, pathToError, message);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
ValidationError,
|
|
23
|
-
BuildSchemaError,
|
|
24
|
-
throwException
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=chunk-QJOXKH7A.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/exceptions.ts"],"sourcesContent":["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"],"mappings":";AAAO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAEO,IAAM,mBAAN,cAA+B,MAAM;AAAC;AAEtC,SAAS,eAAe,UAAmB,UAAmB,aAAqB,SAAwB;AAChH,QAAM,IAAI,gBAAgB,UAAU,UAAU,aAAa,OAAO;AACpE;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/ObjectSchema.ts"],"sourcesContent":["import { ctxSymbol } from '../core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ObjectShapeSchemaType, ValidatorContext } from './CommonSchema';\n\nexport class ObjectSchema extends CommonSchema {\n _object = 1;\n constructor(ctx: ValidatorContext, shapeSchema: ObjectShapeSchemaType) {\n super(ctx);\n this.validateObjectEntry(shapeSchema);\n this[ctxSymbol].object = shapeSchema;\n }\n\n private validateObjectEntry(shapeSchema: ObjectShapeSchemaType) {\n if (!shapeSchema) throw new BuildSchemaError('Missing schema in object method');\n if (shapeSchema instanceof CommonSchema) throw new BuildSchemaError('Invalid schema in object');\n for (const [key, value] of Object.entries(shapeSchema)) {\n if (!(value instanceof CommonSchema))\n throw new BuildSchemaError(`Invalid schema in object method for property '${key}'`);\n }\n }\n}\n\nexport type WithObject<Y extends ObjectShapeSchemaType> = ObjectSchema & { validation_object: Y };\n"],"mappings":";;;;;;;;;;;AAIO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACV,YAAY,KAAuB,aAAoC;AACrE,UAAM,GAAG;AACT,SAAK,oBAAoB,WAAW;AACpC,SAAK,SAAS,EAAE,SAAS;AAAA,EAC3B;AAAA,EAEQ,oBAAoB,aAAoC;AAC9D,QAAI,CAAC,YAAa,OAAM,IAAI,iBAAiB,iCAAiC;AAC9E,QAAI,uBAAuB,aAAc,OAAM,IAAI,iBAAiB,0BAA0B;AAC9F,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,GAAG;AACtD,UAAI,EAAE,iBAAiB;AACrB,cAAM,IAAI,iBAAiB,iDAAiD,GAAG,GAAG;AAAA,IACtF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-VPFIIM2X.js","../src/schemas/BooleanSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACJA,IAAM,UAAA,EAAY,CAAC,QAAA,EAAA,GAAsB,CAAC,QAAA,EAAmB,WAAA,EAAA,GAAwB;AACnF,EAAA,GAAA,CAAI,SAAA,IAAa,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,WAAA,EAAa,CAAA,0BAAA,EAA6B,QAAQ,CAAA,CAAA;AAClH;AAEgD;AACnC,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASyB,EAAA;AACA,IAAA;AACpC,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASsC,EAAA;AACD,IAAA;AACrC,EAAA;AACF;ADGmH;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-VPFIIM2X.js","sourcesContent":[null,"import { CommonSchema } from './CommonSchema';\nimport { throwException } from '../exceptions';\n\nconst isBoolean = (expected: boolean) => (received: boolean, pathToError: string) => {\n if (received !== expected) throwException(expected, received, pathToError, `The received value is not ${expected}`);\n};\n\nexport class BooleanSchema extends CommonSchema {\n _boolean = 1;\n\n /**\n * Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value true, with the true value inferred as the TypeScript type\n *\n * @example - boolean().onlyTrue(); // Infers the type true\n */\n onlyTrue(): WithBoolean<this, true> {\n return this.custom(isBoolean(true)) as WithBoolean<this, true>;\n }\n\n /**\n * Restricts the schema to exactly match the boolean value false and infers the false value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value false, with the false value inferred as the TypeScript type\n *\n * @example - boolean().onlyFalse(); // Infers the type false\n */\n onlyFalse(): WithBoolean<this, false> {\n return this.custom(isBoolean(false)) as WithBoolean<this, false>;\n }\n}\n\nexport type WithBoolean<T extends BooleanSchema, Y = boolean> = T & { validation_boolean: Y };\nexport type ExtractFromBoolean<T> = T extends WithBoolean<BooleanSchema, infer Y> ? Y : never;\n"]}
|
package/lib/chunk-YXHH5BF6.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
-
|
|
3
|
-
var _chunkAPTTIN2Ljs = require('./chunk-APTTIN2L.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunk5NCJN6D2js = require('./chunk-5NCJN6D2.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunk2AP4OQMTjs = require('./chunk-2AP4OQMT.js');
|
|
10
|
-
|
|
11
|
-
// src/schemas/ArraySchema.ts
|
|
12
|
-
var ArraySchema = (_class = class extends _chunkAPTTIN2Ljs.CommonSchema {
|
|
13
|
-
__init() {this._array = 1}
|
|
14
|
-
constructor(ctx, arraySchema) {
|
|
15
|
-
super(ctx);_class.prototype.__init.call(this);;
|
|
16
|
-
this.validateArrayEntry(arraySchema);
|
|
17
|
-
this[_chunk5NCJN6D2js.ctxSymbol].array = arraySchema;
|
|
18
|
-
}
|
|
19
|
-
validateArrayEntry(arraySchema) {
|
|
20
|
-
if (!arraySchema) throw new (0, _chunk2AP4OQMTjs.BuildSchemaError)("Missing schema in array method");
|
|
21
|
-
if (!(arraySchema instanceof _chunkAPTTIN2Ljs.CommonSchema)) throw new (0, _chunk2AP4OQMTjs.BuildSchemaError)("Invalid schema in array method");
|
|
22
|
-
}
|
|
23
|
-
}, _class);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
exports.ArraySchema = ArraySchema;
|
|
28
|
-
//# sourceMappingURL=chunk-YXHH5BF6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-YXHH5BF6.js","../src/schemas/ArraySchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNO,IAAM,YAAA,YAAN,MAAA,QAA0B,8BAAa;AAAA,iBAC5C,OAAA,EAAS,EAAA;AAAA,EACT,WAAA,CAAY,GAAA,EAAuB,WAAA,EAA2B;AAC5D,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,kBAAA,CAAmB,WAAW,CAAA;AACnC,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,MAAA,EAAQ,WAAA;AAAA,EAC1B;AAAA,EAEQ,kBAAA,CAAmB,WAAA,EAA2B;AACpD,IAAA,GAAA,CAAI,CAAC,WAAA,EAAa,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAC7E,IAAA,GAAA,CAAI,CAAA,CAAE,YAAA,WAAuB,6BAAA,CAAA,EAAe,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAAA,EACzG;AACF,UAAA;ADOA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-YXHH5BF6.js","sourcesContent":[null,"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"]}
|
package/lib/core.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { c as ctxSymbol, i as innerCheck } from './CommonSchema-BIe85W_A.mjs';
|
package/lib/core.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { c as ctxSymbol, i as innerCheck } from './CommonSchema-BIe85W_A.js';
|
package/lib/core.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunk5NCJN6D2js = require('./chunk-5NCJN6D2.js');
|
|
5
|
-
require('./chunk-2AP4OQMT.js');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.ctxSymbol = _chunk5NCJN6D2js.ctxSymbol; exports.innerCheck = _chunk5NCJN6D2js.innerCheck;
|
|
10
|
-
//# sourceMappingURL=core.js.map
|
package/lib/core.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/core.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACA;AACF,iGAAC","file":"/home/runner/work/bguard/bguard/lib/core.js"}
|
package/lib/core.mjs
DELETED
package/lib/parseSchema.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunk5ZMICHV3js = require('./chunk-5ZMICHV3.js');
|
|
4
|
-
require('./chunk-5NCJN6D2.js');
|
|
5
|
-
require('./chunk-2AP4OQMT.js');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.parseSchema = _chunk5ZMICHV3js.parseSchema;
|
|
9
|
-
//# sourceMappingURL=parseSchema.js.map
|
package/lib/parseSchema.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/parseSchema.js"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACF,mDAAC","file":"/home/runner/work/bguard/bguard/lib/parseSchema.js"}
|
package/lib/parseSchema.mjs
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|