bguard 0.2.0 → 0.4.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 +777 -447
- package/lib/CommonSchema-DOh3bsL-.d.ts +110 -0
- package/lib/CommonSchema-wi9MOXGF.d.mts +110 -0
- package/lib/InferType.d.mts +6 -14
- package/lib/InferType.d.ts +6 -14
- package/lib/asserts/array/index.d.mts +6 -5
- package/lib/asserts/array/index.d.ts +6 -5
- package/lib/asserts/array/index.js +8 -6
- package/lib/asserts/array/index.js.map +1 -1
- package/lib/asserts/array/index.mjs +7 -5
- package/lib/asserts/array/index.mjs.map +1 -1
- package/lib/asserts/array/maxArrayLength.d.mts +22 -0
- package/lib/asserts/array/maxArrayLength.d.ts +22 -0
- package/lib/asserts/array/maxArrayLength.js +20 -0
- package/lib/asserts/array/maxArrayLength.js.map +1 -0
- package/lib/asserts/array/maxArrayLength.mjs +20 -0
- package/lib/asserts/array/maxArrayLength.mjs.map +1 -0
- package/lib/asserts/array/minArrayLength.d.mts +22 -0
- package/lib/asserts/array/minArrayLength.d.ts +22 -0
- package/lib/asserts/array/minArrayLength.js +20 -0
- package/lib/asserts/array/minArrayLength.js.map +1 -0
- package/lib/asserts/array/minArrayLength.mjs +20 -0
- package/lib/asserts/array/minArrayLength.mjs.map +1 -0
- package/lib/asserts/bigint/bigintMax.js +4 -4
- package/lib/asserts/bigint/bigintMax.mjs +2 -2
- package/lib/asserts/bigint/bigintMaxExcluded.js +4 -4
- package/lib/asserts/bigint/bigintMaxExcluded.mjs +2 -2
- package/lib/asserts/bigint/bigintMin.js +4 -4
- package/lib/asserts/bigint/bigintMin.mjs +2 -2
- package/lib/asserts/bigint/bigintMinExcluded.js +4 -4
- package/lib/asserts/bigint/bigintMinExcluded.mjs +2 -2
- package/lib/asserts/bigint/index.d.mts +5 -4
- package/lib/asserts/bigint/index.d.ts +5 -4
- package/lib/asserts/bigint/index.js +11 -10
- package/lib/asserts/bigint/index.js.map +1 -1
- package/lib/asserts/bigint/index.mjs +10 -9
- package/lib/asserts/bigint/index.mjs.map +1 -1
- package/lib/asserts/boolean/index.d.mts +5 -4
- package/lib/asserts/boolean/index.d.ts +5 -4
- package/lib/asserts/boolean/index.js +9 -7
- package/lib/asserts/boolean/index.js.map +1 -1
- package/lib/asserts/boolean/index.mjs +8 -6
- package/lib/asserts/boolean/index.mjs.map +1 -1
- package/lib/asserts/date/dateMax.js +6 -6
- package/lib/asserts/date/dateMax.js.map +1 -1
- package/lib/asserts/date/dateMax.mjs +5 -5
- package/lib/asserts/date/dateMax.mjs.map +1 -1
- package/lib/asserts/date/dateMin.js +6 -6
- package/lib/asserts/date/dateMin.js.map +1 -1
- package/lib/asserts/date/dateMin.mjs +5 -5
- package/lib/asserts/date/dateMin.mjs.map +1 -1
- package/lib/asserts/date/index.d.mts +5 -4
- package/lib/asserts/date/index.d.ts +5 -4
- package/lib/asserts/date/index.js +8 -6
- package/lib/asserts/date/index.js.map +1 -1
- package/lib/asserts/date/index.mjs +7 -5
- package/lib/asserts/date/index.mjs.map +1 -1
- package/lib/asserts/mix/equalTo.js +4 -4
- package/lib/asserts/mix/equalTo.mjs +3 -3
- package/lib/asserts/mix/index.d.mts +5 -4
- package/lib/asserts/mix/index.d.ts +5 -4
- package/lib/asserts/mix/index.js +7 -5
- package/lib/asserts/mix/index.js.map +1 -1
- package/lib/asserts/mix/index.mjs +6 -4
- package/lib/asserts/mix/index.mjs.map +1 -1
- package/lib/asserts/mix/oneOfValues.js +4 -4
- package/lib/asserts/mix/oneOfValues.mjs +3 -3
- package/lib/asserts/number/index.d.mts +4 -3
- package/lib/asserts/number/index.d.ts +4 -3
- package/lib/asserts/number/index.js +11 -10
- package/lib/asserts/number/index.js.map +1 -1
- package/lib/asserts/number/index.mjs +10 -9
- package/lib/asserts/number/index.mjs.map +1 -1
- package/lib/asserts/number/max.js +4 -4
- package/lib/asserts/number/max.mjs +2 -2
- package/lib/asserts/number/maxExcluded.js +4 -4
- package/lib/asserts/number/maxExcluded.mjs +2 -2
- package/lib/asserts/number/min.js +4 -4
- package/lib/asserts/number/min.mjs +2 -2
- package/lib/asserts/number/minExcluded.js +4 -4
- package/lib/asserts/number/minExcluded.mjs +2 -2
- package/lib/asserts/number/negative.js +4 -4
- package/lib/asserts/number/negative.mjs +2 -2
- package/lib/asserts/number/positive.js +4 -4
- package/lib/asserts/number/positive.mjs +2 -2
- package/lib/asserts/object/index.d.mts +6 -5
- package/lib/asserts/object/index.d.ts +6 -5
- package/lib/asserts/object/index.js +8 -6
- package/lib/asserts/object/index.js.map +1 -1
- package/lib/asserts/object/index.mjs +7 -5
- package/lib/asserts/object/index.mjs.map +1 -1
- package/lib/asserts/object/maxKeys.d.mts +30 -0
- package/lib/asserts/object/maxKeys.d.ts +30 -0
- package/lib/asserts/object/maxKeys.js +23 -0
- package/lib/asserts/object/maxKeys.js.map +1 -0
- package/lib/asserts/object/maxKeys.mjs +23 -0
- package/lib/asserts/object/maxKeys.mjs.map +1 -0
- package/lib/asserts/string/atLeastOneDigit.js +4 -4
- package/lib/asserts/string/atLeastOneDigit.mjs +2 -2
- package/lib/asserts/string/atLeastOneLowerChar.js +4 -4
- package/lib/asserts/string/atLeastOneLowerChar.mjs +2 -2
- package/lib/asserts/string/atLeastOneSpecialChar.js +4 -4
- package/lib/asserts/string/atLeastOneSpecialChar.mjs +2 -2
- package/lib/asserts/string/atLeastOneUpperChar.js +4 -4
- package/lib/asserts/string/atLeastOneUpperChar.mjs +2 -2
- package/lib/asserts/string/contains.js +4 -4
- package/lib/asserts/string/contains.mjs +2 -2
- package/lib/asserts/string/email.js +4 -4
- package/lib/asserts/string/email.mjs +2 -2
- package/lib/asserts/string/endsWith.js +4 -4
- package/lib/asserts/string/endsWith.mjs +2 -2
- package/lib/asserts/string/index.d.mts +5 -4
- package/lib/asserts/string/index.d.ts +5 -4
- package/lib/asserts/string/index.js +11 -10
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +10 -9
- package/lib/asserts/string/index.mjs.map +1 -1
- package/lib/asserts/string/isValidDate.d.mts +21 -0
- package/lib/asserts/string/isValidDate.d.ts +21 -0
- package/lib/asserts/string/isValidDate.js +25 -0
- package/lib/asserts/string/isValidDate.js.map +1 -0
- package/lib/asserts/string/isValidDate.mjs +25 -0
- package/lib/asserts/string/isValidDate.mjs.map +1 -0
- package/lib/asserts/string/isValidDateTime.d.mts +35 -0
- package/lib/asserts/string/isValidDateTime.d.ts +35 -0
- package/lib/asserts/string/isValidDateTime.js +32 -0
- package/lib/asserts/string/isValidDateTime.js.map +1 -0
- package/lib/asserts/string/isValidDateTime.mjs +32 -0
- package/lib/asserts/string/isValidDateTime.mjs.map +1 -0
- package/lib/asserts/string/isValidTime.d.mts +29 -0
- package/lib/asserts/string/isValidTime.d.ts +29 -0
- package/lib/asserts/string/isValidTime.js +32 -0
- package/lib/asserts/string/isValidTime.js.map +1 -0
- package/lib/asserts/string/isValidTime.mjs +32 -0
- package/lib/asserts/string/isValidTime.mjs.map +1 -0
- package/lib/asserts/string/lowerCase.js +4 -4
- package/lib/asserts/string/lowerCase.mjs +2 -2
- package/lib/asserts/string/maxLength.js +4 -4
- package/lib/asserts/string/maxLength.mjs +2 -2
- package/lib/asserts/string/minLength.js +4 -4
- package/lib/asserts/string/minLength.mjs +2 -2
- package/lib/asserts/string/regExp.js +4 -4
- package/lib/asserts/string/regExp.mjs +2 -2
- package/lib/asserts/string/startsWith.js +4 -4
- package/lib/asserts/string/startsWith.mjs +2 -2
- package/lib/asserts/string/upperCase.js +4 -4
- package/lib/asserts/string/upperCase.mjs +2 -2
- package/lib/asserts/string/uuid.js +4 -4
- package/lib/asserts/string/uuid.mjs +2 -2
- package/lib/asserts/string/uuidV1.js +4 -4
- package/lib/asserts/string/uuidV1.mjs +2 -2
- package/lib/asserts/string/uuidV2.js +4 -4
- package/lib/asserts/string/uuidV2.mjs +2 -2
- package/lib/asserts/string/uuidV3.js +4 -4
- package/lib/asserts/string/uuidV3.mjs +2 -2
- package/lib/asserts/string/uuidV4.js +4 -4
- package/lib/asserts/string/uuidV4.mjs +2 -2
- package/lib/asserts/string/uuidV5.js +4 -4
- package/lib/asserts/string/uuidV5.mjs +2 -2
- package/lib/asserts/string/validUrl.js +4 -4
- package/lib/asserts/string/validUrl.mjs +2 -2
- package/lib/{chunk-QLVLZRHT.js → chunk-2KQASECD.js} +5 -5
- package/lib/chunk-2KQASECD.js.map +1 -0
- package/lib/{chunk-WK4O3HH4.js → chunk-5P6AZJCN.js} +6 -5
- package/lib/chunk-5P6AZJCN.js.map +1 -0
- package/lib/{chunk-VGF3Y2EK.js → chunk-5WHCMWXK.js} +12 -9
- package/lib/chunk-5WHCMWXK.js.map +1 -0
- package/lib/{chunk-CQWI6YRI.js → chunk-5YYRBKDP.js} +4 -4
- package/lib/{chunk-CQWI6YRI.js.map → chunk-5YYRBKDP.js.map} +1 -1
- package/lib/{chunk-PJI3DRGP.mjs → chunk-6D5W7SSQ.mjs} +4 -4
- package/lib/chunk-6D5W7SSQ.mjs.map +1 -0
- package/lib/chunk-7NBOVYSP.mjs +136 -0
- package/lib/chunk-7NBOVYSP.mjs.map +1 -0
- package/lib/{chunk-XZTZC73V.mjs → chunk-BNCT7NOR.mjs} +36 -14
- package/lib/chunk-BNCT7NOR.mjs.map +1 -0
- package/lib/{chunk-M6OCVAUD.mjs → chunk-C3EDEQ3W.mjs} +3 -3
- package/lib/{chunk-Z7OEFOAD.mjs → chunk-CHUPE6SJ.mjs} +8 -8
- package/lib/chunk-CHUPE6SJ.mjs.map +1 -0
- package/lib/{chunk-4SR7J2I4.js → chunk-ECBOZ3BM.js} +8 -8
- package/lib/chunk-ECBOZ3BM.js.map +1 -0
- package/lib/{chunk-7XFLH6R2.mjs → chunk-FGZKNBDP.mjs} +6 -5
- package/lib/chunk-FGZKNBDP.mjs.map +1 -0
- package/lib/{chunk-TP5I237J.mjs → chunk-FP5QAEVQ.mjs} +14 -12
- package/lib/chunk-FP5QAEVQ.mjs.map +1 -0
- package/lib/{chunk-MTJJKWTP.js → chunk-G55SHHAR.js} +10 -8
- package/lib/chunk-G55SHHAR.js.map +1 -0
- package/lib/{chunk-QV4JDW3T.mjs → chunk-H32B3NHW.mjs} +2 -2
- package/lib/{chunk-54RHVQFA.mjs → chunk-H6LHV3EA.mjs} +2 -2
- package/lib/{chunk-WPHJ4QTB.js → chunk-HP3DRZWK.js} +5 -5
- package/lib/{chunk-WPHJ4QTB.js.map → chunk-HP3DRZWK.js.map} +1 -1
- package/lib/{chunk-4SPM2CSQ.js → chunk-IZ3CBVEE.js} +5 -5
- package/lib/{chunk-4SPM2CSQ.js.map → chunk-IZ3CBVEE.js.map} +1 -1
- package/lib/{chunk-YPAUFM3S.mjs → chunk-K7X6DVM2.mjs} +3 -3
- package/lib/{chunk-PEWNA24X.mjs → chunk-LPR3G5T3.mjs} +4 -4
- package/lib/chunk-LPR3G5T3.mjs.map +1 -0
- package/lib/{chunk-XFR7Y4XX.mjs → chunk-MHBY5OIQ.mjs} +3 -3
- package/lib/chunk-MHBY5OIQ.mjs.map +1 -0
- package/lib/{chunk-5EIBKBYS.js → chunk-MLNQZ445.js} +13 -13
- package/lib/chunk-MLNQZ445.js.map +1 -0
- package/lib/chunk-QIDWASOC.js +14 -0
- package/lib/{chunk-LWAEUS2F.js.map → chunk-QIDWASOC.js.map} +1 -1
- package/lib/chunk-SHJVKSEZ.js +136 -0
- package/lib/chunk-SHJVKSEZ.js.map +1 -0
- package/lib/{chunk-MRWZVTNH.mjs → chunk-TRGMD7LA.mjs} +7 -5
- package/lib/chunk-TRGMD7LA.mjs.map +1 -0
- package/lib/{chunk-5AO66YV5.mjs → chunk-TV5IZY4L.mjs} +9 -6
- package/lib/chunk-TV5IZY4L.mjs.map +1 -0
- package/lib/{chunk-N6YMNLXG.js → chunk-U4USIJV3.js} +11 -11
- package/lib/chunk-U4USIJV3.js.map +1 -0
- package/lib/{chunk-SEIKS6G7.js → chunk-UUY7DPHK.js} +19 -15
- package/lib/chunk-UUY7DPHK.js.map +1 -0
- package/lib/{chunk-356HMXOP.js → chunk-VBTWYDEM.js} +4 -4
- package/lib/chunk-VBTWYDEM.js.map +1 -0
- package/lib/chunk-VW4RMQD4.js +28 -0
- package/lib/chunk-VW4RMQD4.js.map +1 -0
- package/lib/{chunk-UV4I7JZR.mjs → chunk-WK4FJ5GD.mjs} +16 -12
- package/lib/chunk-WK4FJ5GD.mjs.map +1 -0
- package/lib/chunk-X762EUSZ.js +91 -0
- package/lib/chunk-X762EUSZ.js.map +1 -0
- package/lib/{chunk-GDSB7CDN.mjs → chunk-YBVMP4EI.mjs} +4 -4
- package/lib/chunk-YBVMP4EI.mjs.map +1 -0
- package/lib/{chunk-PVOHKGBW.mjs → chunk-YUMUCQKL.mjs} +4 -4
- package/lib/chunk-YUMUCQKL.mjs.map +1 -0
- package/lib/{chunk-32J4WVLE.js → chunk-Z6QU36MM.js} +17 -15
- package/lib/chunk-Z6QU36MM.js.map +1 -0
- package/lib/codeGen.d.mts +2 -1
- package/lib/codeGen.d.ts +2 -1
- package/lib/codeGen.js +4 -4
- package/lib/codeGen.mjs +3 -3
- package/lib/commonTypes.d.mts +26 -2
- package/lib/commonTypes.d.ts +26 -2
- package/lib/exceptions.d.mts +3 -2
- package/lib/exceptions.d.ts +3 -2
- package/lib/exceptions.js +2 -2
- package/lib/exceptions.mjs +1 -1
- package/lib/helpers/core.d.mts +2 -1
- package/lib/helpers/core.d.ts +2 -1
- package/lib/helpers/core.js +4 -4
- package/lib/helpers/core.mjs +3 -3
- package/lib/helpers/isValidDateInner.d.mts +3 -0
- package/lib/helpers/isValidDateInner.d.ts +3 -0
- package/lib/helpers/isValidDateInner.js +7 -0
- package/lib/helpers/isValidDateInner.js.map +1 -0
- package/lib/helpers/isValidDateInner.mjs +7 -0
- package/lib/helpers/setStrictType.d.mts +2 -1
- package/lib/helpers/setStrictType.d.ts +2 -1
- package/lib/helpers/setStrictType.js +5 -5
- package/lib/helpers/setStrictType.mjs +4 -4
- package/lib/index.d.mts +1 -8
- package/lib/index.d.ts +1 -8
- package/lib/index.js +7 -7
- package/lib/index.mjs +6 -6
- package/lib/parse.d.mts +1 -8
- package/lib/parse.d.ts +1 -8
- package/lib/parse.js +6 -6
- package/lib/parse.mjs +5 -5
- package/lib/parseOrFail.d.mts +1 -8
- package/lib/parseOrFail.d.ts +1 -8
- package/lib/parseOrFail.js +6 -6
- package/lib/parseOrFail.mjs +5 -5
- package/lib/schemas/ArraySchema.d.mts +4 -7
- package/lib/schemas/ArraySchema.d.ts +4 -7
- package/lib/schemas/ArraySchema.js +8 -6
- package/lib/schemas/ArraySchema.js.map +1 -1
- package/lib/schemas/ArraySchema.mjs +7 -5
- package/lib/schemas/BigIntSchema.d.mts +8 -10
- package/lib/schemas/BigIntSchema.d.ts +8 -10
- package/lib/schemas/BigIntSchema.js +11 -10
- package/lib/schemas/BigIntSchema.js.map +1 -1
- package/lib/schemas/BigIntSchema.mjs +10 -9
- package/lib/schemas/BooleanSchema.d.mts +7 -10
- package/lib/schemas/BooleanSchema.d.ts +7 -10
- package/lib/schemas/BooleanSchema.js +9 -7
- package/lib/schemas/BooleanSchema.js.map +1 -1
- package/lib/schemas/BooleanSchema.mjs +8 -6
- package/lib/schemas/CommonSchema.d.mts +2 -1
- package/lib/schemas/CommonSchema.d.ts +2 -1
- package/lib/schemas/CommonSchema.js +7 -5
- package/lib/schemas/CommonSchema.js.map +1 -1
- package/lib/schemas/CommonSchema.mjs +6 -4
- package/lib/schemas/DateSchema.d.mts +3 -2
- package/lib/schemas/DateSchema.d.ts +3 -2
- package/lib/schemas/DateSchema.js +8 -6
- package/lib/schemas/DateSchema.js.map +1 -1
- package/lib/schemas/DateSchema.mjs +7 -5
- package/lib/schemas/NumberSchema.d.mts +7 -10
- package/lib/schemas/NumberSchema.d.ts +7 -10
- package/lib/schemas/NumberSchema.js +11 -10
- package/lib/schemas/NumberSchema.js.map +1 -1
- package/lib/schemas/NumberSchema.mjs +10 -9
- package/lib/schemas/ObjectSchema.d.mts +4 -6
- package/lib/schemas/ObjectSchema.d.ts +4 -6
- package/lib/schemas/ObjectSchema.js +8 -6
- package/lib/schemas/ObjectSchema.js.map +1 -1
- package/lib/schemas/ObjectSchema.mjs +7 -5
- package/lib/schemas/StringSchema.d.mts +8 -10
- package/lib/schemas/StringSchema.d.ts +8 -10
- package/lib/schemas/StringSchema.js +11 -10
- package/lib/schemas/StringSchema.js.map +1 -1
- package/lib/schemas/StringSchema.mjs +10 -9
- package/lib/translationMap.js +3 -3
- package/lib/translationMap.mjs +2 -2
- package/package.json +1 -1
- package/lib/CommonSchema-9RtxTxdX.d.ts +0 -63
- package/lib/CommonSchema-DJmQ3F_9.d.mts +0 -63
- package/lib/chunk-2OINKFOA.js +0 -28
- package/lib/chunk-2OINKFOA.js.map +0 -1
- package/lib/chunk-32J4WVLE.js.map +0 -1
- package/lib/chunk-356HMXOP.js.map +0 -1
- package/lib/chunk-4SR7J2I4.js.map +0 -1
- package/lib/chunk-4UF67IQ2.mjs +0 -42
- package/lib/chunk-4UF67IQ2.mjs.map +0 -1
- package/lib/chunk-5AO66YV5.mjs.map +0 -1
- package/lib/chunk-5EIBKBYS.js.map +0 -1
- package/lib/chunk-7GIRQ5EA.js +0 -69
- package/lib/chunk-7GIRQ5EA.js.map +0 -1
- package/lib/chunk-7XFLH6R2.mjs.map +0 -1
- package/lib/chunk-EQNVYAKS.js +0 -42
- package/lib/chunk-EQNVYAKS.js.map +0 -1
- package/lib/chunk-GDSB7CDN.mjs.map +0 -1
- package/lib/chunk-LWAEUS2F.js +0 -14
- package/lib/chunk-MRWZVTNH.mjs.map +0 -1
- package/lib/chunk-MTJJKWTP.js.map +0 -1
- package/lib/chunk-N6YMNLXG.js.map +0 -1
- package/lib/chunk-PEWNA24X.mjs.map +0 -1
- package/lib/chunk-PJI3DRGP.mjs.map +0 -1
- package/lib/chunk-PVOHKGBW.mjs.map +0 -1
- package/lib/chunk-QLVLZRHT.js.map +0 -1
- package/lib/chunk-SEIKS6G7.js.map +0 -1
- package/lib/chunk-TP5I237J.mjs.map +0 -1
- package/lib/chunk-UV4I7JZR.mjs.map +0 -1
- package/lib/chunk-VGF3Y2EK.js.map +0 -1
- package/lib/chunk-WK4O3HH4.js.map +0 -1
- package/lib/chunk-XFR7Y4XX.mjs.map +0 -1
- package/lib/chunk-XZTZC73V.mjs.map +0 -1
- package/lib/chunk-Z7OEFOAD.mjs.map +0 -1
- package/lib/helpers/isValidDate.d.mts +0 -3
- package/lib/helpers/isValidDate.d.ts +0 -3
- package/lib/helpers/isValidDate.js +0 -7
- package/lib/helpers/isValidDate.js.map +0 -1
- package/lib/helpers/isValidDate.mjs +0 -7
- /package/lib/{chunk-M6OCVAUD.mjs.map → chunk-C3EDEQ3W.mjs.map} +0 -0
- /package/lib/{chunk-QV4JDW3T.mjs.map → chunk-H32B3NHW.mjs.map} +0 -0
- /package/lib/{chunk-54RHVQFA.mjs.map → chunk-H6LHV3EA.mjs.map} +0 -0
- /package/lib/{chunk-YPAUFM3S.mjs.map → chunk-K7X6DVM2.mjs.map} +0 -0
- /package/lib/helpers/{isValidDate.mjs.map → isValidDateInner.mjs.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-IZ3CBVEE.js","../src/asserts/mix/oneOfValues.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACHA,IAAM,wBAAA,EAA0B,6CAAA;AAChC,IAAM,oBAAA,EAAsB,eAAA;AAgBrB,IAAM,YAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AAC5C,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,QAAA,CAAS,QAAQ,CAAA,EAAG,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,mBAAmB,CAAA;AAC/F,CAAA;AAEF,WAAA,CAAY,IAAA,EAAM,mBAAA;AAClB,WAAA,CAAY,QAAA,EAAU,uBAAA;AACtB,iDAAA,WAA8B,CAAA;ADb9B;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-IZ3CBVEE.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst oneOfValuesErrorMessage = 'The received value is not equal to expected';\nconst oneOfValuesErrorKey = 'm:oneOfValues';\n\n/**\n * @description Creates a custom assertion that checks if a value is equal to the one of expected values.\n * @notice It has already been implemented in the number, bigint and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match at least one of the expected values.\n * @example\n * const schema = number().custom(oneOfValues([5, 4])); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 4); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:oneOfValues'\n */\nexport const oneOfValues =\n (expected: unknown[]): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (!expected.includes(received)) guardException(expected, received, ctx, oneOfValuesErrorKey);\n };\n\noneOfValues.key = oneOfValuesErrorKey;\noneOfValues.message = oneOfValuesErrorMessage;\nsetToDefaultLocale(oneOfValues);\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
setToDefaultLocale
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-H32B3NHW.mjs";
|
|
4
4
|
import {
|
|
5
5
|
guardException
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FGZKNBDP.mjs";
|
|
7
7
|
|
|
8
8
|
// src/asserts/mix/oneOfValues.ts
|
|
9
9
|
var oneOfValuesErrorMessage = "The received value is not equal to expected";
|
|
@@ -18,4 +18,4 @@ setToDefaultLocale(oneOfValues);
|
|
|
18
18
|
export {
|
|
19
19
|
oneOfValues
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-K7X6DVM2.mjs.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CommonSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7NBOVYSP.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ctxSymbol
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BNCT7NOR.mjs";
|
|
7
7
|
import {
|
|
8
8
|
BuildSchemaError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-FGZKNBDP.mjs";
|
|
10
10
|
|
|
11
11
|
// src/schemas/ArraySchema.ts
|
|
12
12
|
var ArraySchema = class extends CommonSchema {
|
|
@@ -25,4 +25,4 @@ var ArraySchema = class extends CommonSchema {
|
|
|
25
25
|
export {
|
|
26
26
|
ArraySchema
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-LPR3G5T3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/ArraySchema.ts"],"sourcesContent":["import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class ArraySchema extends CommonSchema {\n protected _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"],"mappings":";;;;;;;;;;;AAIO,IAAM,cAAN,cAA0B,aAAa;AAAA,EAClC,SAAS;AAAA,EACnB,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":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CommonSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7NBOVYSP.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ctxSymbol
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BNCT7NOR.mjs";
|
|
7
7
|
|
|
8
8
|
// src/schemas/DateSchema.ts
|
|
9
9
|
var DateSchema = class extends CommonSchema {
|
|
@@ -17,4 +17,4 @@ var DateSchema = class extends CommonSchema {
|
|
|
17
17
|
export {
|
|
18
18
|
DateSchema
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
20
|
+
//# sourceMappingURL=chunk-MHBY5OIQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/DateSchema.ts"],"sourcesContent":["import { ctxSymbol } from '../helpers/core';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class DateSchema extends CommonSchema {\n protected _date = 1;\n\n constructor(ctx: ValidatorContext) {\n super(ctx);\n this[ctxSymbol].date = true;\n }\n}\n"],"mappings":";;;;;;;;AAGO,IAAM,aAAN,cAAyB,aAAa;AAAA,EACjC,QAAQ;AAAA,EAElB,YAAY,KAAuB;AACjC,UAAM,GAAG;AACT,SAAK,SAAS,EAAE,OAAO;AAAA,EACzB;AACF;","names":[]}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkHP3DRZWKjs = require('./chunk-HP3DRZWK.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkIZ3CBVEEjs = require('./chunk-IZ3CBVEE.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkQIDWASOCjs = require('./chunk-QIDWASOC.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkSHJVKSEZjs = require('./chunk-SHJVKSEZ.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
|
|
19
19
|
|
|
20
20
|
// src/schemas/NumberSchema.ts
|
|
21
|
-
var NumberSchema = (_class = class extends
|
|
21
|
+
var NumberSchema = (_class = class extends _chunkSHJVKSEZjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
22
22
|
__init() {this._number = 1}
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -30,10 +30,10 @@ var NumberSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constr
|
|
|
30
30
|
* @example - number().equalTo(42); // Infers the type 42
|
|
31
31
|
*/
|
|
32
32
|
equalTo(expectedValue) {
|
|
33
|
-
if (this.limit) throw new (0,
|
|
33
|
+
if (this.limit) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
34
34
|
this.limit = true;
|
|
35
|
-
|
|
36
|
-
return this.custom(
|
|
35
|
+
_chunkQIDWASOCjs._setStrictType.call(void 0, this, expectedValue);
|
|
36
|
+
return this.custom(_chunkHP3DRZWKjs.equalTo.call(void 0, expectedValue));
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
|
|
@@ -45,14 +45,14 @@ var NumberSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constr
|
|
|
45
45
|
* number().oneOfValues([5, 7]); // Infers the type 5 | 7
|
|
46
46
|
*/
|
|
47
47
|
oneOfValues(expectedValue) {
|
|
48
|
-
if (this.limit) throw new (0,
|
|
48
|
+
if (this.limit) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
49
49
|
this.limit = true;
|
|
50
|
-
|
|
51
|
-
return this.custom(
|
|
50
|
+
_chunkQIDWASOCjs._setStrictType.call(void 0, this, expectedValue);
|
|
51
|
+
return this.custom(_chunkIZ3CBVEEjs.oneOfValues.call(void 0, expectedValue));
|
|
52
52
|
}
|
|
53
53
|
}, _class);
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
exports.NumberSchema = NumberSchema;
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-MLNQZ445.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-MLNQZ445.js","../src/schemas/NumberSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACXO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBACnC,QAAA,EAAU,EAAA;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,OAAA,CAA0B,aAAA,EAA2C;AAC1E,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWO,WAAA,CAA8B,aAAA,EAA6C;AAChF,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADWA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-MLNQZ445.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { WithBGuardType } from '../commonTypes';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n protected _number = 1;\n private limit: boolean | undefined;\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 public equalTo<Y extends number>(expectedValue: Y): WithBGuardType<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n public oneOfValues<Y extends number>(expectedValue: Y[]): WithBGuardType<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithBGuardType<this, Y>;\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkX762EUSZjs = require('./chunk-X762EUSZ.js');
|
|
4
|
+
|
|
5
|
+
// src/helpers/setStrictType.ts
|
|
6
|
+
function _setStrictType(that, val) {
|
|
7
|
+
that[_chunkX762EUSZjs.ctxSymbol].strictType = true;
|
|
8
|
+
that[_chunkX762EUSZjs.ctxSymbol].strictTypeValue = val;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports._setStrictType = _setStrictType;
|
|
14
|
+
//# sourceMappingURL=chunk-QIDWASOC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-QIDWASOC.js","../src/helpers/setStrictType.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACDO,SAAS,cAAA,CAAe,IAAA,EAAoB,GAAA,EAAc;AAC/D,EAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,EAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,gBAAA,EAAkB,GAAA;AACpC;ADGA;AACA;AACE;AACF,wCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-QIDWASOC.js","sourcesContent":[null,"import { ctxSymbol } from './core';\nimport type { CommonSchema } from '../schemas/CommonSchema';\n\nexport function _setStrictType(that: CommonSchema, val: unknown) {\n that[ctxSymbol].strictType = true;\n that[ctxSymbol].strictTypeValue = val;\n}\n"]}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkG55SHHARjs = require('./chunk-G55SHHAR.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkX762EUSZjs = require('./chunk-X762EUSZ.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
|
|
10
|
+
|
|
11
|
+
// src/schemas/CommonSchema.ts
|
|
12
|
+
var CommonSchema = class {
|
|
13
|
+
|
|
14
|
+
constructor(ctx) {
|
|
15
|
+
this[_chunkX762EUSZjs.ctxSymbol] = ctx;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @param validators - One or more custom validation functions.
|
|
19
|
+
* @returns {this} The schema instance with the added custom validation.
|
|
20
|
+
*/
|
|
21
|
+
custom(...validators) {
|
|
22
|
+
this.defaultValueCheck();
|
|
23
|
+
this[_chunkX762EUSZjs.ctxSymbol].requiredValidations.push(...validators);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Marks the schema as nullable, allowing the value to be `null`.
|
|
28
|
+
*
|
|
29
|
+
* @returns {WithNull<this>} The schema instance marked as nullable.
|
|
30
|
+
*/
|
|
31
|
+
nullable() {
|
|
32
|
+
this.defaultValueCheck();
|
|
33
|
+
this[_chunkX762EUSZjs.ctxSymbol].isNullable = true;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Marks the schema as optional, allowing the value to be `undefined`.
|
|
38
|
+
*
|
|
39
|
+
* @returns {WithUndefined<this>} The schema instance marked as optional.
|
|
40
|
+
*/
|
|
41
|
+
optional() {
|
|
42
|
+
this.defaultValueCheck();
|
|
43
|
+
this[_chunkX762EUSZjs.ctxSymbol].isOptional = true;
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Marks the schema as optional, allowing the value to be `undefined`.
|
|
48
|
+
*
|
|
49
|
+
* @returns {this} The schema instance. This method should be used as a last one because it does the check of previous methods and
|
|
50
|
+
*/
|
|
51
|
+
default(defaultValue) {
|
|
52
|
+
const ctx = this[_chunkX762EUSZjs.ctxSymbol];
|
|
53
|
+
if (ctx.isOptional) {
|
|
54
|
+
throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(`Cannot call method 'default' after method 'optional'`);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
_chunkG55SHHARjs.parseOrFail.call(void 0, this, defaultValue);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(e.message);
|
|
60
|
+
}
|
|
61
|
+
this[_chunkX762EUSZjs.ctxSymbol].defaultValue = defaultValue;
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Applies a transformation to the input value before any validation occurs.
|
|
66
|
+
* The transformation should return a value of the same type as the inferred type of the schema,
|
|
67
|
+
* ensuring that the overall type is not altered.
|
|
68
|
+
*
|
|
69
|
+
* @template In - The type of the input value before transformation (defaults to `unknown`).
|
|
70
|
+
* @param {TransformCallback<In, InferType<this>>} cb - The callback function that performs the transformation.
|
|
71
|
+
* @returns {this} The updated schema with the applied transformation.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* const schema = string()
|
|
75
|
+
* .nullable()
|
|
76
|
+
* .transformBeforeValidation((val) => val + '') // Ensure the value is a string
|
|
77
|
+
* .transformBeforeValidation((val: string) => (val === '' ? null : val)); // Convert empty strings to null
|
|
78
|
+
*
|
|
79
|
+
* // Parse 'test' will pass as 'test' is a valid string longer than 3 characters.
|
|
80
|
+
* parseOrFail(schema, 'test');
|
|
81
|
+
*
|
|
82
|
+
* // Parsing '' will be transformed to null and will pass due to .nullable().
|
|
83
|
+
* parseOrFail(schema, '');
|
|
84
|
+
*/
|
|
85
|
+
transformBeforeValidation(cb) {
|
|
86
|
+
const ctx = this[_chunkX762EUSZjs.ctxSymbol];
|
|
87
|
+
if (ctx.transformListBefore) {
|
|
88
|
+
ctx.transformListBefore.push(cb);
|
|
89
|
+
} else {
|
|
90
|
+
ctx.transformListBefore = [cb];
|
|
91
|
+
}
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Assigns a unique identifier to the schema.
|
|
96
|
+
* This ID can be used to track or map validation errors back to specific fields
|
|
97
|
+
* in a form or other structures.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} value - The unique identifier for the schema.
|
|
100
|
+
* @returns {this} The updated schema with the assigned ID.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* const schema = string().id('username');
|
|
104
|
+
*/
|
|
105
|
+
id(value) {
|
|
106
|
+
return this.meta("id", value);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Provides a description for the schema, offering additional context or information.
|
|
110
|
+
* The description can be used when displaying validation errors or for documentation purposes.
|
|
111
|
+
*
|
|
112
|
+
* @param {string} value - The description for the schema.
|
|
113
|
+
* @returns {this} The updated schema with the added description.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const schema = string().description('The username of the account holder.');
|
|
117
|
+
*/
|
|
118
|
+
description(value) {
|
|
119
|
+
return this.meta("description", value);
|
|
120
|
+
}
|
|
121
|
+
meta(key, value) {
|
|
122
|
+
const ctx = this[_chunkX762EUSZjs.ctxSymbol];
|
|
123
|
+
ctx.meta = { ...ctx.meta, [key]: value };
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
defaultValueCheck() {
|
|
127
|
+
if (this[_chunkX762EUSZjs.ctxSymbol].defaultValue !== void 0) {
|
|
128
|
+
throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)("Default value must be the last method called in schema");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
exports.CommonSchema = CommonSchema;
|
|
136
|
+
//# sourceMappingURL=chunk-SHJVKSEZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-SHJVKSEZ.js","../src/schemas/CommonSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACeO,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,EAMO,MAAA,CAAA,GAAU,UAAA,EAAwC;AACvD,IAAA,IAAA,CAAK,iBAAA,CAAkB,CAAA;AACvB,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,EAOO,QAAA,CAAA,EAA2B;AAChC,IAAA,IAAA,CAAK,iBAAA,CAAkB,CAAA;AACvB,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,QAAA,CAAA,EAAgC;AACrC,IAAA,IAAA,CAAK,iBAAA,CAAkB,CAAA;AACvB,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,OAAA,CAAQ,YAAA,EAAqC;AAClD,IAAA,MAAM,IAAA,EAAM,IAAA,CAAK,0BAAS,CAAA;AAC1B,IAAA,GAAA,CAAI,GAAA,CAAI,UAAA,EAAY;AAClB,MAAA,MAAM,IAAI,sCAAA,CAAiB,CAAA,oDAAA,CAAsD,CAAA;AAAA,IACnF;AAEA,IAAA,IAAI;AACF,MAAA,0CAAA,IAAY,EAAM,YAAY,CAAA;AAAA,IAChC,EAAA,MAAA,CAAS,CAAA,EAAG;AACV,MAAA,MAAM,IAAI,sCAAA,CAAkB,CAAA,CAAY,OAAO,CAAA;AAAA,IACjD;AAEA,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,aAAA,EAAe,YAAA;AAC/B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBO,yBAAA,CAA8B,EAAA,EAAkD;AACrF,IAAA,MAAM,IAAA,EAAM,IAAA,CAAK,0BAAS,CAAA;AAC1B,IAAA,GAAA,CAAI,GAAA,CAAI,mBAAA,EAAqB;AAC3B,MAAA,GAAA,CAAI,mBAAA,CAAoB,IAAA,CAAK,EAAE,CAAA;AAAA,IACjC,EAAA,KAAO;AACL,MAAA,GAAA,CAAI,oBAAA,EAAsB,CAAC,EAAE,CAAA;AAAA,IAC/B;AAEA,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaO,EAAA,CAAG,KAAA,EAAqB;AAC7B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,EAAM,KAAK,CAAA;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYO,WAAA,CAAY,KAAA,EAAqB;AACtC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,aAAA,EAAe,KAAK,CAAA;AAAA,EACvC;AAAA,EAEQ,IAAA,CAAK,GAAA,EAAa,KAAA,EAAqB;AAC7C,IAAA,MAAM,IAAA,EAAM,IAAA,CAAK,0BAAS,CAAA;AAC1B,IAAA,GAAA,CAAI,KAAA,EAAO,EAAE,GAAG,GAAA,CAAI,IAAA,EAAM,CAAC,GAAG,CAAA,EAAG,MAAM,CAAA;AACvC,IAAA,OAAO,IAAA;AAAA,EACT;AAAA,EAEU,iBAAA,CAAA,EAAoB;AAC5B,IAAA,GAAA,CAAI,IAAA,CAAK,0BAAS,CAAA,CAAE,aAAA,IAAiB,KAAA,CAAA,EAAW;AAC9C,MAAA,MAAM,IAAI,sCAAA,CAAiB,wDAAwD,CAAA;AAAA,IACrF;AAAA,EACF;AACF,CAAA;ADzBA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-SHJVKSEZ.js","sourcesContent":[null,"import { InferType } from '../InferType';\nimport { MetaContext, BaseType, RequiredValidation, WithNull, WithUndefined, TransformCallback } from '../commonTypes';\nimport { BuildSchemaError } from '../exceptions';\nimport { ctxSymbol } from '../helpers/core';\nimport { parseOrFail } from '../parseOrFail';\n\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport interface ValidatorContext {\n type: BaseType[];\n isNullable?: boolean;\n isOptional?: boolean;\n requiredValidations: RequiredValidation[];\n array?: CommonSchema;\n object?: ObjectShapeSchemaType;\n allowUnrecognizedObjectProps?: boolean;\n strictType?: boolean;\n strictTypeValue?: unknown;\n date?: boolean;\n defaultValue?: unknown;\n meta?: MetaContext;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformListBefore?: TransformCallback<any, any>[];\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 public custom(...validators: RequiredValidation[]): this {\n this.defaultValueCheck();\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 public nullable(): WithNull<this> {\n this.defaultValueCheck();\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 public optional(): WithUndefined<this> {\n this.defaultValueCheck();\n this[ctxSymbol].isOptional = true;\n return this as WithUndefined<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {this} The schema instance. This method should be used as a last one because it does the check of previous methods and\n */\n public default(defaultValue: InferType<this>): this {\n const ctx = this[ctxSymbol];\n if (ctx.isOptional) {\n throw new BuildSchemaError(`Cannot call method 'default' after method 'optional'`);\n }\n\n try {\n parseOrFail(this, defaultValue);\n } catch (e) {\n throw new BuildSchemaError((e as Error).message);\n }\n\n this[ctxSymbol].defaultValue = defaultValue;\n return this;\n }\n\n /**\n * Applies a transformation to the input value before any validation occurs.\n * The transformation should return a value of the same type as the inferred type of the schema,\n * ensuring that the overall type is not altered.\n *\n * @template In - The type of the input value before transformation (defaults to `unknown`).\n * @param {TransformCallback<In, InferType<this>>} cb - The callback function that performs the transformation.\n * @returns {this} The updated schema with the applied transformation.\n *\n * @example\n * const schema = string()\n * .nullable()\n * .transformBeforeValidation((val) => val + '') // Ensure the value is a string\n * .transformBeforeValidation((val: string) => (val === '' ? null : val)); // Convert empty strings to null\n *\n * // Parse 'test' will pass as 'test' is a valid string longer than 3 characters.\n * parseOrFail(schema, 'test');\n *\n * // Parsing '' will be transformed to null and will pass due to .nullable().\n * parseOrFail(schema, '');\n */\n public transformBeforeValidation<In>(cb: TransformCallback<In, InferType<this>>): this {\n const ctx = this[ctxSymbol];\n if (ctx.transformListBefore) {\n ctx.transformListBefore.push(cb);\n } else {\n ctx.transformListBefore = [cb];\n }\n\n return this;\n }\n\n /**\n * Assigns a unique identifier to the schema.\n * This ID can be used to track or map validation errors back to specific fields\n * in a form or other structures.\n *\n * @param {string} value - The unique identifier for the schema.\n * @returns {this} The updated schema with the assigned ID.\n *\n * @example\n * const schema = string().id('username');\n */\n public id(value: string): this {\n return this.meta('id', value);\n }\n\n /**\n * Provides a description for the schema, offering additional context or information.\n * The description can be used when displaying validation errors or for documentation purposes.\n *\n * @param {string} value - The description for the schema.\n * @returns {this} The updated schema with the added description.\n *\n * @example\n * const schema = string().description('The username of the account holder.');\n */\n public description(value: string): this {\n return this.meta('description', value);\n }\n\n private meta(key: string, value: string): this {\n const ctx = this[ctxSymbol];\n ctx.meta = { ...ctx.meta, [key]: value };\n return this;\n }\n\n protected defaultValueCheck() {\n if (this[ctxSymbol].defaultValue !== undefined) {\n throw new BuildSchemaError('Default value must be the last method called in schema');\n }\n }\n}\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 MapMixTypes<T extends BaseType[]> = T extends (infer U)[]\n ? U extends keyof TypeMapping\n ? TypeMapping[U]\n : never\n : never;\n"]}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ctxSymbol,
|
|
2
3
|
innerCheck
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BNCT7NOR.mjs";
|
|
4
5
|
import {
|
|
5
6
|
getTranslationByLocale
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-H32B3NHW.mjs";
|
|
7
8
|
import {
|
|
8
9
|
ValidationError
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-FGZKNBDP.mjs";
|
|
10
11
|
|
|
11
12
|
// src/parseOrFail.ts
|
|
12
13
|
function parseOrFail(schema, receivedValue, options) {
|
|
13
14
|
try {
|
|
14
15
|
return innerCheck(schema, receivedValue, {
|
|
15
16
|
t: getTranslationByLocale(options?.lng),
|
|
16
|
-
pathToError: ""
|
|
17
|
+
pathToError: "",
|
|
18
|
+
meta: schema[ctxSymbol].meta
|
|
17
19
|
});
|
|
18
20
|
} catch (e) {
|
|
19
21
|
if (e instanceof ValidationError) throw e;
|
|
@@ -24,4 +26,4 @@ function parseOrFail(schema, receivedValue, options) {
|
|
|
24
26
|
export {
|
|
25
27
|
parseOrFail
|
|
26
28
|
};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-TRGMD7LA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/parseOrFail.ts"],"sourcesContent":["import type { InferType } from './InferType';\nimport type { CommonSchema } from './schemas/CommonSchema';\nimport { ctxSymbol, innerCheck } from './helpers/core';\nimport { getTranslationByLocale } from './translationMap';\nimport { ValidationError } from './exceptions';\ninterface ParseOptions {\n /**\n * Set language keyword to map error messages.\n * @default 'default'\n * @example 'sr' or 'Serbia' or any string to identify language\n */\n lng?: string;\n}\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 * @param {ParseOptions} options - Options\n * @param {ParseOptions.lng} options.lng - Set language keyword to map Error message\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 = parseOrFail(schema, { name: 'Alice', age: 30 });\n * // result will be inferred as { name: string; age: number }\n *\n * parseOrFail(schema, { name: 'Alice', age: '30' });\n * // Throws ValidationError because 'age' should be a number, not a string.\n */\nexport function parseOrFail<T extends CommonSchema>(\n schema: T,\n receivedValue: unknown,\n options?: ParseOptions,\n): InferType<T> {\n try {\n return innerCheck(schema, receivedValue, {\n t: getTranslationByLocale(options?.lng),\n pathToError: '',\n meta: schema[ctxSymbol].meta,\n }) 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":";;;;;;;;;;;;AA0CO,SAAS,YACd,QACA,eACA,SACc;AACd,MAAI;AACF,WAAO,WAAW,QAAQ,eAAe;AAAA,MACvC,GAAG,uBAAuB,SAAS,GAAG;AAAA,MACtC,aAAa;AAAA,MACb,MAAM,OAAO,SAAS,EAAE;AAAA,IAC1B,CAAC;AAAA,EACH,SAAS,GAAG;AACV,QAAI,aAAa,gBAAiB,OAAM;AAExC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AACF;","names":[]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ctxSymbol,
|
|
2
3
|
innerCheck
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BNCT7NOR.mjs";
|
|
4
5
|
import {
|
|
5
6
|
getTranslationByLocale
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-H32B3NHW.mjs";
|
|
7
8
|
import {
|
|
8
9
|
ValidationError
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-FGZKNBDP.mjs";
|
|
10
11
|
|
|
11
12
|
// src/parse.ts
|
|
12
13
|
function parse(schema, receivedValue, options) {
|
|
@@ -15,7 +16,8 @@ function parse(schema, receivedValue, options) {
|
|
|
15
16
|
t: getTranslationByLocale(options?.lng),
|
|
16
17
|
pathToError: "",
|
|
17
18
|
getAllErrors: options?.getAllErrors,
|
|
18
|
-
errors: []
|
|
19
|
+
errors: [],
|
|
20
|
+
meta: schema[ctxSymbol].meta
|
|
19
21
|
};
|
|
20
22
|
const parsedValue = innerCheck(schema, receivedValue, ctx);
|
|
21
23
|
if (ctx.getAllErrors && ctx.errors.length) {
|
|
@@ -33,7 +35,8 @@ function parse(schema, receivedValue, options) {
|
|
|
33
35
|
message: "Something unexpected happened",
|
|
34
36
|
expected: "",
|
|
35
37
|
received: "",
|
|
36
|
-
pathToError: ""
|
|
38
|
+
pathToError: "",
|
|
39
|
+
meta: void 0
|
|
37
40
|
}
|
|
38
41
|
],
|
|
39
42
|
void 0
|
|
@@ -44,4 +47,4 @@ function parse(schema, receivedValue, options) {
|
|
|
44
47
|
export {
|
|
45
48
|
parse
|
|
46
49
|
};
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
50
|
+
//# sourceMappingURL=chunk-TV5IZY4L.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/parse.ts"],"sourcesContent":["import { InferType } from './InferType';\nimport { ctxSymbol, innerCheck } from './helpers/core';\nimport { getTranslationByLocale } from './translationMap';\nimport { ValidationError } from './exceptions';\nimport { CommonSchema } from './schemas/CommonSchema';\nimport { ExceptionContext, ValidationErrorData } from './commonTypes';\n\ninterface ParseOptions {\n /**\n * Set language keyword to map error messages.\n * @default 'default'\n * @example 'sr' or 'Serbia' or any string to identify language\n */\n lng?: string;\n\n /**\n * If true, collects all validation errors and returns them.\n * If false or undefined, returns the first validation error it can find and stops looking,\n * which provides a small runtime optimization.\n * @default undefined\n */\n getAllErrors?: boolean;\n}\n\n/**\n * Parses and validates a value against the provided schema, returning a type-safe parsedValue.\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 * @param {ParseOptions} options - Options\n * @param {ParseOptions.lng} options.lng - Set language keyword to map Error messages\n * @param {ParseOptions.lng} options.getAllErrors - If `false` or `undefined` - returns the first validation error it can find and stops looking, which provides a small runtime optimization.\n * @returns {[undefined, InferType<T>]} A tuple of [undefined, InferType<T>] if parsing is successful.\n * @returns {[ValidationErrorData[], undefined]} A tuple of [ValidationErrorData[], undefined]] if errors occur.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number(),\n * });\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: 30 });\n * // parsedValue will be inferred as { name: string; age: number }\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: '30' });\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // Array 'errors' returns only one element.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { getAllErrors: true});\n * // Returns array \"errors\" with multiple errors because 'age' should be a number and 'name' a string.\n * // With provided options { getAllErrors: true}, we can expecte more than one error in 'errors' array.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { lng: 'SR'});\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // With provided options { lng: 'SR'}, errors will be translated to a language mapped with keyword 'SR'\n */\nexport function parse<T extends CommonSchema>(\n schema: T,\n receivedValue: unknown,\n options?: ParseOptions,\n): [ValidationErrorData[], undefined] | [undefined, InferType<T>] {\n try {\n const ctx: ExceptionContext = {\n t: getTranslationByLocale(options?.lng),\n pathToError: '',\n getAllErrors: options?.getAllErrors,\n errors: [],\n meta: schema[ctxSymbol].meta,\n };\n\n const parsedValue = innerCheck(schema, receivedValue, ctx) as InferType<T>;\n\n if (ctx.getAllErrors && ctx.errors.length) {\n return [ctx.errors, undefined];\n }\n\n return [undefined, parsedValue];\n } catch (e) {\n if (e instanceof ValidationError) {\n delete e.stack;\n return [[e], undefined];\n }\n /* istanbul ignore next */\n return [\n [\n {\n message: 'Something unexpected happened',\n expected: '',\n received: '',\n pathToError: '',\n meta: undefined,\n },\n ],\n undefined,\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;AA+DO,SAAS,MACd,QACA,eACA,SACgE;AAChE,MAAI;AACF,UAAM,MAAwB;AAAA,MAC5B,GAAG,uBAAuB,SAAS,GAAG;AAAA,MACtC,aAAa;AAAA,MACb,cAAc,SAAS;AAAA,MACvB,QAAQ,CAAC;AAAA,MACT,MAAM,OAAO,SAAS,EAAE;AAAA,IAC1B;AAEA,UAAM,cAAc,WAAW,QAAQ,eAAe,GAAG;AAEzD,QAAI,IAAI,gBAAgB,IAAI,OAAO,QAAQ;AACzC,aAAO,CAAC,IAAI,QAAQ,MAAS;AAAA,IAC/B;AAEA,WAAO,CAAC,QAAW,WAAW;AAAA,EAChC,SAAS,GAAG;AACV,QAAI,aAAa,iBAAiB;AAChC,aAAO,EAAE;AACT,aAAO,CAAC,CAAC,CAAC,GAAG,MAAS;AAAA,IACxB;AAEA,WAAO;AAAA,MACL;AAAA,QACE;AAAA,UACE,SAAS;AAAA,UACT,UAAU;AAAA,UACV,UAAU;AAAA,UACV,aAAa;AAAA,UACb,MAAM;AAAA,QACR;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkSHJVKSEZjs = require('./chunk-SHJVKSEZ.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkX762EUSZjs = require('./chunk-X762EUSZ.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
|
|
10
10
|
|
|
11
11
|
// src/schemas/ObjectSchema.ts
|
|
12
|
-
var ObjectSchema = (_class = class extends
|
|
12
|
+
var ObjectSchema = (_class = class extends _chunkSHJVKSEZjs.CommonSchema {
|
|
13
13
|
__init() {this._object = 1}
|
|
14
14
|
constructor(ctx, shapeSchema) {
|
|
15
15
|
super(ctx);_class.prototype.__init.call(this);;
|
|
16
16
|
this.validateObjectEntry(shapeSchema);
|
|
17
|
-
this[
|
|
17
|
+
this[_chunkX762EUSZjs.ctxSymbol].object = shapeSchema;
|
|
18
18
|
}
|
|
19
19
|
validateObjectEntry(shapeSchema) {
|
|
20
|
-
if (!shapeSchema) throw new (0,
|
|
21
|
-
if (shapeSchema instanceof
|
|
20
|
+
if (!shapeSchema) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)("Missing schema in object method");
|
|
21
|
+
if (shapeSchema instanceof _chunkSHJVKSEZjs.CommonSchema) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)("Invalid schema in object");
|
|
22
22
|
for (const [key, value] of Object.entries(shapeSchema)) {
|
|
23
|
-
if (!(value instanceof
|
|
24
|
-
throw new (0,
|
|
23
|
+
if (!(value instanceof _chunkSHJVKSEZjs.CommonSchema))
|
|
24
|
+
throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(`Invalid schema in object method for property '${key}'`);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
@@ -42,7 +42,7 @@ var ObjectSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {
|
|
|
42
42
|
* // No error thrown
|
|
43
43
|
*/
|
|
44
44
|
allowUnrecognized() {
|
|
45
|
-
this[
|
|
45
|
+
this[_chunkX762EUSZjs.ctxSymbol].allowUnrecognizedObjectProps = true;
|
|
46
46
|
return this;
|
|
47
47
|
}
|
|
48
48
|
}, _class);
|
|
@@ -50,4 +50,4 @@ var ObjectSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
exports.ObjectSchema = ObjectSchema;
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-U4USIJV3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-U4USIJV3.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,iBACnC,QAAA,EAAU,EAAA;AAAA,EACpB,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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBO,iBAAA,CAAA,EAA0B;AAC/B,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,6BAAA,EAA+B,IAAA;AAC/C,IAAA,OAAO,IAAA;AAAA,EACT;AACF,UAAA;ADMA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-U4USIJV3.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ObjectShapeSchemaType, ValidatorContext } from './CommonSchema';\n\nexport class ObjectSchema extends CommonSchema {\n protected _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 /**\n * Allows unrecognized properties in the validated object.\n * When this method is called, the validation will not fail\n * if the received object contains properties not specified\n * in the validation schema.\n *\n * @returns {this} The current ObjectSchema instance.\n *\n * @example\n * const userSchema = object({\n * name: string(),\n * age: number(),\n * }).allowUnrecognized();\n *\n * parseOrFail(userSchema, ({ name: 'John', age: 30, extra: 'value' }););\n * // No error thrown\n */\n public allowUnrecognized(): this {\n this[ctxSymbol].allowUnrecognizedObjectProps = true;\n return this;\n }\n}\n"]}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkHP3DRZWKjs = require('./chunk-HP3DRZWK.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkIZ3CBVEEjs = require('./chunk-IZ3CBVEE.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkQIDWASOCjs = require('./chunk-QIDWASOC.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkSHJVKSEZjs = require('./chunk-SHJVKSEZ.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
|
|
19
19
|
|
|
20
20
|
// src/schemas/BigIntSchema.ts
|
|
21
|
-
var BigIntSchema = (_class = class extends
|
|
21
|
+
var BigIntSchema = (_class = class extends _chunkSHJVKSEZjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
22
22
|
__init() {this._bigint = 1}
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -30,10 +30,10 @@ var BigIntSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constr
|
|
|
30
30
|
* @example - bigint().equalTo(42n); // Infers the type 42n
|
|
31
31
|
*/
|
|
32
32
|
equalTo(expectedValue) {
|
|
33
|
-
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
return this.custom(
|
|
33
|
+
this.defaultValueCheck();
|
|
34
|
+
this.limitCheck();
|
|
35
|
+
_chunkQIDWASOCjs._setStrictType.call(void 0, this, `${expectedValue}n`);
|
|
36
|
+
return this.custom(_chunkHP3DRZWKjs.equalTo.call(void 0, expectedValue));
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
|
|
@@ -45,17 +45,21 @@ var BigIntSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constr
|
|
|
45
45
|
* bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n
|
|
46
46
|
*/
|
|
47
47
|
oneOfValues(expectedValue) {
|
|
48
|
-
|
|
49
|
-
this.
|
|
50
|
-
|
|
48
|
+
this.defaultValueCheck();
|
|
49
|
+
this.limitCheck();
|
|
50
|
+
_chunkQIDWASOCjs._setStrictType.call(void 0,
|
|
51
51
|
this,
|
|
52
52
|
expectedValue.map((el) => `${el}n`)
|
|
53
53
|
);
|
|
54
|
-
return this.custom(
|
|
54
|
+
return this.custom(_chunkIZ3CBVEEjs.oneOfValues.call(void 0, expectedValue));
|
|
55
|
+
}
|
|
56
|
+
limitCheck() {
|
|
57
|
+
if (this.limit) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
58
|
+
this.limit = true;
|
|
55
59
|
}
|
|
56
60
|
}, _class);
|
|
57
61
|
|
|
58
62
|
|
|
59
63
|
|
|
60
64
|
exports.BigIntSchema = BigIntSchema;
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-UUY7DPHK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-UUY7DPHK.js","../src/schemas/BigIntSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACXO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBACnC,QAAA,EAAU,EAAA;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,OAAA,CAA0B,aAAA,EAA2C;AAC1E,IAAA,IAAA,CAAK,iBAAA,CAAkB,CAAA;AACvB,IAAA,IAAA,CAAK,UAAA,CAAW,CAAA;AAChB,IAAA,6CAAA,IAAe,EAAM,CAAA,EAAA;AACF,IAAA;AACrB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWqC,EAAA;AAC9B,IAAA;AACW,IAAA;AAChB,IAAA;AACE,MAAA;AACmB,MAAA;AACrB,IAAA;AACmB,IAAA;AACrB,EAAA;AAEqB,EAAA;AACG,IAAA;AACT,IAAA;AACf,EAAA;AACF;ADU0B;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-UUY7DPHK.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { WithBGuardType } from '../commonTypes';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class BigIntSchema extends CommonSchema {\n protected _bigint = 1;\n private limit: boolean | undefined;\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 - bigint().equalTo(42n); // Infers the type 42n\n */\n public equalTo<Y extends bigint>(expectedValue: Y): WithBGuardType<this, Y> {\n this.defaultValueCheck();\n this.limitCheck();\n _setStrictType(this, `${expectedValue}n`);\n return this.custom(equalTo(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n\n */\n public oneOfValues<Y extends bigint>(expectedValue: Y[]): WithBGuardType<this, Y> {\n this.defaultValueCheck();\n this.limitCheck();\n _setStrictType(\n this,\n expectedValue.map((el) => `${el}n`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n private limitCheck() {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/helpers/
|
|
2
|
-
function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/helpers/isValidDateInner.ts
|
|
2
|
+
function isValidDateInner(d) {
|
|
3
3
|
return (
|
|
4
4
|
// @ts-expect-error we expect d to have getTime method
|
|
5
5
|
Object.prototype.toString.call(d) === "[object Date]" && !isNaN(typeof _optionalChain([d, 'optionalAccess', _ => _.getTime]) === "function" && d.getTime())
|
|
@@ -8,5 +8,5 @@ function isValidDate(d) {
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
exports.
|
|
12
|
-
//# sourceMappingURL=chunk-
|
|
11
|
+
exports.isValidDateInner = isValidDateInner;
|
|
12
|
+
//# sourceMappingURL=chunk-VBTWYDEM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-VBTWYDEM.js","../src/helpers/isValidDateInner.ts"],"names":[],"mappings":"AAAA;ACAO,SAAS,gBAAA,CAAiB,CAAA,EAAY;AAC3C,EAAA,OAAA;AAAA;AAAA,IAEE,MAAA,CAAO,SAAA,CAAU,QAAA,CAAS,IAAA,CAAK,CAAC,EAAA,IAAM,gBAAA,GAAmB,CAAC,KAAA,CAAM,uBAAO,CAAA,2BAAG,UAAA,IAAY,WAAA,GAAc,CAAA,CAAE,OAAA,CAAQ,CAAC;AAAA,EAAA,CAAA;AAEnH;ADEA;AACA;AACE;AACF,4CAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-VBTWYDEM.js","sourcesContent":[null,"export function isValidDateInner(d: unknown) {\n return (\n // @ts-expect-error we expect d to have getTime method\n Object.prototype.toString.call(d) === '[object Date]' && !isNaN(typeof d?.getTime === 'function' && d.getTime())\n );\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
+
|
|
3
|
+
var _chunkSHJVKSEZjs = require('./chunk-SHJVKSEZ.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkX762EUSZjs = require('./chunk-X762EUSZ.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
|
|
10
|
+
|
|
11
|
+
// src/schemas/ArraySchema.ts
|
|
12
|
+
var ArraySchema = (_class = class extends _chunkSHJVKSEZjs.CommonSchema {
|
|
13
|
+
__init() {this._array = 1}
|
|
14
|
+
constructor(ctx, arraySchema) {
|
|
15
|
+
super(ctx);_class.prototype.__init.call(this);;
|
|
16
|
+
this.validateArrayEntry(arraySchema);
|
|
17
|
+
this[_chunkX762EUSZjs.ctxSymbol].array = arraySchema;
|
|
18
|
+
}
|
|
19
|
+
validateArrayEntry(arraySchema) {
|
|
20
|
+
if (!arraySchema) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)("Missing schema in array method");
|
|
21
|
+
if (!(arraySchema instanceof _chunkSHJVKSEZjs.CommonSchema)) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)("Invalid schema in array method");
|
|
22
|
+
}
|
|
23
|
+
}, _class);
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
exports.ArraySchema = ArraySchema;
|
|
28
|
+
//# sourceMappingURL=chunk-VW4RMQD4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-VW4RMQD4.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,iBAClC,OAAA,EAAS,EAAA;AAAA,EACnB,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-VW4RMQD4.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class ArraySchema extends CommonSchema {\n protected _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"]}
|