bguard 0.1.1 → 0.3.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 +561 -175
- package/lib/{CommonSchema-CjsYE4dC.d.mts → CommonSchema-CiY7spmg.d.mts} +12 -3
- package/lib/{CommonSchema-BbGNki0L.d.ts → CommonSchema-D9QVJBJe.d.ts} +12 -3
- package/lib/InferType.d.mts +5 -2
- package/lib/InferType.d.ts +5 -2
- package/lib/asserts/array/index.d.mts +4 -4
- package/lib/asserts/array/index.d.ts +4 -4
- package/lib/asserts/array/index.js +13 -6
- package/lib/asserts/array/index.js.map +1 -1
- package/lib/asserts/array/index.mjs +13 -6
- 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.d.mts +22 -0
- package/lib/asserts/bigint/bigintMax.d.ts +22 -0
- package/lib/asserts/bigint/bigintMax.js +20 -0
- package/lib/asserts/bigint/bigintMax.js.map +1 -0
- package/lib/asserts/bigint/bigintMax.mjs +20 -0
- package/lib/asserts/bigint/bigintMax.mjs.map +1 -0
- package/lib/asserts/bigint/bigintMaxExcluded.d.mts +22 -0
- package/lib/asserts/bigint/bigintMaxExcluded.d.ts +22 -0
- package/lib/asserts/bigint/bigintMaxExcluded.js +20 -0
- package/lib/asserts/bigint/bigintMaxExcluded.js.map +1 -0
- package/lib/asserts/bigint/bigintMaxExcluded.mjs +20 -0
- package/lib/asserts/bigint/bigintMaxExcluded.mjs.map +1 -0
- package/lib/asserts/bigint/bigintMin.d.mts +22 -0
- package/lib/asserts/bigint/bigintMin.d.ts +22 -0
- package/lib/asserts/bigint/bigintMin.js +20 -0
- package/lib/asserts/bigint/bigintMin.js.map +1 -0
- package/lib/asserts/bigint/bigintMin.mjs +20 -0
- package/lib/asserts/bigint/bigintMin.mjs.map +1 -0
- package/lib/asserts/bigint/bigintMinExcluded.d.mts +22 -0
- package/lib/asserts/bigint/bigintMinExcluded.d.ts +22 -0
- package/lib/asserts/bigint/bigintMinExcluded.js +20 -0
- package/lib/asserts/bigint/bigintMinExcluded.js.map +1 -0
- package/lib/asserts/bigint/bigintMinExcluded.mjs +20 -0
- package/lib/asserts/bigint/bigintMinExcluded.mjs.map +1 -0
- package/lib/asserts/bigint/index.d.mts +18 -0
- package/lib/asserts/bigint/index.d.ts +18 -0
- package/lib/asserts/bigint/index.js +22 -0
- package/lib/asserts/bigint/index.js.map +1 -0
- package/lib/asserts/bigint/index.mjs +22 -0
- package/lib/asserts/bigint/index.mjs.map +1 -0
- package/lib/asserts/boolean/index.d.mts +4 -4
- package/lib/asserts/boolean/index.d.ts +4 -4
- package/lib/asserts/boolean/index.js +14 -7
- package/lib/asserts/boolean/index.js.map +1 -1
- package/lib/asserts/boolean/index.mjs +14 -7
- package/lib/asserts/boolean/index.mjs.map +1 -1
- package/lib/asserts/date/dateMax.d.mts +22 -0
- package/lib/asserts/date/dateMax.d.ts +22 -0
- package/lib/asserts/date/dateMax.js +28 -0
- package/lib/asserts/date/dateMax.js.map +1 -0
- package/lib/asserts/date/dateMax.mjs +28 -0
- package/lib/asserts/date/dateMax.mjs.map +1 -0
- package/lib/asserts/date/dateMin.d.mts +22 -0
- package/lib/asserts/date/dateMin.d.ts +22 -0
- package/lib/asserts/date/dateMin.js +28 -0
- package/lib/asserts/date/dateMin.js.map +1 -0
- package/lib/asserts/date/dateMin.mjs +28 -0
- package/lib/asserts/date/dateMin.mjs.map +1 -0
- package/lib/asserts/date/index.d.mts +17 -0
- package/lib/asserts/date/index.d.ts +17 -0
- package/lib/asserts/date/index.js +18 -0
- package/lib/asserts/date/index.js.map +1 -0
- package/lib/asserts/date/index.mjs +18 -0
- package/lib/asserts/date/index.mjs.map +1 -0
- package/lib/asserts/mix/equalTo.d.mts +1 -1
- package/lib/asserts/mix/equalTo.d.ts +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 +4 -3
- package/lib/asserts/mix/index.d.ts +4 -3
- package/lib/asserts/mix/index.js +12 -5
- package/lib/asserts/mix/index.js.map +1 -1
- package/lib/asserts/mix/index.mjs +12 -5
- package/lib/asserts/mix/index.mjs.map +1 -1
- package/lib/asserts/mix/oneOfValues.d.mts +1 -1
- package/lib/asserts/mix/oneOfValues.d.ts +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 -4
- package/lib/asserts/number/index.d.ts +4 -4
- package/lib/asserts/number/index.js +16 -10
- package/lib/asserts/number/index.js.map +1 -1
- package/lib/asserts/number/index.mjs +16 -10
- 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 +4 -4
- package/lib/asserts/object/index.d.ts +4 -4
- package/lib/asserts/object/index.js +13 -6
- package/lib/asserts/object/index.js.map +1 -1
- package/lib/asserts/object/index.mjs +13 -6
- package/lib/asserts/object/index.mjs.map +1 -1
- 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 +4 -4
- package/lib/asserts/string/index.d.ts +4 -4
- package/lib/asserts/string/index.js +16 -10
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +16 -10
- 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-LEQCDD66.js → chunk-2D5QE7F4.js} +17 -15
- package/lib/chunk-2D5QE7F4.js.map +1 -0
- package/lib/chunk-2MFBOVP2.mjs +20 -0
- package/lib/chunk-2MFBOVP2.mjs.map +1 -0
- package/lib/chunk-3IOQH3K4.js +74 -0
- package/lib/chunk-3IOQH3K4.js.map +1 -0
- package/lib/chunk-3ZPLJ5KC.js +14 -0
- package/lib/{chunk-JSGZ7DKT.js.map → chunk-3ZPLJ5KC.js.map} +1 -1
- package/lib/{chunk-3HTYHE2X.mjs → chunk-4GDBM5LP.mjs} +4 -3
- package/lib/chunk-4GDBM5LP.mjs.map +1 -0
- package/lib/{chunk-TCQY2R3U.mjs → chunk-5HT3PYSG.mjs} +4 -4
- package/lib/chunk-5HT3PYSG.mjs.map +1 -0
- package/lib/{chunk-PH2PMUZP.mjs → chunk-5LLJ22IG.mjs} +28 -14
- package/lib/chunk-5LLJ22IG.mjs.map +1 -0
- package/lib/{chunk-PG2R7P7G.mjs → chunk-ADSMWGDJ.mjs} +4 -4
- package/lib/{chunk-H7CPKW53.js → chunk-AN3VHQEQ.js} +7 -7
- package/lib/{chunk-H7CPKW53.js.map → chunk-AN3VHQEQ.js.map} +1 -1
- package/lib/chunk-AOUFWACR.mjs +74 -0
- package/lib/chunk-AOUFWACR.mjs.map +1 -0
- package/lib/{chunk-WK4O3HH4.js → chunk-AY7HKAG2.js} +2 -3
- package/lib/chunk-AY7HKAG2.js.map +1 -0
- package/lib/{chunk-NNFYXHLU.mjs → chunk-BUXOCPHI.mjs} +3 -3
- package/lib/chunk-BUXOCPHI.mjs.map +1 -0
- package/lib/{chunk-RYVUYVEE.mjs → chunk-D42ISCFK.mjs} +2 -2
- package/lib/{chunk-KQKJASVB.js → chunk-EU3ZZF7Y.js} +13 -13
- package/lib/chunk-EU3ZZF7Y.js.map +1 -0
- package/lib/{chunk-NDQM5OL4.mjs → chunk-KBZUNXJB.mjs} +4 -4
- package/lib/chunk-KBZUNXJB.mjs.map +1 -0
- package/lib/chunk-LYNVPN3R.js +28 -0
- package/lib/chunk-LYNVPN3R.js.map +1 -0
- package/lib/{chunk-7XFLH6R2.mjs → chunk-NP64RC7B.mjs} +2 -3
- package/lib/chunk-NP64RC7B.mjs.map +1 -0
- package/lib/{chunk-3O4WCRC2.mjs → chunk-OHEMRF7Y.mjs} +3 -3
- package/lib/chunk-OHEMRF7Y.mjs.map +1 -0
- package/lib/chunk-OJSTQQ3N.js +20 -0
- package/lib/chunk-OJSTQQ3N.js.map +1 -0
- package/lib/{chunk-YUESB2WV.mjs → chunk-OKF3BVUD.mjs} +4 -4
- package/lib/{chunk-6TH3DBDK.js → chunk-OO6BTBVP.js} +11 -11
- package/lib/chunk-OO6BTBVP.js.map +1 -0
- package/lib/chunk-P6V6S6TZ.js +65 -0
- package/lib/chunk-P6V6S6TZ.js.map +1 -0
- package/lib/{chunk-DJSLA2ZV.js → chunk-PESVL5YJ.js} +7 -7
- package/lib/{chunk-DJSLA2ZV.js.map → chunk-PESVL5YJ.js.map} +1 -1
- package/lib/{chunk-IRG4OQAB.js → chunk-PIBDJJUU.js} +35 -21
- package/lib/chunk-PIBDJJUU.js.map +1 -0
- package/lib/{chunk-J4VKFJQK.js → chunk-SPWF5IFU.js} +5 -5
- package/lib/chunk-SPWF5IFU.js.map +1 -0
- package/lib/{chunk-P7IXNCJG.mjs → chunk-TQWUSDQD.mjs} +6 -6
- package/lib/chunk-TQWUSDQD.mjs.map +1 -0
- package/lib/{chunk-5BVJ6YMH.js → chunk-UZ2PWO4O.js} +6 -5
- package/lib/chunk-UZ2PWO4O.js.map +1 -0
- package/lib/chunk-VBTWYDEM.js +12 -0
- package/lib/chunk-VBTWYDEM.js.map +1 -0
- package/lib/{chunk-4CYIMDP2.js → chunk-W2GOLG3K.js} +5 -5
- package/lib/chunk-W2GOLG3K.js.map +1 -0
- package/lib/chunk-YBVMP4EI.mjs +12 -0
- package/lib/chunk-YBVMP4EI.mjs.map +1 -0
- package/lib/{chunk-CCBCDJXS.mjs → chunk-YPAFWVDL.mjs} +4 -4
- package/lib/chunk-YPAFWVDL.mjs.map +1 -0
- package/lib/chunk-ZMEQCIRN.mjs +65 -0
- package/lib/chunk-ZMEQCIRN.mjs.map +1 -0
- package/lib/{chunk-WBERBAL4.js → chunk-ZVW3IHBW.js} +8 -8
- package/lib/chunk-ZVW3IHBW.js.map +1 -0
- package/lib/{chunk-JPRCULRQ.mjs → chunk-ZWE5Q37U.mjs} +12 -10
- package/lib/chunk-ZWE5Q37U.mjs.map +1 -0
- package/lib/codeGen.d.mts +1 -1
- package/lib/codeGen.d.ts +1 -1
- package/lib/codeGen.js +5 -3
- package/lib/codeGen.js.map +1 -1
- package/lib/codeGen.mjs +4 -2
- package/lib/codeGen.mjs.map +1 -1
- package/lib/commonTypes.d.mts +1 -0
- package/lib/commonTypes.d.ts +1 -0
- package/lib/exceptions.js +2 -2
- package/lib/exceptions.mjs +1 -1
- package/lib/helpers/core.d.mts +1 -1
- package/lib/helpers/core.d.ts +1 -1
- package/lib/helpers/core.js +4 -3
- package/lib/helpers/core.js.map +1 -1
- package/lib/helpers/core.mjs +3 -2
- 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/isValidDateInner.mjs.map +1 -0
- package/lib/helpers/setStrictType.d.mts +1 -1
- package/lib/helpers/setStrictType.d.ts +1 -1
- package/lib/helpers/setStrictType.js +5 -4
- package/lib/helpers/setStrictType.js.map +1 -1
- package/lib/helpers/setStrictType.mjs +4 -3
- package/lib/index.d.mts +3 -7
- package/lib/index.d.ts +3 -7
- package/lib/index.js +7 -40
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +7 -40
- package/lib/parse.d.mts +3 -1
- package/lib/parse.d.ts +3 -1
- package/lib/parse.js +6 -5
- package/lib/parse.js.map +1 -1
- package/lib/parse.mjs +5 -4
- package/lib/parseOrFail.d.mts +3 -1
- package/lib/parseOrFail.d.ts +3 -1
- package/lib/parseOrFail.js +6 -5
- package/lib/parseOrFail.js.map +1 -1
- package/lib/parseOrFail.mjs +5 -4
- package/lib/schemas/ArraySchema.d.mts +2 -2
- package/lib/schemas/ArraySchema.d.ts +2 -2
- package/lib/schemas/ArraySchema.js +8 -5
- package/lib/schemas/ArraySchema.js.map +1 -1
- package/lib/schemas/ArraySchema.mjs +7 -4
- package/lib/schemas/BigIntSchema.d.mts +33 -0
- package/lib/schemas/BigIntSchema.d.ts +33 -0
- package/lib/schemas/BigIntSchema.js +17 -0
- package/lib/schemas/BigIntSchema.js.map +1 -0
- package/lib/schemas/BigIntSchema.mjs +17 -0
- package/lib/schemas/BigIntSchema.mjs.map +1 -0
- package/lib/schemas/BooleanSchema.d.mts +2 -2
- package/lib/schemas/BooleanSchema.d.ts +2 -2
- package/lib/schemas/BooleanSchema.js +9 -6
- package/lib/schemas/BooleanSchema.js.map +1 -1
- package/lib/schemas/BooleanSchema.mjs +8 -5
- package/lib/schemas/CommonSchema.d.mts +1 -1
- package/lib/schemas/CommonSchema.d.ts +1 -1
- package/lib/schemas/CommonSchema.js +7 -4
- package/lib/schemas/CommonSchema.js.map +1 -1
- package/lib/schemas/CommonSchema.mjs +6 -3
- package/lib/schemas/DateSchema.d.mts +9 -0
- package/lib/schemas/DateSchema.d.ts +9 -0
- package/lib/schemas/DateSchema.js +13 -0
- package/lib/schemas/DateSchema.js.map +1 -0
- package/lib/schemas/DateSchema.mjs +13 -0
- package/lib/schemas/DateSchema.mjs.map +1 -0
- package/lib/schemas/NumberSchema.d.mts +2 -2
- package/lib/schemas/NumberSchema.d.ts +2 -2
- package/lib/schemas/NumberSchema.js +11 -9
- package/lib/schemas/NumberSchema.js.map +1 -1
- package/lib/schemas/NumberSchema.mjs +10 -8
- package/lib/schemas/ObjectSchema.d.mts +2 -2
- package/lib/schemas/ObjectSchema.d.ts +2 -2
- package/lib/schemas/ObjectSchema.js +8 -5
- package/lib/schemas/ObjectSchema.js.map +1 -1
- package/lib/schemas/ObjectSchema.mjs +7 -4
- package/lib/schemas/StringSchema.d.mts +3 -2
- package/lib/schemas/StringSchema.d.ts +3 -2
- package/lib/schemas/StringSchema.js +11 -9
- package/lib/schemas/StringSchema.js.map +1 -1
- package/lib/schemas/StringSchema.mjs +10 -8
- package/lib/translationMap.js +3 -3
- package/lib/translationMap.mjs +2 -2
- package/package.json +6 -1
- package/lib/chunk-2PM3K3OE.mjs +0 -13
- package/lib/chunk-2PM3K3OE.mjs.map +0 -1
- package/lib/chunk-32RSTOZ4.mjs +0 -13
- package/lib/chunk-32RSTOZ4.mjs.map +0 -1
- package/lib/chunk-3HTYHE2X.mjs.map +0 -1
- package/lib/chunk-3O4WCRC2.mjs.map +0 -1
- package/lib/chunk-4CYIMDP2.js.map +0 -1
- package/lib/chunk-5BVJ6YMH.js.map +0 -1
- package/lib/chunk-6TH3DBDK.js.map +0 -1
- package/lib/chunk-7XFLH6R2.mjs.map +0 -1
- package/lib/chunk-CCBCDJXS.mjs.map +0 -1
- package/lib/chunk-DPBE7TAQ.mjs +0 -42
- package/lib/chunk-DPBE7TAQ.mjs.map +0 -1
- package/lib/chunk-EGEHSELT.js +0 -42
- package/lib/chunk-EGEHSELT.js.map +0 -1
- package/lib/chunk-HDSGCAHH.js +0 -13
- package/lib/chunk-HDSGCAHH.js.map +0 -1
- package/lib/chunk-IEUXIOL6.js +0 -13
- package/lib/chunk-IEUXIOL6.js.map +0 -1
- package/lib/chunk-IRG4OQAB.js.map +0 -1
- package/lib/chunk-J4VKFJQK.js.map +0 -1
- package/lib/chunk-JDGZCBXF.mjs +0 -13
- package/lib/chunk-JDGZCBXF.mjs.map +0 -1
- package/lib/chunk-JPRCULRQ.mjs.map +0 -1
- package/lib/chunk-JSGZ7DKT.js +0 -14
- package/lib/chunk-KQKJASVB.js.map +0 -1
- package/lib/chunk-LEQCDD66.js.map +0 -1
- package/lib/chunk-MRISXZQ4.mjs +0 -13
- package/lib/chunk-MRISXZQ4.mjs.map +0 -1
- package/lib/chunk-NDQM5OL4.mjs.map +0 -1
- package/lib/chunk-NNFYXHLU.mjs.map +0 -1
- package/lib/chunk-P7IXNCJG.mjs.map +0 -1
- package/lib/chunk-PH2PMUZP.mjs.map +0 -1
- package/lib/chunk-PXBAS3GA.mjs +0 -13
- package/lib/chunk-PXBAS3GA.mjs.map +0 -1
- package/lib/chunk-QQNQ4IDN.js +0 -13
- package/lib/chunk-QQNQ4IDN.js.map +0 -1
- package/lib/chunk-RD6TBCPQ.js +0 -13
- package/lib/chunk-RD6TBCPQ.js.map +0 -1
- package/lib/chunk-RRQOET3X.js +0 -28
- package/lib/chunk-RRQOET3X.js.map +0 -1
- package/lib/chunk-TCQY2R3U.mjs.map +0 -1
- package/lib/chunk-TKZ6FLLR.js +0 -13
- package/lib/chunk-TKZ6FLLR.js.map +0 -1
- package/lib/chunk-VHEA4JZ5.js +0 -13
- package/lib/chunk-VHEA4JZ5.js.map +0 -1
- package/lib/chunk-WBERBAL4.js.map +0 -1
- package/lib/chunk-WK4O3HH4.js.map +0 -1
- package/lib/chunk-YML32TPA.mjs +0 -13
- package/lib/chunk-YML32TPA.mjs.map +0 -1
- /package/lib/{chunk-PG2R7P7G.mjs.map → chunk-ADSMWGDJ.mjs.map} +0 -0
- /package/lib/{chunk-RYVUYVEE.mjs.map → chunk-D42ISCFK.mjs.map} +0 -0
- /package/lib/{chunk-YUESB2WV.mjs.map → chunk-OKF3BVUD.mjs.map} +0 -0
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StringSchema
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-ZWE5Q37U.mjs";
|
|
4
|
+
import "../chunk-BUXOCPHI.mjs";
|
|
5
|
+
import "../chunk-OHEMRF7Y.mjs";
|
|
6
6
|
import "../chunk-ASZW6XRM.mjs";
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-D42ISCFK.mjs";
|
|
8
|
+
import "../chunk-AOUFWACR.mjs";
|
|
9
|
+
import "../chunk-ADSMWGDJ.mjs";
|
|
10
|
+
import "../chunk-5LLJ22IG.mjs";
|
|
11
|
+
import "../chunk-YBVMP4EI.mjs";
|
|
12
|
+
import "../chunk-4GDBM5LP.mjs";
|
|
13
|
+
import "../chunk-NP64RC7B.mjs";
|
|
12
14
|
export {
|
|
13
15
|
StringSchema
|
|
14
16
|
};
|
package/lib/translationMap.js
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
7
|
-
require('./chunk-
|
|
6
|
+
var _chunkUZ2PWO4Ojs = require('./chunk-UZ2PWO4O.js');
|
|
7
|
+
require('./chunk-AY7HKAG2.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
exports.clearLocales =
|
|
13
|
+
exports.clearLocales = _chunkUZ2PWO4Ojs.clearLocales; exports.getTranslationByLocale = _chunkUZ2PWO4Ojs.getTranslationByLocale; exports.setLocale = _chunkUZ2PWO4Ojs.setLocale; exports.setToDefaultLocale = _chunkUZ2PWO4Ojs.setToDefaultLocale;
|
|
14
14
|
//# sourceMappingURL=translationMap.js.map
|
package/lib/translationMap.mjs
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "bguard",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "lib/index.mjs",
|
|
8
8
|
"types": "lib/index.d.ts",
|
|
@@ -139,6 +139,11 @@
|
|
|
139
139
|
"require": "./lib/asserts/bigint/*.js",
|
|
140
140
|
"types": "./lib/asserts/bigint/*.d.ts"
|
|
141
141
|
},
|
|
142
|
+
"./date/*": {
|
|
143
|
+
"import": "./lib/asserts/date/*.mjs",
|
|
144
|
+
"require": "./lib/asserts/date/*.js",
|
|
145
|
+
"types": "./lib/asserts/date/*.d.ts"
|
|
146
|
+
},
|
|
142
147
|
"./*": {
|
|
143
148
|
"import": "./*.mjs",
|
|
144
149
|
"require": "./*.js",
|
package/lib/chunk-2PM3K3OE.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ObjectSchema
|
|
3
|
-
} from "./chunk-TCQY2R3U.mjs";
|
|
4
|
-
|
|
5
|
-
// src/asserts/object/index.ts
|
|
6
|
-
function object(shapeSchema) {
|
|
7
|
-
return new ObjectSchema({ type: [], requiredValidations: [] }, shapeSchema);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
object
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=chunk-2PM3K3OE.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/object/index.ts"],"sourcesContent":["import { ObjectShapeSchemaType } from '../../schemas/CommonSchema';\nimport { ObjectSchema, WithObject } from '../../schemas/ObjectSchema';\n\n/**\n * Creates a new schema for validating objects where each property must match the specified schema.\n *\n * @template T\n * @param {T} shapeSchema - The schema that each property of the object must match.\n * @returns {WithObject<T>} A new instance of `ObjectSchema` for validating objects with properties matching the specified schema.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number()\n * });\n * parseOrFail(schema, { name: 'John', age: 30 }); // Validates successfully\n * parseOrFail(schema, { name: 'John', age: '30' }); // Throws a validation error\n */\nexport function object<T extends ObjectShapeSchemaType>(shapeSchema: T): WithObject<T> {\n return new ObjectSchema({ type: [], requiredValidations: [] }, shapeSchema) as WithObject<T>;\n}\n"],"mappings":";;;;;AAkBO,SAAS,OAAwC,aAA+B;AACrF,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,EAAE,GAAG,WAAW;AAC5E;","names":[]}
|
package/lib/chunk-32RSTOZ4.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
StringSchema
|
|
3
|
-
} from "./chunk-JPRCULRQ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/asserts/string/index.ts
|
|
6
|
-
function string() {
|
|
7
|
-
return new StringSchema({ type: ["string"], requiredValidations: [] });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
string
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=chunk-32RSTOZ4.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/string/index.ts"],"sourcesContent":["import { StringSchema } from '../../schemas/StringSchema';\n\n/**\n * Creates a new schema for validating string values.\n *\n * @returns {StringSchema} A new instance of `StringSchema` for validating strings.\n *\n * @example\n * const schema = string();\n * parseOrFail(schema, 'hello'); // Validates successfully\n * parseOrFail(schema, 123); // Throws a validation error\n */\nexport function string(): StringSchema {\n return new StringSchema({ type: ['string'], requiredValidations: [] });\n}\n"],"mappings":";;;;;AAYO,SAAS,SAAuB;AACrC,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,QAAQ,GAAG,qBAAqB,CAAC,EAAE,CAAC;AACvE;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/translationMap.ts"],"sourcesContent":["import { BuildSchemaError } from './exceptions';\nimport { RequiredValidation, TranslationErrorMap } from './commonTypes';\n\n// c: stands for common\nconst defaultErrorMap: TranslationErrorMap = {\n //@@start\n 'c:optional': 'The required value is missing',\n 'c:nullable': 'Value should not be null',\n 'c:array': 'Expected an array but received a different type',\n 'c:objectType': 'Expected an object but received a different type',\n 'c:objectTypeAsArray': 'Expected an object but received an array. Invalid type of data',\n 'c:unrecognizedProperty': 'This property is not allowed in the object',\n 'c:requiredProperty': 'Missing required property in the object',\n 'c:invalidType': 'Invalid type of data',\n 'c:isBoolean': 'The received value is not {{e}}',\n //@@end\n};\n\nlet data: Record<string, Record<string, string>> = {\n default: { ...defaultErrorMap },\n};\n\nexport function setToDefaultLocale({\n key,\n message,\n}: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (expected: any): RequiredValidation;\n key: string;\n message: string;\n}) {\n const defaultLocale = data.default!;\n if (defaultLocale[key]) throw new BuildSchemaError('Duplicate default message key');\n defaultLocale[key] = message;\n}\n\nexport function setLocale(lng: string, custom: Partial<TranslationErrorMap>) {\n if (lng === 'default') throw new BuildSchemaError('Invalid language');\n if (!data[lng]) data[lng] = { ...defaultErrorMap };\n const locale = data[lng]!;\n Object.entries(custom).forEach(([messageKey, messageValue]) => {\n locale[messageKey] = messageValue!;\n });\n}\n\nexport function clearLocales() {\n data = {\n default: { ...defaultErrorMap },\n };\n}\n\nexport function getTranslationByLocale(lng?: string): TranslationErrorMap {\n if (!lng) return data['default'] as TranslationErrorMap;\n return (data[lng] ?? data['default']) as TranslationErrorMap;\n}\n"],"mappings":";;;;;AAIA,IAAM,kBAAuC;AAAA;AAAA,EAE3C,cAAc;AAAA,EACd,cAAc;AAAA,EACd,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,uBAAuB;AAAA,EACvB,0BAA0B;AAAA,EAC1B,sBAAsB;AAAA,EACtB,iBAAiB;AAAA,EACjB,eAAe;AAAA;AAEjB;AAEA,IAAI,OAA+C;AAAA,EACjD,SAAS,EAAE,GAAG,gBAAgB;AAChC;AAEO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAKG;AACD,QAAM,gBAAgB,KAAK;AAC3B,MAAI,cAAc,GAAG,EAAG,OAAM,IAAI,iBAAiB,+BAA+B;AAClF,gBAAc,GAAG,IAAI;AACvB;AAEO,SAAS,UAAU,KAAa,QAAsC;AAC3E,MAAI,QAAQ,UAAW,OAAM,IAAI,iBAAiB,kBAAkB;AACpE,MAAI,CAAC,KAAK,GAAG,EAAG,MAAK,GAAG,IAAI,EAAE,GAAG,gBAAgB;AACjD,QAAM,SAAS,KAAK,GAAG;AACvB,SAAO,QAAQ,MAAM,EAAE,QAAQ,CAAC,CAAC,YAAY,YAAY,MAAM;AAC7D,WAAO,UAAU,IAAI;AAAA,EACvB,CAAC;AACH;AAEO,SAAS,eAAe;AAC7B,SAAO;AAAA,IACL,SAAS,EAAE,GAAG,gBAAgB;AAAA,EAChC;AACF;AAEO,SAAS,uBAAuB,KAAmC;AACxE,MAAI,CAAC,IAAK,QAAO,KAAK,SAAS;AAC/B,SAAQ,KAAK,GAAG,KAAK,KAAK,SAAS;AACrC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/mix/oneOfValues.ts"],"sourcesContent":["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 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"],"mappings":";;;;;;;;AAIA,IAAM,0BAA0B;AAChC,IAAM,sBAAsB;AAgBrB,IAAM,cACX,CAAC,aACD,CAAC,UAAmB,QAA0B;AAC5C,MAAI,CAAC,SAAS,SAAS,QAAQ,EAAG,gBAAe,UAAU,UAAU,KAAK,mBAAmB;AAC/F;AAEF,YAAY,MAAM;AAClB,YAAY,UAAU;AACtB,mBAAmB,WAAW;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-4CYIMDP2.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-4CYIMDP2.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 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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-5BVJ6YMH.js","../src/translationMap.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACAA,IAAM,gBAAA,EAAuC;AAAA;AAAA,EAE3C,YAAA,EAAc,+BAAA;AAAA,EACd,YAAA,EAAc,0BAAA;AAAA,EACd,SAAA,EAAW,iDAAA;AAAA,EACX,cAAA,EAAgB,kDAAA;AAAA,EAChB,qBAAA,EAAuB,gEAAA;AAAA,EACvB,wBAAA,EAA0B,4CAAA;AAAA,EAC1B,oBAAA,EAAsB,yCAAA;AAAA,EACtB,eAAA,EAAiB,sBAAA;AAAA,EACjB,aAAA,EAAe;AAAA;AAEjB,CAAA;AAEA,IAAI,KAAA,EAA+C;AAAA,EACjD,OAAA,EAAS,EAAE,GAAG,gBAAgB;AAChC,CAAA;AAEO,SAAS,kBAAA,CAAmB;AAAA,EACjC,GAAA;AAAA,EACA;AACF,CAAA,EAKG;AACD,EAAA,MAAM,cAAA,EAAgB,IAAA,CAAK,OAAA;AAC3B,EAAA,GAAA,CAAI,aAAA,CAAc,GAAG,CAAA,EAAG,MAAM,IAAI,sCAAA,CAAiB,+BAA+B,CAAA;AAClF,EAAA,aAAA,CAAc,GAAG,EAAA,EAAI,OAAA;AACvB;AAEO,SAAS,SAAA,CAAU,GAAA,EAAa,MAAA,EAAsC;AAC3E,EAAA,GAAA,CAAI,IAAA,IAAQ,SAAA,EAAW,MAAM,IAAI,sCAAA,CAAiB,kBAAkB,CAAA;AACpE,EAAA,GAAA,CAAI,CAAC,IAAA,CAAK,GAAG,CAAA,EAAG,IAAA,CAAK,GAAG,EAAA,EAAI,EAAE,GAAG,gBAAgB,CAAA;AACjD,EAAA,MAAM,OAAA,EAAS,IAAA,CAAK,GAAG,CAAA;AACvB,EAAA,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAC,UAAA,EAAY,YAAY,CAAA,EAAA,GAAM;AAC7D,IAAA,MAAA,CAAO,UAAU,EAAA,EAAI,YAAA;AAAA,EACvB,CAAC,CAAA;AACH;AAEO,SAAS,YAAA,CAAA,EAAe;AAC7B,EAAA,KAAA,EAAO;AAAA,IACL,OAAA,EAAS,EAAE,GAAG,gBAAgB;AAAA,EAChC,CAAA;AACF;AAEO,SAAS,sBAAA,CAAuB,GAAA,EAAmC;AACxE,EAAA,GAAA,CAAI,CAAC,GAAA,EAAK,OAAO,IAAA,CAAK,SAAS,CAAA;AAC/B,EAAA,wBAAQ,IAAA,CAAK,GAAG,CAAA,UAAK,IAAA,CAAK,SAAS,GAAA;AACrC;ADRA;AACA;AACE;AACA;AACA;AACA;AACF,6KAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-5BVJ6YMH.js","sourcesContent":[null,"import { BuildSchemaError } from './exceptions';\nimport { RequiredValidation, TranslationErrorMap } from './commonTypes';\n\n// c: stands for common\nconst defaultErrorMap: TranslationErrorMap = {\n //@@start\n 'c:optional': 'The required value is missing',\n 'c:nullable': 'Value should not be null',\n 'c:array': 'Expected an array but received a different type',\n 'c:objectType': 'Expected an object but received a different type',\n 'c:objectTypeAsArray': 'Expected an object but received an array. Invalid type of data',\n 'c:unrecognizedProperty': 'This property is not allowed in the object',\n 'c:requiredProperty': 'Missing required property in the object',\n 'c:invalidType': 'Invalid type of data',\n 'c:isBoolean': 'The received value is not {{e}}',\n //@@end\n};\n\nlet data: Record<string, Record<string, string>> = {\n default: { ...defaultErrorMap },\n};\n\nexport function setToDefaultLocale({\n key,\n message,\n}: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (expected: any): RequiredValidation;\n key: string;\n message: string;\n}) {\n const defaultLocale = data.default!;\n if (defaultLocale[key]) throw new BuildSchemaError('Duplicate default message key');\n defaultLocale[key] = message;\n}\n\nexport function setLocale(lng: string, custom: Partial<TranslationErrorMap>) {\n if (lng === 'default') throw new BuildSchemaError('Invalid language');\n if (!data[lng]) data[lng] = { ...defaultErrorMap };\n const locale = data[lng]!;\n Object.entries(custom).forEach(([messageKey, messageValue]) => {\n locale[messageKey] = messageValue!;\n });\n}\n\nexport function clearLocales() {\n data = {\n default: { ...defaultErrorMap },\n };\n}\n\nexport function getTranslationByLocale(lng?: string): TranslationErrorMap {\n if (!lng) return data['default'] as TranslationErrorMap;\n return (data[lng] ?? data['default']) as TranslationErrorMap;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-6TH3DBDK.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;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-6TH3DBDK.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 _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\nexport type WithObject<Y extends ObjectShapeSchemaType> = ObjectSchema & { validation_object: Y };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/exceptions.ts"],"sourcesContent":["import type { ExceptionContext } from './commonTypes';\n\nexport 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\nfunction replacePlaceholders(template: string, replacements: Record<string, unknown>): string {\n const regex = /{{(.*?)}}/g;\n return template.replace(regex, (_, key) => {\n const vvv = key in replacements ? `${replacements[key] as string}` : `{{${key}}}`;\n return vvv;\n });\n}\n\nexport function guardException(\n expected: unknown,\n received: unknown,\n ctx: ExceptionContext,\n messageKey: string,\n): never | void {\n const rawMessage = ctx.t[messageKey] ?? messageKey;\n const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: ctx.pathToError });\n\n if (ctx.getAllErrors) {\n ctx.errors.push({\n expected,\n received,\n pathToError: ctx.pathToError,\n message,\n });\n\n return;\n }\n throw new ValidationError(expected, received, ctx.pathToError, message);\n}\n"],"mappings":";AAEO,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;AAE7C,SAAS,oBAAoB,UAAkB,cAA+C;AAC5F,QAAM,QAAQ;AACd,SAAO,SAAS,QAAQ,OAAO,CAAC,GAAG,QAAQ;AACzC,UAAM,MAAM,OAAO,eAAe,GAAG,aAAa,GAAG,CAAW,KAAK,KAAK,GAAG;AAC7E,WAAO;AAAA,EACT,CAAC;AACH;AAEO,SAAS,eACd,UACA,UACA,KACA,YACc;AACd,QAAM,aAAa,IAAI,EAAE,UAAU,KAAK;AACxC,QAAM,UAAU,oBAAoB,YAAY,EAAE,GAAG,UAAU,GAAG,UAAU,GAAG,IAAI,YAAY,CAAC;AAEhG,MAAI,IAAI,cAAc;AACpB,QAAI,OAAO,KAAK;AAAA,MACd;AAAA,MACA;AAAA,MACA,aAAa,IAAI;AAAA,MACjB;AAAA,IACF,CAAC;AAED;AAAA,EACF;AACA,QAAM,IAAI,gBAAgB,UAAU,UAAU,IAAI,aAAa,OAAO;AACxE;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/BooleanSchema.ts"],"sourcesContent":["import { CommonSchema } from './CommonSchema';\nimport { guardException } from '../exceptions';\nimport { ExceptionContext } from '../commonTypes';\nimport { _setStrictType } from '../helpers/setStrictType';\n\nconst isBoolean = (expected: boolean) => (received: boolean, ctx: ExceptionContext) => {\n if (received !== expected) guardException(expected, received, ctx, 'c:isBoolean');\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 _setStrictType(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 _setStrictType(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":";;;;;;;;;;;AAKA,IAAM,YAAY,CAAC,aAAsB,CAAC,UAAmB,QAA0B;AACrF,MAAI,aAAa,SAAU,gBAAe,UAAU,UAAU,KAAK,aAAa;AAClF;AAEO,IAAM,gBAAN,cAA4B,aAAa;AAAA,EAC9C,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASX,WAAoC;AAClC,mBAAe,MAAM,IAAI;AACzB,WAAO,KAAK,OAAO,UAAU,IAAI,CAAC;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,YAAsC;AACpC,mBAAe,MAAM,KAAK;AAC1B,WAAO,KAAK,OAAO,UAAU,KAAK,CAAC;AAAA,EACrC;AACF;","names":[]}
|
package/lib/chunk-DPBE7TAQ.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ctxSymbol
|
|
3
|
-
} from "./chunk-PH2PMUZP.mjs";
|
|
4
|
-
|
|
5
|
-
// src/schemas/CommonSchema.ts
|
|
6
|
-
var CommonSchema = class {
|
|
7
|
-
[ctxSymbol];
|
|
8
|
-
constructor(ctx) {
|
|
9
|
-
this[ctxSymbol] = ctx;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @param validators - One or more custom validation functions.
|
|
13
|
-
* @returns {this} The schema instance with the added custom validation.
|
|
14
|
-
*/
|
|
15
|
-
custom(...validators) {
|
|
16
|
-
this[ctxSymbol].requiredValidations.push(...validators);
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Marks the schema as nullable, allowing the value to be `null`.
|
|
21
|
-
*
|
|
22
|
-
* @returns {WithNull<this>} The schema instance marked as nullable.
|
|
23
|
-
*/
|
|
24
|
-
nullable() {
|
|
25
|
-
this[ctxSymbol].isNullable = true;
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Marks the schema as optional, allowing the value to be `undefined`.
|
|
30
|
-
*
|
|
31
|
-
* @returns {WithUndefined<this>}} The schema instance marked as optional.
|
|
32
|
-
*/
|
|
33
|
-
optional() {
|
|
34
|
-
this[ctxSymbol].isOptional = true;
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
CommonSchema
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=chunk-DPBE7TAQ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/CommonSchema.ts"],"sourcesContent":["import { PrimitiveType, RequiredValidation } from '../commonTypes';\nimport { ctxSymbol } from '../helpers/core';\n\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport interface ValidatorContext {\n type: PrimitiveType[];\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}\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":";;;;;AAiBO,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-EGEHSELT.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkIRG4OQABjs = require('./chunk-IRG4OQAB.js');
|
|
4
|
-
|
|
5
|
-
// src/schemas/CommonSchema.ts
|
|
6
|
-
var CommonSchema = class {
|
|
7
|
-
|
|
8
|
-
constructor(ctx) {
|
|
9
|
-
this[_chunkIRG4OQABjs.ctxSymbol] = ctx;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @param validators - One or more custom validation functions.
|
|
13
|
-
* @returns {this} The schema instance with the added custom validation.
|
|
14
|
-
*/
|
|
15
|
-
custom(...validators) {
|
|
16
|
-
this[_chunkIRG4OQABjs.ctxSymbol].requiredValidations.push(...validators);
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Marks the schema as nullable, allowing the value to be `null`.
|
|
21
|
-
*
|
|
22
|
-
* @returns {WithNull<this>} The schema instance marked as nullable.
|
|
23
|
-
*/
|
|
24
|
-
nullable() {
|
|
25
|
-
this[_chunkIRG4OQABjs.ctxSymbol].isNullable = true;
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Marks the schema as optional, allowing the value to be `undefined`.
|
|
30
|
-
*
|
|
31
|
-
* @returns {WithUndefined<this>}} The schema instance marked as optional.
|
|
32
|
-
*/
|
|
33
|
-
optional() {
|
|
34
|
-
this[_chunkIRG4OQABjs.ctxSymbol].isOptional = true;
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
exports.CommonSchema = CommonSchema;
|
|
42
|
-
//# sourceMappingURL=chunk-EGEHSELT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-EGEHSELT.js","../src/schemas/CommonSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACaO,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;ADdA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-EGEHSELT.js","sourcesContent":[null,"import { PrimitiveType, RequiredValidation } from '../commonTypes';\nimport { ctxSymbol } from '../helpers/core';\n\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport interface ValidatorContext {\n type: PrimitiveType[];\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}\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-HDSGCAHH.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkWBERBAL4js = require('./chunk-WBERBAL4.js');
|
|
4
|
-
|
|
5
|
-
// src/asserts/boolean/index.ts
|
|
6
|
-
function boolean() {
|
|
7
|
-
return new (0, _chunkWBERBAL4js.BooleanSchema)({ type: ["boolean"], requiredValidations: [] });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.boolean = boolean;
|
|
13
|
-
//# sourceMappingURL=chunk-HDSGCAHH.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-HDSGCAHH.js","../src/asserts/boolean/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,OAAA,CAAA,EAAyB;AACvC,EAAA,OAAO,IAAI,mCAAA,CAAc,EAAE,IAAA,EAAM,CAAC,SAAS,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACzE;ADNA;AACA;AACE;AACF,0BAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-HDSGCAHH.js","sourcesContent":[null,"import { BooleanSchema } from '../../schemas/BooleanSchema';\n\n/**\n * Creates a new schema for validating boolean values.\n *\n * @returns {BooleanSchema} A new instance of `BooleanSchema` for validating booleans.\n *\n * @example\n * const schema = boolean();\n * parseOrFail(schema, true); // Validates successfully\n * parseOrFail(schema, 'true'); // Throws a validation error\n */\nexport function boolean(): BooleanSchema {\n return new BooleanSchema({ type: ['boolean'], requiredValidations: [] });\n}\n"]}
|
package/lib/chunk-IEUXIOL6.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkRRQOET3Xjs = require('./chunk-RRQOET3X.js');
|
|
4
|
-
|
|
5
|
-
// src/asserts/array/index.ts
|
|
6
|
-
function array(arraySchema) {
|
|
7
|
-
return new (0, _chunkRRQOET3Xjs.ArraySchema)({ type: [], requiredValidations: [] }, arraySchema);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.array = array;
|
|
13
|
-
//# sourceMappingURL=chunk-IEUXIOL6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-IEUXIOL6.js","../src/asserts/array/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACWO,SAAS,KAAA,CAA8B,WAAA,EAA8B;AAC1E,EAAA,OAAO,IAAI,iCAAA,CAAY,EAAE,IAAA,EAAM,CAAC,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAA,EAAG,WAAW,CAAA;AAC3E;ADTA;AACA;AACE;AACF,sBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-IEUXIOL6.js","sourcesContent":[null,"import { ArraySchema, WithArray } from '../../schemas/ArraySchema';\nimport { CommonSchema } from '../../schemas/CommonSchema';\n\n/**\n * Creates a new schema for validating arrays where each element must match the specified schema.\n *\n * @template T\n * @param {T} arraySchema - The schema that each element of the array must match.\n * @returns {WithArray<T>} A new instance of `ArraySchema` for validating arrays of elements that match the specified schema.\n *\n * @example\n * const schema = array(string());\n * parseOrFail(schema, ['hello', 'world']); // Validates successfully\n * parseOrFail(schema, ['hello', 123]); // Throws a validation error\n */\nexport function array<T extends CommonSchema>(arraySchema: T): WithArray<T> {\n return new ArraySchema({ type: [], requiredValidations: [] }, arraySchema) as WithArray<T>;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-IRG4OQAB.js","../src/helpers/core.ts"],"names":["schema"],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACJO,IAAM,UAAA,EAAY,MAAA,CAAO,eAAe,CAAA;AAMxC,SAAS,UAAA,CAAW,MAAA,EAAsB,aAAA,EAAwB,KAAA,EAAyB;AAChG,EAAA,MAAM,WAAA,EAAa,KAAA,CAAM,CAAA;AACzB,EAAA,MAAM,WAAA,EAAa,MAAA,CAAO,SAAS,CAAA;AACnC,EAAA,GAAA,CAAI,cAAA,IAAkB,KAAA,CAAA,EAAW;AAC/B,IAAA,GAAA,CAAI,CAAC,UAAA,CAAW,UAAA,EAAY,6CAAA,UAAe,EAAY,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,YAAY,CAAC,CAAA;AACrG,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,cAAA,IAAkB,IAAA,EAAM;AAC1B,IAAA,GAAA,CAAI,CAAC,UAAA,CAAW,UAAA,EAAY,6CAAA,UAAe,EAAY,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,YAAY,CAAC,CAAA;AACrG,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,UAAA,CAAW,KAAA,EAAO;AACpB,IAAA,GAAA,CAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,aAAa,CAAA,EAAG,OAAO,6CAAA,OAAe,EAAS,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,SAAS,CAAC,CAAA;AAC7G,IAAA,MAAMA,QAAAA,EAAS,UAAA,CAAW,KAAA;AAC1B,IAAA,MAAM,YAAA,EAAc,KAAA,CAAM,WAAA;AAC1B,IAAA,aAAA,CAAc,OAAA,CAAQ,CAAC,IAAA,EAAM,CAAA,EAAA,GAAM;AACjC,MAAA,UAAA,CAAWA,OAAAA,EAAQ,IAAA,EAAM,EAAE,GAAG,KAAA,EAAO,WAAA,EAAa,CAAA,EAAA;AACnD,IAAA;AAEM,IAAA;AACT,EAAA;AAEyB,EAAA;AAEF,EAAA;AACgC,IAAA;AACJ,IAAA;AAClB,IAAA;AAEe,IAAA;AACE,MAAA;AACH,QAAA;AACC,UAAA;AAC5C,MAAA;AACF,IAAA;AAE0B,IAAA;AACwB,IAAA;AAC8B,MAAA;AAChC,MAAA;AACd,QAAA;AACD,UAAA;AAC/B,MAAA;AAE0B,MAAA;AAC5B,IAAA;AAEO,IAAA;AACT,EAAA;AAE4B,EAAA;AACa,IAAA;AACa,MAAA;AACtD,EAAA;AAEwC,EAAA;AACC,IAAA;AACxC,EAAA;AAEM,EAAA;AACT;ADX0D;AACA;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-IRG4OQAB.js","sourcesContent":[null,"export const ctxSymbol = Symbol('contextSymbol');\n\nimport { ExceptionContext } from '../commonTypes';\nimport { guardException } from '../exceptions';\nimport type { CommonSchema } from '../schemas/CommonSchema';\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, exCtx: ExceptionContext) {\n const commonTmap = exCtx.t;\n const schemaData = schema[ctxSymbol];\n if (receivedValue === undefined) {\n if (!schemaData.isOptional) guardException('Required', receivedValue, exCtx, commonTmap['c:optional']);\n return receivedValue;\n }\n\n if (receivedValue === null) {\n if (!schemaData.isNullable) guardException('Not null', receivedValue, exCtx, commonTmap['c:nullable']);\n return receivedValue;\n }\n\n if (schemaData.array) {\n if (!Array.isArray(receivedValue)) return guardException('Array', receivedValue, exCtx, commonTmap['c:array']);\n const schema = schemaData.array;\n const pathToError = exCtx.pathToError;\n receivedValue.forEach((elem, i) => {\n innerCheck(schema, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });\n });\n\n return receivedValue;\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (schemaData.object) {\n if (typeOfVal !== 'object') guardException('Object', receivedValue, exCtx, commonTmap['c:objectType']);\n if (Array.isArray(receivedValue)) guardException('Object', receivedValue, exCtx, commonTmap['c:objectTypeAsArray']);\n const shapeSchema = schemaData.object;\n\n if (!schemaData.allowUnrecognizedObjectProps) {\n for (const keyPerReceivedValue of Object.keys(receivedValue)) {\n if (shapeSchema[keyPerReceivedValue] === undefined)\n guardException('Unrecognized property', keyPerReceivedValue, exCtx, commonTmap['c:unrecognizedProperty']);\n }\n }\n\n const pathToError = exCtx.pathToError;\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 guardException('Required', receivedObjectValuePropery, exCtx, commonTmap['c:requiredProperty']);\n }\n\n innerCheck(valueOfSchema, receivedObjectValuePropery, { ...exCtx, pathToError: `${pathToError}.${keyOfSchema}` });\n }\n\n return receivedValue;\n }\n\n if (schemaData.type.length) {\n if (!schemaData.type.includes(typeOfVal))\n guardException(schemaData.type, typeOfVal, exCtx, commonTmap['c:invalidType']);\n }\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\n return receivedValue;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-J4VKFJQK.js","../src/asserts/mix/equalTo.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACHA,IAAM,oBAAA,EAAsB,6CAAA;AAC5B,IAAM,gBAAA,EAAkB,WAAA;AAejB,IAAM,QAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AAC5C,EAAA,GAAA,CAAI,SAAA,IAAa,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,eAAe,CAAA;AACpF,CAAA;AAEF,OAAA,CAAQ,IAAA,EAAM,eAAA;AACd,OAAA,CAAQ,QAAA,EAAU,mBAAA;AAClB,iDAAA,OAA0B,CAAA;ADZ1B;AACA;AACE;AACF,0BAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-J4VKFJQK.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst equalToErrorMessage = 'The received value is not equal to expected';\nconst equalToErrorKey = 'm:equalTo';\n\n/**\n * @description Creates a custom assertion that checks if a value is equal to the expected value.\n * @notice It has already been implemented in the number 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 the expected value.\n * @example\n * const schema = number().custom(equalTo(5)); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:equalTo'\n */\nexport const equalTo =\n (expected: unknown): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (expected !== received) guardException(expected, received, ctx, equalToErrorKey);\n };\n\nequalTo.key = equalToErrorKey;\nequalTo.message = equalToErrorMessage;\nsetToDefaultLocale(equalTo);\n"]}
|
package/lib/chunk-JDGZCBXF.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ArraySchema
|
|
3
|
-
} from "./chunk-NDQM5OL4.mjs";
|
|
4
|
-
|
|
5
|
-
// src/asserts/array/index.ts
|
|
6
|
-
function array(arraySchema) {
|
|
7
|
-
return new ArraySchema({ type: [], requiredValidations: [] }, arraySchema);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
array
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=chunk-JDGZCBXF.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/array/index.ts"],"sourcesContent":["import { ArraySchema, WithArray } from '../../schemas/ArraySchema';\nimport { CommonSchema } from '../../schemas/CommonSchema';\n\n/**\n * Creates a new schema for validating arrays where each element must match the specified schema.\n *\n * @template T\n * @param {T} arraySchema - The schema that each element of the array must match.\n * @returns {WithArray<T>} A new instance of `ArraySchema` for validating arrays of elements that match the specified schema.\n *\n * @example\n * const schema = array(string());\n * parseOrFail(schema, ['hello', 'world']); // Validates successfully\n * parseOrFail(schema, ['hello', 123]); // Throws a validation error\n */\nexport function array<T extends CommonSchema>(arraySchema: T): WithArray<T> {\n return new ArraySchema({ type: [], requiredValidations: [] }, arraySchema) as WithArray<T>;\n}\n"],"mappings":";;;;;AAeO,SAAS,MAA8B,aAA8B;AAC1E,SAAO,IAAI,YAAY,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,EAAE,GAAG,WAAW;AAC3E;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/StringSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 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 - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, `'${expectedValue}'`);\n\n return this.custom(equalTo(expectedValue)) as WithString<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 * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(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":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,IAAI,aAAa,GAAG;AAEzC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,IAAI,EAAE,GAAG;AAAA,IACrC;AACA,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
|
package/lib/chunk-JSGZ7DKT.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkIRG4OQABjs = require('./chunk-IRG4OQAB.js');
|
|
4
|
-
|
|
5
|
-
// src/helpers/setStrictType.ts
|
|
6
|
-
function _setStrictType(that, val) {
|
|
7
|
-
that[_chunkIRG4OQABjs.ctxSymbol].strictType = true;
|
|
8
|
-
that[_chunkIRG4OQABjs.ctxSymbol].strictTypeValue = val;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports._setStrictType = _setStrictType;
|
|
14
|
-
//# sourceMappingURL=chunk-JSGZ7DKT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-KQKJASVB.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;ACZO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,OAAA,CAA0B,aAAA,EAAuC;AAC/D,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,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,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;ADYA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-KQKJASVB.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\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 _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 equalTo<Y extends number>(expectedValue: Y): WithNumber<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 WithNumber<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 oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<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 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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-LEQCDD66.js","../src/schemas/StringSchema.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;ACZO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,OAAA,CAA0B,aAAA,EAAuC;AAC/D,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,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,CAAG,CAAA;AAEzC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA;AAAA,MACE,IAAA;AAAA,MACA,aAAA,CAAc,GAAA,CAAI,CAAC,EAAA,EAAA,GAAO,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG;AAAA,IACrC,CAAA;AACA,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-LEQCDD66.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 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 - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, `'${expectedValue}'`);\n\n return this.custom(equalTo(expectedValue)) as WithString<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 * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(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-MRISXZQ4.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CommonSchema
|
|
3
|
-
} from "./chunk-DPBE7TAQ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/asserts/mix/index.ts
|
|
6
|
-
function oneOfTypes(valueTypes) {
|
|
7
|
-
return new CommonSchema({ type: valueTypes, requiredValidations: [] });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
oneOfTypes
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=chunk-MRISXZQ4.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/mix/index.ts"],"sourcesContent":["import { PrimitiveType } from '../../commonTypes';\nimport { CommonSchema, MapMixTypes, 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 * parseOrFail(schema, 'hello'); // Validates successfully\n * parseOrFail(schema, 42); // Validates successfully\n * parseOrFail(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":";;;;;AAgBO,SAAS,WAAsC,YAAwC;AAC5F,SAAO,IAAI,aAAa,EAAE,MAAM,YAAY,qBAAqB,CAAC,EAAE,CAAC;AACvE;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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 _array = 1;\n constructor(ctx: ValidatorContext, arraySchema: CommonSchema) {\n super(ctx);\n this.validateArrayEntry(arraySchema);\n this[ctxSymbol].array = arraySchema;\n }\n\n private validateArrayEntry(arraySchema: CommonSchema) {\n if (!arraySchema) throw new BuildSchemaError('Missing schema in array method');\n if (!(arraySchema instanceof CommonSchema)) throw new BuildSchemaError('Invalid schema in array method');\n }\n}\n\nexport type WithArray<Y extends CommonSchema> = ArraySchema & { validation_array: Y };\nexport type ExtractFromArray<T> = T extends WithArray<infer X> ? X : never;\n"],"mappings":";;;;;;;;;;;AAIO,IAAM,cAAN,cAA0B,aAAa;AAAA,EAC5C,SAAS;AAAA,EACT,YAAY,KAAuB,aAA2B;AAC5D,UAAM,GAAG;AACT,SAAK,mBAAmB,WAAW;AACnC,SAAK,SAAS,EAAE,QAAQ;AAAA,EAC1B;AAAA,EAEQ,mBAAmB,aAA2B;AACpD,QAAI,CAAC,YAAa,OAAM,IAAI,iBAAiB,gCAAgC;AAC7E,QAAI,EAAE,uBAAuB,cAAe,OAAM,IAAI,iBAAiB,gCAAgC;AAAA,EACzG;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/mix/equalTo.ts"],"sourcesContent":["import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst equalToErrorMessage = 'The received value is not equal to expected';\nconst equalToErrorKey = 'm:equalTo';\n\n/**\n * @description Creates a custom assertion that checks if a value is equal to the expected value.\n * @notice It has already been implemented in the number 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 the expected value.\n * @example\n * const schema = number().custom(equalTo(5)); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:equalTo'\n */\nexport const equalTo =\n (expected: unknown): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (expected !== received) guardException(expected, received, ctx, equalToErrorKey);\n };\n\nequalTo.key = equalToErrorKey;\nequalTo.message = equalToErrorMessage;\nsetToDefaultLocale(equalTo);\n"],"mappings":";;;;;;;;AAIA,IAAM,sBAAsB;AAC5B,IAAM,kBAAkB;AAejB,IAAM,UACX,CAAC,aACD,CAAC,UAAmB,QAA0B;AAC5C,MAAI,aAAa,SAAU,gBAAe,UAAU,UAAU,KAAK,eAAe;AACpF;AAEF,QAAQ,MAAM;AACd,QAAQ,UAAU;AAClB,mBAAmB,OAAO;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/NumberSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\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 _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 equalTo<Y extends number>(expectedValue: Y): WithNumber<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 WithNumber<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 oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<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 WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helpers/core.ts"],"sourcesContent":["export const ctxSymbol = Symbol('contextSymbol');\n\nimport { ExceptionContext } from '../commonTypes';\nimport { guardException } from '../exceptions';\nimport type { CommonSchema } from '../schemas/CommonSchema';\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, exCtx: ExceptionContext) {\n const commonTmap = exCtx.t;\n const schemaData = schema[ctxSymbol];\n if (receivedValue === undefined) {\n if (!schemaData.isOptional) guardException('Required', receivedValue, exCtx, commonTmap['c:optional']);\n return receivedValue;\n }\n\n if (receivedValue === null) {\n if (!schemaData.isNullable) guardException('Not null', receivedValue, exCtx, commonTmap['c:nullable']);\n return receivedValue;\n }\n\n if (schemaData.array) {\n if (!Array.isArray(receivedValue)) return guardException('Array', receivedValue, exCtx, commonTmap['c:array']);\n const schema = schemaData.array;\n const pathToError = exCtx.pathToError;\n receivedValue.forEach((elem, i) => {\n innerCheck(schema, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });\n });\n\n return receivedValue;\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (schemaData.object) {\n if (typeOfVal !== 'object') guardException('Object', receivedValue, exCtx, commonTmap['c:objectType']);\n if (Array.isArray(receivedValue)) guardException('Object', receivedValue, exCtx, commonTmap['c:objectTypeAsArray']);\n const shapeSchema = schemaData.object;\n\n if (!schemaData.allowUnrecognizedObjectProps) {\n for (const keyPerReceivedValue of Object.keys(receivedValue)) {\n if (shapeSchema[keyPerReceivedValue] === undefined)\n guardException('Unrecognized property', keyPerReceivedValue, exCtx, commonTmap['c:unrecognizedProperty']);\n }\n }\n\n const pathToError = exCtx.pathToError;\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 guardException('Required', receivedObjectValuePropery, exCtx, commonTmap['c:requiredProperty']);\n }\n\n innerCheck(valueOfSchema, receivedObjectValuePropery, { ...exCtx, pathToError: `${pathToError}.${keyOfSchema}` });\n }\n\n return receivedValue;\n }\n\n if (schemaData.type.length) {\n if (!schemaData.type.includes(typeOfVal))\n guardException(schemaData.type, typeOfVal, exCtx, commonTmap['c:invalidType']);\n }\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\n return receivedValue;\n}\n"],"mappings":";;;;;AAAO,IAAM,YAAY,OAAO,eAAe;AAMxC,SAAS,WAAW,QAAsB,eAAwB,OAAyB;AAChG,QAAM,aAAa,MAAM;AACzB,QAAM,aAAa,OAAO,SAAS;AACnC,MAAI,kBAAkB,QAAW;AAC/B,QAAI,CAAC,WAAW,WAAY,gBAAe,YAAY,eAAe,OAAO,WAAW,YAAY,CAAC;AACrG,WAAO;AAAA,EACT;AAEA,MAAI,kBAAkB,MAAM;AAC1B,QAAI,CAAC,WAAW,WAAY,gBAAe,YAAY,eAAe,OAAO,WAAW,YAAY,CAAC;AACrG,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,OAAO;AACpB,QAAI,CAAC,MAAM,QAAQ,aAAa,EAAG,QAAO,eAAe,SAAS,eAAe,OAAO,WAAW,SAAS,CAAC;AAC7G,UAAMA,UAAS,WAAW;AAC1B,UAAM,cAAc,MAAM;AAC1B,kBAAc,QAAQ,CAAC,MAAM,MAAM;AACjC,iBAAWA,SAAQ,MAAM,EAAE,GAAG,OAAO,aAAa,GAAG,WAAW,IAAI,CAAC,IAAI,CAAC;AAAA,IAC5E,CAAC;AAED,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO;AAEzB,MAAI,WAAW,QAAQ;AACrB,QAAI,cAAc,SAAU,gBAAe,UAAU,eAAe,OAAO,WAAW,cAAc,CAAC;AACrG,QAAI,MAAM,QAAQ,aAAa,EAAG,gBAAe,UAAU,eAAe,OAAO,WAAW,qBAAqB,CAAC;AAClH,UAAM,cAAc,WAAW;AAE/B,QAAI,CAAC,WAAW,8BAA8B;AAC5C,iBAAW,uBAAuB,OAAO,KAAK,aAAa,GAAG;AAC5D,YAAI,YAAY,mBAAmB,MAAM;AACvC,yBAAe,yBAAyB,qBAAqB,OAAO,WAAW,wBAAwB,CAAC;AAAA,MAC5G;AAAA,IACF;AAEA,UAAM,cAAc,MAAM;AAC1B,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,yBAAe,YAAY,4BAA4B,OAAO,WAAW,oBAAoB,CAAC;AAAA,MAClG;AAEA,iBAAW,eAAe,4BAA4B,EAAE,GAAG,OAAO,aAAa,GAAG,WAAW,IAAI,WAAW,GAAG,CAAC;AAAA,IAClH;AAEA,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,KAAK,QAAQ;AAC1B,QAAI,CAAC,WAAW,KAAK,SAAS,SAAS;AACrC,qBAAe,WAAW,MAAM,WAAW,OAAO,WAAW,eAAe,CAAC;AAAA,EACjF;AAEA,aAAW,oBAAoB,QAAQ,CAAC,uBAAuB;AAC7D,uBAAmB,eAAe,KAAK;AAAA,EACzC,CAAC;AAED,SAAO;AACT;","names":["schema"]}
|
package/lib/chunk-PXBAS3GA.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NumberSchema
|
|
3
|
-
} from "./chunk-P7IXNCJG.mjs";
|
|
4
|
-
|
|
5
|
-
// src/asserts/number/index.ts
|
|
6
|
-
function number() {
|
|
7
|
-
return new NumberSchema({ type: ["number"], requiredValidations: [] });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
number
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=chunk-PXBAS3GA.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/number/index.ts"],"sourcesContent":["import { NumberSchema } from '../../schemas/NumberSchema';\n\n/**\n * Creates a new schema for validating number values.\n *\n * @returns {NumberSchema} A new instance of `NumberSchema` for validating numbers.\n *\n * @example\n * const schema = number();\n * parseOrFail(schema, 42); // Validates successfully\n * parseOrFail(schema, '42'); // Throws a validation error\n */\nexport function number(): NumberSchema {\n return new NumberSchema({ type: ['number'], requiredValidations: [] });\n}\n"],"mappings":";;;;;AAYO,SAAS,SAAuB;AACrC,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,QAAQ,GAAG,qBAAqB,CAAC,EAAE,CAAC;AACvE;","names":[]}
|
package/lib/chunk-QQNQ4IDN.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkEGEHSELTjs = require('./chunk-EGEHSELT.js');
|
|
4
|
-
|
|
5
|
-
// src/asserts/mix/index.ts
|
|
6
|
-
function oneOfTypes(valueTypes) {
|
|
7
|
-
return new (0, _chunkEGEHSELTjs.CommonSchema)({ type: valueTypes, requiredValidations: [] });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.oneOfTypes = oneOfTypes;
|
|
13
|
-
//# sourceMappingURL=chunk-QQNQ4IDN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-QQNQ4IDN.js","../src/asserts/mix/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACYO,SAAS,UAAA,CAAsC,UAAA,EAAwC;AAC5F,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,UAAA,EAAY,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADVA;AACA;AACE;AACF,gCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-QQNQ4IDN.js","sourcesContent":[null,"import { PrimitiveType } from '../../commonTypes';\nimport { CommonSchema, MapMixTypes, 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 * parseOrFail(schema, 'hello'); // Validates successfully\n * parseOrFail(schema, 42); // Validates successfully\n * parseOrFail(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-RD6TBCPQ.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkKQKJASVBjs = require('./chunk-KQKJASVB.js');
|
|
4
|
-
|
|
5
|
-
// src/asserts/number/index.ts
|
|
6
|
-
function number() {
|
|
7
|
-
return new (0, _chunkKQKJASVBjs.NumberSchema)({ type: ["number"], requiredValidations: [] });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.number = number;
|
|
13
|
-
//# sourceMappingURL=chunk-RD6TBCPQ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-RD6TBCPQ.js","../src/asserts/number/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,MAAA,CAAA,EAAuB;AACrC,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADNA;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-RD6TBCPQ.js","sourcesContent":[null,"import { NumberSchema } from '../../schemas/NumberSchema';\n\n/**\n * Creates a new schema for validating number values.\n *\n * @returns {NumberSchema} A new instance of `NumberSchema` for validating numbers.\n *\n * @example\n * const schema = number();\n * parseOrFail(schema, 42); // Validates successfully\n * parseOrFail(schema, '42'); // Throws a validation error\n */\nexport function number(): NumberSchema {\n return new NumberSchema({ type: ['number'], requiredValidations: [] });\n}\n"]}
|
package/lib/chunk-RRQOET3X.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
-
|
|
3
|
-
var _chunkEGEHSELTjs = require('./chunk-EGEHSELT.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkIRG4OQABjs = require('./chunk-IRG4OQAB.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
|
|
10
|
-
|
|
11
|
-
// src/schemas/ArraySchema.ts
|
|
12
|
-
var ArraySchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {
|
|
13
|
-
__init() {this._array = 1}
|
|
14
|
-
constructor(ctx, arraySchema) {
|
|
15
|
-
super(ctx);_class.prototype.__init.call(this);;
|
|
16
|
-
this.validateArrayEntry(arraySchema);
|
|
17
|
-
this[_chunkIRG4OQABjs.ctxSymbol].array = arraySchema;
|
|
18
|
-
}
|
|
19
|
-
validateArrayEntry(arraySchema) {
|
|
20
|
-
if (!arraySchema) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Missing schema in array method");
|
|
21
|
-
if (!(arraySchema instanceof _chunkEGEHSELTjs.CommonSchema)) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Invalid schema in array method");
|
|
22
|
-
}
|
|
23
|
-
}, _class);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
exports.ArraySchema = ArraySchema;
|
|
28
|
-
//# sourceMappingURL=chunk-RRQOET3X.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-RRQOET3X.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-RRQOET3X.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/ObjectSchema.ts"],"sourcesContent":["import { ctxSymbol } from '../helpers/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 /**\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\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBO,oBAA0B;AAC/B,SAAK,SAAS,EAAE,+BAA+B;AAC/C,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/lib/chunk-TKZ6FLLR.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkLEQCDD66js = require('./chunk-LEQCDD66.js');
|
|
4
|
-
|
|
5
|
-
// src/asserts/string/index.ts
|
|
6
|
-
function string() {
|
|
7
|
-
return new (0, _chunkLEQCDD66js.StringSchema)({ type: ["string"], requiredValidations: [] });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.string = string;
|
|
13
|
-
//# sourceMappingURL=chunk-TKZ6FLLR.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-TKZ6FLLR.js","../src/asserts/string/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,MAAA,CAAA,EAAuB;AACrC,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADNA;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-TKZ6FLLR.js","sourcesContent":[null,"import { StringSchema } from '../../schemas/StringSchema';\n\n/**\n * Creates a new schema for validating string values.\n *\n * @returns {StringSchema} A new instance of `StringSchema` for validating strings.\n *\n * @example\n * const schema = string();\n * parseOrFail(schema, 'hello'); // Validates successfully\n * parseOrFail(schema, 123); // Throws a validation error\n */\nexport function string(): StringSchema {\n return new StringSchema({ type: ['string'], requiredValidations: [] });\n}\n"]}
|
package/lib/chunk-VHEA4JZ5.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunk6TH3DBDKjs = require('./chunk-6TH3DBDK.js');
|
|
4
|
-
|
|
5
|
-
// src/asserts/object/index.ts
|
|
6
|
-
function object(shapeSchema) {
|
|
7
|
-
return new (0, _chunk6TH3DBDKjs.ObjectSchema)({ type: [], requiredValidations: [] }, shapeSchema);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.object = object;
|
|
13
|
-
//# sourceMappingURL=chunk-VHEA4JZ5.js.map
|