bguard 0.4.1 → 0.6.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 +91 -9
- package/lib/InferType.d.mts +1 -1
- package/lib/InferType.d.ts +1 -1
- package/lib/asserts/array/index.d.mts +7 -2
- package/lib/asserts/array/index.d.ts +7 -2
- package/lib/asserts/array/index.js +6 -12
- package/lib/asserts/array/index.js.map +1 -1
- package/lib/asserts/array/index.mjs +6 -12
- package/lib/asserts/array/index.mjs.map +1 -1
- package/lib/asserts/array/maxArrayLength.d.mts +4 -1
- package/lib/asserts/array/maxArrayLength.d.ts +4 -1
- package/lib/asserts/array/maxArrayLength.js +4 -15
- package/lib/asserts/array/maxArrayLength.js.map +1 -1
- package/lib/asserts/array/maxArrayLength.mjs +4 -15
- package/lib/asserts/array/maxArrayLength.mjs.map +1 -1
- package/lib/asserts/array/minArrayLength.d.mts +4 -1
- package/lib/asserts/array/minArrayLength.d.ts +4 -1
- package/lib/asserts/array/minArrayLength.js +4 -15
- package/lib/asserts/array/minArrayLength.js.map +1 -1
- package/lib/asserts/array/minArrayLength.mjs +4 -15
- package/lib/asserts/array/minArrayLength.mjs.map +1 -1
- package/lib/asserts/bigint/bigintMax.d.mts +4 -1
- package/lib/asserts/bigint/bigintMax.d.ts +4 -1
- package/lib/asserts/bigint/bigintMax.js +4 -15
- package/lib/asserts/bigint/bigintMax.js.map +1 -1
- package/lib/asserts/bigint/bigintMax.mjs +4 -15
- package/lib/asserts/bigint/bigintMax.mjs.map +1 -1
- package/lib/asserts/bigint/bigintMaxExcluded.d.mts +4 -1
- package/lib/asserts/bigint/bigintMaxExcluded.d.ts +4 -1
- package/lib/asserts/bigint/bigintMaxExcluded.js +4 -15
- package/lib/asserts/bigint/bigintMaxExcluded.js.map +1 -1
- package/lib/asserts/bigint/bigintMaxExcluded.mjs +4 -15
- package/lib/asserts/bigint/bigintMaxExcluded.mjs.map +1 -1
- package/lib/asserts/bigint/bigintMin.d.mts +4 -1
- package/lib/asserts/bigint/bigintMin.d.ts +4 -1
- package/lib/asserts/bigint/bigintMin.js +4 -15
- package/lib/asserts/bigint/bigintMin.js.map +1 -1
- package/lib/asserts/bigint/bigintMin.mjs +4 -15
- package/lib/asserts/bigint/bigintMin.mjs.map +1 -1
- package/lib/asserts/bigint/bigintMinExcluded.d.mts +4 -1
- package/lib/asserts/bigint/bigintMinExcluded.d.ts +4 -1
- package/lib/asserts/bigint/bigintMinExcluded.js +4 -15
- package/lib/asserts/bigint/bigintMinExcluded.js.map +1 -1
- package/lib/asserts/bigint/bigintMinExcluded.mjs +4 -15
- package/lib/asserts/bigint/bigintMinExcluded.mjs.map +1 -1
- package/lib/asserts/bigint/index.d.mts +30 -3
- package/lib/asserts/bigint/index.d.ts +30 -3
- package/lib/asserts/bigint/index.js +9 -16
- package/lib/asserts/bigint/index.js.map +1 -1
- package/lib/asserts/bigint/index.mjs +9 -16
- package/lib/asserts/bigint/index.mjs.map +1 -1
- package/lib/asserts/boolean/index.d.mts +25 -2
- package/lib/asserts/boolean/index.d.ts +25 -2
- package/lib/asserts/boolean/index.js +7 -13
- package/lib/asserts/boolean/index.js.map +1 -1
- package/lib/asserts/boolean/index.mjs +7 -13
- package/lib/asserts/boolean/index.mjs.map +1 -1
- package/lib/asserts/date/dateMax.d.mts +4 -1
- package/lib/asserts/date/dateMax.d.ts +4 -1
- package/lib/asserts/date/dateMax.js +5 -23
- package/lib/asserts/date/dateMax.js.map +1 -1
- package/lib/asserts/date/dateMax.mjs +5 -23
- package/lib/asserts/date/dateMax.mjs.map +1 -1
- package/lib/asserts/date/dateMin.d.mts +4 -1
- package/lib/asserts/date/dateMin.d.ts +4 -1
- package/lib/asserts/date/dateMin.js +5 -23
- package/lib/asserts/date/dateMin.js.map +1 -1
- package/lib/asserts/date/dateMin.mjs +5 -23
- package/lib/asserts/date/dateMin.mjs.map +1 -1
- package/lib/asserts/date/index.d.mts +6 -2
- package/lib/asserts/date/index.d.ts +6 -2
- package/lib/asserts/date/index.js +6 -12
- package/lib/asserts/date/index.js.map +1 -1
- package/lib/asserts/date/index.mjs +6 -12
- package/lib/asserts/date/index.mjs.map +1 -1
- package/lib/asserts/mix/equalTo.d.mts +4 -1
- package/lib/asserts/mix/equalTo.d.ts +4 -1
- package/lib/asserts/mix/equalTo.js +4 -4
- package/lib/asserts/mix/equalTo.mjs +3 -3
- package/lib/asserts/mix/index.d.mts +3 -3
- package/lib/asserts/mix/index.d.ts +3 -3
- package/lib/asserts/mix/index.js +6 -11
- package/lib/asserts/mix/index.js.map +1 -1
- package/lib/asserts/mix/index.mjs +6 -11
- package/lib/asserts/mix/index.mjs.map +1 -1
- package/lib/asserts/mix/oneOfValues.d.mts +4 -1
- package/lib/asserts/mix/oneOfValues.d.ts +4 -1
- package/lib/asserts/mix/oneOfValues.js +4 -4
- package/lib/asserts/mix/oneOfValues.mjs +3 -3
- package/lib/asserts/number/index.d.mts +28 -2
- package/lib/asserts/number/index.d.ts +28 -2
- package/lib/asserts/number/index.js +9 -16
- package/lib/asserts/number/index.js.map +1 -1
- package/lib/asserts/number/index.mjs +9 -16
- package/lib/asserts/number/index.mjs.map +1 -1
- package/lib/asserts/number/max.d.mts +4 -1
- package/lib/asserts/number/max.d.ts +4 -1
- package/lib/asserts/number/max.js +4 -15
- package/lib/asserts/number/max.js.map +1 -1
- package/lib/asserts/number/max.mjs +4 -15
- package/lib/asserts/number/max.mjs.map +1 -1
- package/lib/asserts/number/maxExcluded.d.mts +4 -1
- package/lib/asserts/number/maxExcluded.d.ts +4 -1
- package/lib/asserts/number/maxExcluded.js +4 -15
- package/lib/asserts/number/maxExcluded.js.map +1 -1
- package/lib/asserts/number/maxExcluded.mjs +4 -15
- package/lib/asserts/number/maxExcluded.mjs.map +1 -1
- package/lib/asserts/number/min.d.mts +4 -1
- package/lib/asserts/number/min.d.ts +4 -1
- package/lib/asserts/number/min.js +4 -15
- package/lib/asserts/number/min.js.map +1 -1
- package/lib/asserts/number/min.mjs +4 -15
- package/lib/asserts/number/min.mjs.map +1 -1
- package/lib/asserts/number/minExcluded.d.mts +4 -1
- package/lib/asserts/number/minExcluded.d.ts +4 -1
- package/lib/asserts/number/minExcluded.js +4 -15
- package/lib/asserts/number/minExcluded.js.map +1 -1
- package/lib/asserts/number/minExcluded.mjs +4 -15
- package/lib/asserts/number/minExcluded.mjs.map +1 -1
- package/lib/asserts/number/negative.d.mts +4 -1
- package/lib/asserts/number/negative.d.ts +4 -1
- package/lib/asserts/number/negative.js +4 -15
- package/lib/asserts/number/negative.js.map +1 -1
- package/lib/asserts/number/negative.mjs +4 -15
- package/lib/asserts/number/negative.mjs.map +1 -1
- package/lib/asserts/number/positive.d.mts +4 -1
- package/lib/asserts/number/positive.d.ts +4 -1
- package/lib/asserts/number/positive.js +4 -15
- package/lib/asserts/number/positive.js.map +1 -1
- package/lib/asserts/number/positive.mjs +4 -15
- package/lib/asserts/number/positive.mjs.map +1 -1
- package/lib/asserts/object/index.d.mts +26 -2
- package/lib/asserts/object/index.d.ts +26 -2
- package/lib/asserts/object/index.js +6 -12
- package/lib/asserts/object/index.js.map +1 -1
- package/lib/asserts/object/index.mjs +6 -12
- package/lib/asserts/object/index.mjs.map +1 -1
- package/lib/asserts/object/maxKeys.d.mts +4 -1
- package/lib/asserts/object/maxKeys.d.ts +4 -1
- package/lib/asserts/object/maxKeys.js +4 -18
- package/lib/asserts/object/maxKeys.js.map +1 -1
- package/lib/asserts/object/maxKeys.mjs +4 -18
- package/lib/asserts/object/maxKeys.mjs.map +1 -1
- package/lib/asserts/string/atLeastOneDigit.d.mts +4 -1
- package/lib/asserts/string/atLeastOneDigit.d.ts +4 -1
- package/lib/asserts/string/atLeastOneDigit.js +4 -16
- package/lib/asserts/string/atLeastOneDigit.js.map +1 -1
- package/lib/asserts/string/atLeastOneDigit.mjs +4 -16
- package/lib/asserts/string/atLeastOneDigit.mjs.map +1 -1
- package/lib/asserts/string/atLeastOneLowerChar.d.mts +4 -1
- package/lib/asserts/string/atLeastOneLowerChar.d.ts +4 -1
- package/lib/asserts/string/atLeastOneLowerChar.js +4 -17
- package/lib/asserts/string/atLeastOneLowerChar.js.map +1 -1
- package/lib/asserts/string/atLeastOneLowerChar.mjs +4 -17
- package/lib/asserts/string/atLeastOneLowerChar.mjs.map +1 -1
- package/lib/asserts/string/atLeastOneSpecialChar.d.mts +5 -2
- package/lib/asserts/string/atLeastOneSpecialChar.d.ts +5 -2
- package/lib/asserts/string/atLeastOneSpecialChar.js +5 -22
- package/lib/asserts/string/atLeastOneSpecialChar.js.map +1 -1
- package/lib/asserts/string/atLeastOneSpecialChar.mjs +4 -21
- package/lib/asserts/string/atLeastOneSpecialChar.mjs.map +1 -1
- package/lib/asserts/string/atLeastOneUpperChar.d.mts +4 -1
- package/lib/asserts/string/atLeastOneUpperChar.d.ts +4 -1
- package/lib/asserts/string/atLeastOneUpperChar.js +4 -17
- package/lib/asserts/string/atLeastOneUpperChar.js.map +1 -1
- package/lib/asserts/string/atLeastOneUpperChar.mjs +4 -17
- package/lib/asserts/string/atLeastOneUpperChar.mjs.map +1 -1
- package/lib/asserts/string/contains.d.mts +4 -1
- package/lib/asserts/string/contains.d.ts +4 -1
- package/lib/asserts/string/contains.js +4 -17
- package/lib/asserts/string/contains.js.map +1 -1
- package/lib/asserts/string/contains.mjs +4 -17
- package/lib/asserts/string/contains.mjs.map +1 -1
- package/lib/asserts/string/email.d.mts +4 -1
- package/lib/asserts/string/email.d.ts +4 -1
- package/lib/asserts/string/email.js +4 -16
- package/lib/asserts/string/email.js.map +1 -1
- package/lib/asserts/string/email.mjs +4 -16
- package/lib/asserts/string/email.mjs.map +1 -1
- package/lib/asserts/string/endsWith.d.mts +4 -1
- package/lib/asserts/string/endsWith.d.ts +4 -1
- package/lib/asserts/string/endsWith.js +4 -17
- package/lib/asserts/string/endsWith.js.map +1 -1
- package/lib/asserts/string/endsWith.mjs +4 -17
- package/lib/asserts/string/endsWith.mjs.map +1 -1
- package/lib/asserts/string/index.d.mts +29 -2
- package/lib/asserts/string/index.d.ts +29 -2
- package/lib/asserts/string/index.js +9 -16
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +9 -16
- package/lib/asserts/string/index.mjs.map +1 -1
- package/lib/asserts/string/isValidDate.d.mts +4 -1
- package/lib/asserts/string/isValidDate.d.ts +4 -1
- package/lib/asserts/string/isValidDate.js +4 -20
- package/lib/asserts/string/isValidDate.js.map +1 -1
- package/lib/asserts/string/isValidDate.mjs +4 -20
- package/lib/asserts/string/isValidDate.mjs.map +1 -1
- package/lib/asserts/string/isValidDateTime.d.mts +4 -1
- package/lib/asserts/string/isValidDateTime.d.ts +4 -1
- package/lib/asserts/string/isValidDateTime.js +4 -27
- package/lib/asserts/string/isValidDateTime.js.map +1 -1
- package/lib/asserts/string/isValidDateTime.mjs +4 -27
- package/lib/asserts/string/isValidDateTime.mjs.map +1 -1
- package/lib/asserts/string/isValidTime.d.mts +4 -1
- package/lib/asserts/string/isValidTime.d.ts +4 -1
- package/lib/asserts/string/isValidTime.js +4 -27
- package/lib/asserts/string/isValidTime.js.map +1 -1
- package/lib/asserts/string/isValidTime.mjs +4 -27
- package/lib/asserts/string/isValidTime.mjs.map +1 -1
- package/lib/asserts/string/lowerCase.d.mts +4 -1
- package/lib/asserts/string/lowerCase.d.ts +4 -1
- package/lib/asserts/string/lowerCase.js +4 -15
- package/lib/asserts/string/lowerCase.js.map +1 -1
- package/lib/asserts/string/lowerCase.mjs +4 -15
- package/lib/asserts/string/lowerCase.mjs.map +1 -1
- package/lib/asserts/string/maxLength.d.mts +4 -1
- package/lib/asserts/string/maxLength.d.ts +4 -1
- package/lib/asserts/string/maxLength.js +4 -15
- package/lib/asserts/string/maxLength.js.map +1 -1
- package/lib/asserts/string/maxLength.mjs +4 -15
- package/lib/asserts/string/maxLength.mjs.map +1 -1
- package/lib/asserts/string/minLength.d.mts +4 -1
- package/lib/asserts/string/minLength.d.ts +4 -1
- package/lib/asserts/string/minLength.js +4 -15
- package/lib/asserts/string/minLength.js.map +1 -1
- package/lib/asserts/string/minLength.mjs +4 -15
- package/lib/asserts/string/minLength.mjs.map +1 -1
- package/lib/asserts/string/regExp.d.mts +4 -1
- package/lib/asserts/string/regExp.d.ts +4 -1
- package/lib/asserts/string/regExp.js +4 -15
- package/lib/asserts/string/regExp.js.map +1 -1
- package/lib/asserts/string/regExp.mjs +4 -15
- package/lib/asserts/string/regExp.mjs.map +1 -1
- package/lib/asserts/string/startsWith.d.mts +4 -1
- package/lib/asserts/string/startsWith.d.ts +4 -1
- package/lib/asserts/string/startsWith.js +4 -17
- package/lib/asserts/string/startsWith.js.map +1 -1
- package/lib/asserts/string/startsWith.mjs +4 -17
- package/lib/asserts/string/startsWith.mjs.map +1 -1
- package/lib/asserts/string/upperCase.d.mts +4 -1
- package/lib/asserts/string/upperCase.d.ts +4 -1
- package/lib/asserts/string/upperCase.js +4 -17
- package/lib/asserts/string/upperCase.js.map +1 -1
- package/lib/asserts/string/upperCase.mjs +4 -17
- package/lib/asserts/string/upperCase.mjs.map +1 -1
- package/lib/asserts/string/uuid.d.mts +4 -1
- package/lib/asserts/string/uuid.d.ts +4 -1
- package/lib/asserts/string/uuid.js +4 -18
- package/lib/asserts/string/uuid.js.map +1 -1
- package/lib/asserts/string/uuid.mjs +4 -18
- package/lib/asserts/string/uuid.mjs.map +1 -1
- package/lib/asserts/string/uuidV1.d.mts +4 -1
- package/lib/asserts/string/uuidV1.d.ts +4 -1
- package/lib/asserts/string/uuidV1.js +4 -18
- package/lib/asserts/string/uuidV1.js.map +1 -1
- package/lib/asserts/string/uuidV1.mjs +4 -18
- package/lib/asserts/string/uuidV1.mjs.map +1 -1
- package/lib/asserts/string/uuidV2.d.mts +4 -1
- package/lib/asserts/string/uuidV2.d.ts +4 -1
- package/lib/asserts/string/uuidV2.js +4 -18
- package/lib/asserts/string/uuidV2.js.map +1 -1
- package/lib/asserts/string/uuidV2.mjs +4 -18
- package/lib/asserts/string/uuidV2.mjs.map +1 -1
- package/lib/asserts/string/uuidV3.d.mts +4 -1
- package/lib/asserts/string/uuidV3.d.ts +4 -1
- package/lib/asserts/string/uuidV3.js +4 -18
- package/lib/asserts/string/uuidV3.js.map +1 -1
- package/lib/asserts/string/uuidV3.mjs +4 -18
- package/lib/asserts/string/uuidV3.mjs.map +1 -1
- package/lib/asserts/string/uuidV4.d.mts +4 -1
- package/lib/asserts/string/uuidV4.d.ts +4 -1
- package/lib/asserts/string/uuidV4.js +4 -18
- package/lib/asserts/string/uuidV4.js.map +1 -1
- package/lib/asserts/string/uuidV4.mjs +4 -18
- package/lib/asserts/string/uuidV4.mjs.map +1 -1
- package/lib/asserts/string/uuidV5.d.mts +4 -1
- package/lib/asserts/string/uuidV5.d.ts +4 -1
- package/lib/asserts/string/uuidV5.js +4 -18
- package/lib/asserts/string/uuidV5.js.map +1 -1
- package/lib/asserts/string/uuidV5.mjs +4 -18
- package/lib/asserts/string/uuidV5.mjs.map +1 -1
- package/lib/asserts/string/validUrl.d.mts +4 -1
- package/lib/asserts/string/validUrl.d.ts +4 -1
- package/lib/asserts/string/validUrl.js +4 -27
- package/lib/asserts/string/validUrl.js.map +1 -1
- package/lib/asserts/string/validUrl.mjs +4 -27
- package/lib/asserts/string/validUrl.mjs.map +1 -1
- package/lib/chunk-22254THF.mjs +21 -0
- package/lib/chunk-22254THF.mjs.map +1 -0
- package/lib/chunk-22VHHJSS.js +28 -0
- package/lib/chunk-22VHHJSS.js.map +1 -0
- package/lib/chunk-23QTSXPQ.js +18 -0
- package/lib/chunk-23QTSXPQ.js.map +1 -0
- package/lib/chunk-24LO7MNY.js +18 -0
- package/lib/chunk-24LO7MNY.js.map +1 -0
- package/lib/{chunk-ASZW6XRM.mjs → chunk-2ANPCB4O.mjs} +4 -2
- package/lib/{chunk-ASZW6XRM.mjs.map → chunk-2ANPCB4O.mjs.map} +1 -1
- package/lib/chunk-2D3HCTJV.js +18 -0
- package/lib/chunk-2D3HCTJV.js.map +1 -0
- package/lib/chunk-2ESDKTV4.js +18 -0
- package/lib/chunk-2ESDKTV4.js.map +1 -0
- package/lib/chunk-2HGS4STD.js +48 -0
- package/lib/chunk-2HGS4STD.js.map +1 -0
- package/lib/chunk-2IPGGARK.mjs +21 -0
- package/lib/chunk-2IPGGARK.mjs.map +1 -0
- package/lib/chunk-3W2COCXV.js +18 -0
- package/lib/chunk-3W2COCXV.js.map +1 -0
- package/lib/chunk-4N5J426R.mjs +20 -0
- package/lib/chunk-4N5J426R.mjs.map +1 -0
- package/lib/chunk-4UPXP4I3.js +25 -0
- package/lib/chunk-4UPXP4I3.js.map +1 -0
- package/lib/{chunk-C3EDEQ3W.mjs → chunk-4ZKU4RJL.mjs} +3 -6
- package/lib/chunk-4ZKU4RJL.mjs.map +1 -0
- package/lib/chunk-5NYVRFG3.mjs +48 -0
- package/lib/chunk-5NYVRFG3.mjs.map +1 -0
- package/lib/chunk-62EKGBXF.js +21 -0
- package/lib/chunk-62EKGBXF.js.map +1 -0
- package/lib/chunk-6JPYR2TS.js +23 -0
- package/lib/chunk-6JPYR2TS.js.map +1 -0
- package/lib/chunk-6LPQRAFN.js +30 -0
- package/lib/chunk-6LPQRAFN.js.map +1 -0
- package/lib/{chunk-LPR3G5T3.mjs → chunk-6WKSLMJG.mjs} +11 -8
- package/lib/chunk-6WKSLMJG.mjs.map +1 -0
- package/lib/chunk-7JL66G7G.mjs +20 -0
- package/lib/chunk-7JL66G7G.mjs.map +1 -0
- package/lib/chunk-AJHBPMZT.mjs +19 -0
- package/lib/chunk-AJHBPMZT.mjs.map +1 -0
- package/lib/chunk-AQCV7PB4.mjs +28 -0
- package/lib/chunk-AQCV7PB4.mjs.map +1 -0
- package/lib/chunk-ARIYSQMH.js +20 -0
- package/lib/chunk-ARIYSQMH.js.map +1 -0
- package/lib/{chunk-42J6CHIO.js → chunk-AXKX5BGH.js} +4 -2
- package/lib/chunk-AXKX5BGH.js.map +1 -0
- package/lib/chunk-BRFUFNU4.js +18 -0
- package/lib/chunk-BRFUFNU4.js.map +1 -0
- package/lib/chunk-C2VSTWID.js +18 -0
- package/lib/chunk-C2VSTWID.js.map +1 -0
- package/lib/chunk-C44KAKMR.js +21 -0
- package/lib/chunk-C44KAKMR.js.map +1 -0
- package/lib/chunk-D6G32F2K.js +69 -0
- package/lib/chunk-D6G32F2K.js.map +1 -0
- package/lib/chunk-DCPRPCZ3.js +20 -0
- package/lib/chunk-DCPRPCZ3.js.map +1 -0
- package/lib/{chunk-U4USIJV3.js → chunk-DED5KDLM.js} +20 -16
- package/lib/chunk-DED5KDLM.js.map +1 -0
- package/lib/chunk-DFYP4GKE.js +21 -0
- package/lib/chunk-DFYP4GKE.js.map +1 -0
- package/lib/chunk-ENZ5WDUQ.js +18 -0
- package/lib/chunk-ENZ5WDUQ.js.map +1 -0
- package/lib/chunk-FI737YZJ.js +19 -0
- package/lib/chunk-FI737YZJ.js.map +1 -0
- package/lib/chunk-FIDPCCCW.js +24 -0
- package/lib/chunk-FIDPCCCW.js.map +1 -0
- package/lib/chunk-GFWZQ4XW.mjs +30 -0
- package/lib/chunk-GFWZQ4XW.mjs.map +1 -0
- package/lib/chunk-GGWJJFXY.mjs +20 -0
- package/lib/chunk-GGWJJFXY.mjs.map +1 -0
- package/lib/chunk-H2M4FCRZ.mjs +21 -0
- package/lib/chunk-H2M4FCRZ.mjs.map +1 -0
- package/lib/chunk-H4OW6OUF.js +21 -0
- package/lib/chunk-H4OW6OUF.js.map +1 -0
- package/lib/chunk-HD37VXPZ.mjs +19 -0
- package/lib/chunk-HD37VXPZ.mjs.map +1 -0
- package/lib/chunk-HPIF2CMT.js +18 -0
- package/lib/chunk-HPIF2CMT.js.map +1 -0
- package/lib/chunk-HUWO5UKU.js +64 -0
- package/lib/chunk-HUWO5UKU.js.map +1 -0
- package/lib/chunk-HWVM4SYU.mjs +18 -0
- package/lib/chunk-HWVM4SYU.mjs.map +1 -0
- package/lib/chunk-IDDU6B6T.js +20 -0
- package/lib/chunk-IDDU6B6T.js.map +1 -0
- package/lib/chunk-KRCOKWAB.mjs +18 -0
- package/lib/chunk-KRCOKWAB.mjs.map +1 -0
- package/lib/chunk-LXZTBF7F.js +18 -0
- package/lib/chunk-LXZTBF7F.js.map +1 -0
- package/lib/chunk-M2GOQ7TZ.mjs +21 -0
- package/lib/chunk-M2GOQ7TZ.mjs.map +1 -0
- package/lib/{chunk-YUMUCQKL.mjs → chunk-M3HYPZLE.mjs} +15 -11
- package/lib/chunk-M3HYPZLE.mjs.map +1 -0
- package/lib/chunk-MCQHWS3E.mjs +18 -0
- package/lib/chunk-MCQHWS3E.mjs.map +1 -0
- package/lib/chunk-MHWPSQB3.js +20 -0
- package/lib/chunk-MHWPSQB3.js.map +1 -0
- package/lib/chunk-N3EHGKZV.mjs +25 -0
- package/lib/chunk-N3EHGKZV.mjs.map +1 -0
- package/lib/chunk-NBR3QGKW.js +23 -0
- package/lib/chunk-NBR3QGKW.js.map +1 -0
- package/lib/chunk-NFD7D5GZ.mjs +71 -0
- package/lib/chunk-NFD7D5GZ.mjs.map +1 -0
- package/lib/chunk-NOJB5GBZ.mjs +18 -0
- package/lib/chunk-NOJB5GBZ.mjs.map +1 -0
- package/lib/chunk-NS4GXUCA.mjs +18 -0
- package/lib/chunk-NS4GXUCA.mjs.map +1 -0
- package/lib/chunk-NY2TPU6O.mjs +18 -0
- package/lib/chunk-NY2TPU6O.mjs.map +1 -0
- package/lib/{chunk-H32B3NHW.mjs → chunk-OE3L7EKN.mjs} +3 -3
- package/lib/chunk-OE3L7EKN.mjs.map +1 -0
- package/lib/chunk-OFZMO7PB.mjs +18 -0
- package/lib/chunk-OFZMO7PB.mjs.map +1 -0
- package/lib/chunk-OHUOBIHX.mjs +52 -0
- package/lib/chunk-OHUOBIHX.mjs.map +1 -0
- package/lib/chunk-OMSHZITC.js +20 -0
- package/lib/chunk-OMSHZITC.js.map +1 -0
- package/lib/chunk-OQYS7JVF.js +28 -0
- package/lib/chunk-OQYS7JVF.js.map +1 -0
- package/lib/chunk-OSFIPFQ3.mjs +28 -0
- package/lib/chunk-OSFIPFQ3.mjs.map +1 -0
- package/lib/chunk-OU5BTUDV.mjs +23 -0
- package/lib/chunk-OU5BTUDV.mjs.map +1 -0
- package/lib/chunk-OZ3BTSSQ.mjs +64 -0
- package/lib/chunk-OZ3BTSSQ.mjs.map +1 -0
- package/lib/{chunk-IZ3CBVEE.js → chunk-PAV4SQQL.js} +4 -7
- package/lib/chunk-PAV4SQQL.js.map +1 -0
- package/lib/chunk-PNSDUVRE.mjs +21 -0
- package/lib/chunk-PNSDUVRE.mjs.map +1 -0
- package/lib/chunk-PVQALO2H.js +23 -0
- package/lib/chunk-PVQALO2H.js.map +1 -0
- package/lib/chunk-QEG24G7E.mjs +18 -0
- package/lib/chunk-QEG24G7E.mjs.map +1 -0
- package/lib/chunk-QIFA6S5U.mjs +18 -0
- package/lib/chunk-QIFA6S5U.mjs.map +1 -0
- package/lib/chunk-QIPGUTIG.mjs +302 -0
- package/lib/chunk-QIPGUTIG.mjs.map +1 -0
- package/lib/chunk-QMIH3A4D.js +18 -0
- package/lib/chunk-QMIH3A4D.js.map +1 -0
- package/lib/chunk-R25HSJPH.js +21 -0
- package/lib/chunk-R25HSJPH.js.map +1 -0
- package/lib/chunk-S4FWDTEW.mjs +20 -0
- package/lib/chunk-S4FWDTEW.mjs.map +1 -0
- package/lib/chunk-S5D5AFDF.js +18 -0
- package/lib/chunk-S5D5AFDF.js.map +1 -0
- package/lib/chunk-SBO6OQIX.mjs +23 -0
- package/lib/chunk-SBO6OQIX.mjs.map +1 -0
- package/lib/chunk-SFIX77W5.js +21 -0
- package/lib/chunk-SFIX77W5.js.map +1 -0
- package/lib/chunk-T2A3XXQZ.mjs +18 -0
- package/lib/chunk-T2A3XXQZ.mjs.map +1 -0
- package/lib/chunk-TCDQA2NU.js +31 -0
- package/lib/chunk-TCDQA2NU.js.map +1 -0
- package/lib/{chunk-H6LHV3EA.mjs → chunk-THU5VBSO.mjs} +2 -2
- package/lib/chunk-THU5VBSO.mjs.map +1 -0
- package/lib/{chunk-5YYRBKDP.js → chunk-TJQ5NVL4.js} +5 -5
- package/lib/chunk-TJQ5NVL4.js.map +1 -0
- package/lib/{chunk-HP3DRZWK.js → chunk-TLPVFRWR.js} +4 -7
- package/lib/chunk-TLPVFRWR.js.map +1 -0
- package/lib/chunk-TLRVQWCI.mjs +30 -0
- package/lib/chunk-TLRVQWCI.mjs.map +1 -0
- package/lib/chunk-TQDMUHTA.mjs +20 -0
- package/lib/chunk-TQDMUHTA.mjs.map +1 -0
- package/lib/chunk-TZBAW5OO.mjs +21 -0
- package/lib/chunk-TZBAW5OO.mjs.map +1 -0
- package/lib/chunk-UHMICS34.mjs +18 -0
- package/lib/chunk-UHMICS34.mjs.map +1 -0
- package/lib/chunk-UYQFYQQG.mjs +69 -0
- package/lib/chunk-UYQFYQQG.mjs.map +1 -0
- package/lib/chunk-V2J4TQR5.mjs +20 -0
- package/lib/chunk-V2J4TQR5.mjs.map +1 -0
- package/lib/chunk-V7C77FML.mjs +18 -0
- package/lib/chunk-V7C77FML.mjs.map +1 -0
- package/lib/chunk-VN4GLOEN.js +302 -0
- package/lib/chunk-VN4GLOEN.js.map +1 -0
- package/lib/chunk-VOFKYSJD.js +20 -0
- package/lib/chunk-VOFKYSJD.js.map +1 -0
- package/lib/chunk-VVXKATDH.js +18 -0
- package/lib/chunk-VVXKATDH.js.map +1 -0
- package/lib/{chunk-K7X6DVM2.mjs → chunk-W3U7RYLP.mjs} +3 -6
- package/lib/chunk-W3U7RYLP.mjs.map +1 -0
- package/lib/chunk-WJGXVKZY.js +21 -0
- package/lib/chunk-WJGXVKZY.js.map +1 -0
- package/lib/chunk-WLPDAJB3.js +52 -0
- package/lib/chunk-WLPDAJB3.js.map +1 -0
- package/lib/chunk-WYM2TIVW.mjs +23 -0
- package/lib/chunk-WYM2TIVW.mjs.map +1 -0
- package/lib/chunk-XBE75VFX.js +13 -0
- package/lib/chunk-XBE75VFX.js.map +1 -0
- package/lib/chunk-XDVSL5B6.js +14 -0
- package/lib/chunk-XDVSL5B6.js.map +1 -0
- package/lib/chunk-XIOV4SHZ.mjs +13 -0
- package/lib/chunk-XIOV4SHZ.mjs.map +1 -0
- package/lib/chunk-Y54K6TQO.js +19 -0
- package/lib/chunk-Y54K6TQO.js.map +1 -0
- package/lib/chunk-Y5MNJGFX.js +30 -0
- package/lib/chunk-Y5MNJGFX.js.map +1 -0
- package/lib/chunk-YDTQASAY.mjs +18 -0
- package/lib/chunk-YDTQASAY.mjs.map +1 -0
- package/lib/chunk-YMPRYKNY.js +18 -0
- package/lib/chunk-YMPRYKNY.js.map +1 -0
- package/lib/chunk-Z2HZXSDA.js +18 -0
- package/lib/chunk-Z2HZXSDA.js.map +1 -0
- package/lib/chunk-Z3NPFUIA.mjs +18 -0
- package/lib/chunk-Z3NPFUIA.mjs.map +1 -0
- package/lib/chunk-Z4XOKGU3.js +71 -0
- package/lib/chunk-Z4XOKGU3.js.map +1 -0
- package/lib/chunk-ZDXO3TGZ.mjs +18 -0
- package/lib/chunk-ZDXO3TGZ.mjs.map +1 -0
- package/lib/chunk-ZEGRYDE5.mjs +18 -0
- package/lib/chunk-ZEGRYDE5.mjs.map +1 -0
- package/lib/chunk-ZGUF5ZDP.mjs +21 -0
- package/lib/chunk-ZGUF5ZDP.mjs.map +1 -0
- package/lib/chunk-ZNQHNLKW.js +18 -0
- package/lib/chunk-ZNQHNLKW.js.map +1 -0
- package/lib/chunk-ZTCXXAKD.mjs +24 -0
- package/lib/chunk-ZTCXXAKD.mjs.map +1 -0
- package/lib/codeGen.d.mts +3 -2
- package/lib/codeGen.d.ts +3 -2
- package/lib/codeGen.js +3 -46
- package/lib/codeGen.js.map +1 -1
- package/lib/codeGen.mjs +4 -47
- package/lib/codeGen.mjs.map +1 -1
- package/lib/commonTypes.d.mts +12 -12
- package/lib/commonTypes.d.ts +12 -12
- package/lib/core.d.mts +200 -0
- package/lib/core.d.ts +200 -0
- package/lib/core.js +17 -0
- package/lib/core.js.map +1 -0
- package/lib/core.mjs +17 -0
- package/lib/exceptions.d.mts +2 -3
- package/lib/exceptions.d.ts +2 -3
- package/lib/exceptions.js +2 -4
- package/lib/exceptions.js.map +1 -1
- package/lib/exceptions.mjs +3 -5
- package/lib/helpers/constants.d.mts +2 -1
- package/lib/helpers/constants.d.ts +2 -1
- package/lib/helpers/constants.js +4 -2
- package/lib/helpers/constants.js.map +1 -1
- package/lib/helpers/constants.mjs +5 -3
- package/lib/helpers/setStrictType.d.mts +3 -2
- package/lib/helpers/setStrictType.d.ts +3 -2
- package/lib/helpers/setStrictType.js +3 -5
- package/lib/helpers/setStrictType.js.map +1 -1
- package/lib/helpers/setStrictType.mjs +2 -4
- package/lib/index.d.mts +52 -4
- package/lib/index.d.ts +52 -4
- package/lib/index.js +203 -6
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +207 -10
- package/lib/translationMap.d.mts +4 -1
- package/lib/translationMap.d.ts +4 -1
- package/lib/translationMap.js +3 -3
- package/lib/translationMap.mjs +2 -2
- package/package.json +46 -41
- package/lib/CommonSchema-DOh3bsL-.d.ts +0 -110
- package/lib/CommonSchema-wi9MOXGF.d.mts +0 -110
- package/lib/chunk-2KQASECD.js +0 -20
- package/lib/chunk-2KQASECD.js.map +0 -1
- package/lib/chunk-42J6CHIO.js.map +0 -1
- package/lib/chunk-5P6AZJCN.js +0 -45
- package/lib/chunk-5P6AZJCN.js.map +0 -1
- package/lib/chunk-5WHCMWXK.js +0 -50
- package/lib/chunk-5WHCMWXK.js.map +0 -1
- package/lib/chunk-5YYRBKDP.js.map +0 -1
- package/lib/chunk-6D5W7SSQ.mjs +0 -44
- package/lib/chunk-6D5W7SSQ.mjs.map +0 -1
- package/lib/chunk-7NBOVYSP.mjs +0 -136
- package/lib/chunk-7NBOVYSP.mjs.map +0 -1
- package/lib/chunk-BNCT7NOR.mjs +0 -91
- package/lib/chunk-BNCT7NOR.mjs.map +0 -1
- package/lib/chunk-C3EDEQ3W.mjs.map +0 -1
- package/lib/chunk-CHUPE6SJ.mjs +0 -58
- package/lib/chunk-CHUPE6SJ.mjs.map +0 -1
- package/lib/chunk-ECBOZ3BM.js +0 -44
- package/lib/chunk-ECBOZ3BM.js.map +0 -1
- package/lib/chunk-FGZKNBDP.mjs +0 -45
- package/lib/chunk-FGZKNBDP.mjs.map +0 -1
- package/lib/chunk-FP5QAEVQ.mjs +0 -63
- package/lib/chunk-FP5QAEVQ.mjs.map +0 -1
- package/lib/chunk-G55SHHAR.js +0 -29
- package/lib/chunk-G55SHHAR.js.map +0 -1
- package/lib/chunk-H32B3NHW.mjs.map +0 -1
- package/lib/chunk-H6LHV3EA.mjs.map +0 -1
- package/lib/chunk-HP3DRZWK.js.map +0 -1
- package/lib/chunk-IZ3CBVEE.js.map +0 -1
- package/lib/chunk-K7X6DVM2.mjs.map +0 -1
- package/lib/chunk-LPR3G5T3.mjs.map +0 -1
- package/lib/chunk-MHBY5OIQ.mjs +0 -20
- package/lib/chunk-MHBY5OIQ.mjs.map +0 -1
- package/lib/chunk-MLNQZ445.js +0 -58
- package/lib/chunk-MLNQZ445.js.map +0 -1
- package/lib/chunk-QIDWASOC.js +0 -14
- package/lib/chunk-QIDWASOC.js.map +0 -1
- package/lib/chunk-SHJVKSEZ.js +0 -136
- package/lib/chunk-SHJVKSEZ.js.map +0 -1
- package/lib/chunk-TRGMD7LA.mjs +0 -29
- package/lib/chunk-TRGMD7LA.mjs.map +0 -1
- package/lib/chunk-TV5IZY4L.mjs +0 -50
- package/lib/chunk-TV5IZY4L.mjs.map +0 -1
- package/lib/chunk-U4USIJV3.js.map +0 -1
- package/lib/chunk-UUY7DPHK.js +0 -65
- package/lib/chunk-UUY7DPHK.js.map +0 -1
- package/lib/chunk-VW4RMQD4.js +0 -28
- package/lib/chunk-VW4RMQD4.js.map +0 -1
- package/lib/chunk-WK4FJ5GD.mjs +0 -65
- package/lib/chunk-WK4FJ5GD.mjs.map +0 -1
- package/lib/chunk-X762EUSZ.js +0 -91
- package/lib/chunk-X762EUSZ.js.map +0 -1
- package/lib/chunk-YUMUCQKL.mjs.map +0 -1
- package/lib/chunk-Z6QU36MM.js +0 -63
- package/lib/chunk-Z6QU36MM.js.map +0 -1
- package/lib/helpers/core.d.mts +0 -3
- package/lib/helpers/core.d.ts +0 -3
- package/lib/helpers/core.js +0 -11
- package/lib/helpers/core.js.map +0 -1
- package/lib/helpers/core.mjs +0 -11
- package/lib/parse.d.mts +0 -61
- package/lib/parse.d.ts +0 -61
- package/lib/parse.js +0 -11
- package/lib/parse.js.map +0 -1
- package/lib/parse.mjs +0 -11
- package/lib/parse.mjs.map +0 -1
- package/lib/parseOrFail.d.mts +0 -43
- package/lib/parseOrFail.d.ts +0 -43
- package/lib/parseOrFail.js +0 -11
- package/lib/parseOrFail.js.map +0 -1
- package/lib/parseOrFail.mjs +0 -11
- package/lib/parseOrFail.mjs.map +0 -1
- package/lib/schemas/ArraySchema.d.mts +0 -11
- package/lib/schemas/ArraySchema.d.ts +0 -11
- package/lib/schemas/ArraySchema.js +0 -13
- package/lib/schemas/ArraySchema.js.map +0 -1
- package/lib/schemas/ArraySchema.mjs +0 -13
- package/lib/schemas/ArraySchema.mjs.map +0 -1
- package/lib/schemas/BigIntSchema.d.mts +0 -30
- package/lib/schemas/BigIntSchema.d.ts +0 -30
- package/lib/schemas/BigIntSchema.js +0 -17
- package/lib/schemas/BigIntSchema.js.map +0 -1
- package/lib/schemas/BigIntSchema.mjs +0 -17
- package/lib/schemas/BigIntSchema.mjs.map +0 -1
- package/lib/schemas/BooleanSchema.d.mts +0 -25
- package/lib/schemas/BooleanSchema.d.ts +0 -25
- package/lib/schemas/BooleanSchema.js +0 -14
- package/lib/schemas/BooleanSchema.js.map +0 -1
- package/lib/schemas/BooleanSchema.mjs +0 -14
- package/lib/schemas/BooleanSchema.mjs.map +0 -1
- package/lib/schemas/CommonSchema.d.mts +0 -3
- package/lib/schemas/CommonSchema.d.ts +0 -3
- package/lib/schemas/CommonSchema.js +0 -12
- package/lib/schemas/CommonSchema.js.map +0 -1
- package/lib/schemas/CommonSchema.mjs +0 -12
- package/lib/schemas/CommonSchema.mjs.map +0 -1
- package/lib/schemas/DateSchema.d.mts +0 -10
- package/lib/schemas/DateSchema.d.ts +0 -10
- package/lib/schemas/DateSchema.js +0 -13
- package/lib/schemas/DateSchema.js.map +0 -1
- package/lib/schemas/DateSchema.mjs +0 -13
- package/lib/schemas/DateSchema.mjs.map +0 -1
- package/lib/schemas/NumberSchema.d.mts +0 -29
- package/lib/schemas/NumberSchema.d.ts +0 -29
- package/lib/schemas/NumberSchema.js +0 -17
- package/lib/schemas/NumberSchema.js.map +0 -1
- package/lib/schemas/NumberSchema.mjs +0 -17
- package/lib/schemas/NumberSchema.mjs.map +0 -1
- package/lib/schemas/ObjectSchema.d.mts +0 -29
- package/lib/schemas/ObjectSchema.d.ts +0 -29
- package/lib/schemas/ObjectSchema.js +0 -13
- package/lib/schemas/ObjectSchema.js.map +0 -1
- package/lib/schemas/ObjectSchema.mjs +0 -13
- package/lib/schemas/ObjectSchema.mjs.map +0 -1
- package/lib/schemas/StringSchema.d.mts +0 -30
- package/lib/schemas/StringSchema.d.ts +0 -30
- package/lib/schemas/StringSchema.js +0 -17
- package/lib/schemas/StringSchema.js.map +0 -1
- package/lib/schemas/StringSchema.mjs +0 -17
- package/lib/schemas/StringSchema.mjs.map +0 -1
- /package/lib/{helpers/core.mjs.map → core.mjs.map} +0 -0
package/lib/chunk-BNCT7NOR.mjs
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isValidDateInner
|
|
3
|
-
} from "./chunk-YBVMP4EI.mjs";
|
|
4
|
-
import {
|
|
5
|
-
guardException
|
|
6
|
-
} from "./chunk-FGZKNBDP.mjs";
|
|
7
|
-
|
|
8
|
-
// src/helpers/core.ts
|
|
9
|
-
var ctxSymbol = Symbol("contextSymbol");
|
|
10
|
-
function innerCheck(schema, receivedValue, exCtx) {
|
|
11
|
-
const commonTmap = exCtx.t;
|
|
12
|
-
const schemaData = schema[ctxSymbol];
|
|
13
|
-
schemaData.transformListBefore?.forEach((transformCallback) => {
|
|
14
|
-
receivedValue = transformCallback(receivedValue);
|
|
15
|
-
});
|
|
16
|
-
if (receivedValue === void 0) {
|
|
17
|
-
if (schemaData.defaultValue !== void 0) return schemaData.defaultValue;
|
|
18
|
-
if (!schemaData.isOptional) guardException("Required", receivedValue, exCtx, commonTmap["c:optional"]);
|
|
19
|
-
return receivedValue;
|
|
20
|
-
}
|
|
21
|
-
if (receivedValue === null) {
|
|
22
|
-
if (!schemaData.isNullable) guardException("Not null", receivedValue, exCtx, commonTmap["c:nullable"]);
|
|
23
|
-
return receivedValue;
|
|
24
|
-
}
|
|
25
|
-
if (schemaData.date) {
|
|
26
|
-
if (!isValidDateInner(receivedValue)) guardException("Date", receivedValue, exCtx, commonTmap["c:date"]);
|
|
27
|
-
}
|
|
28
|
-
const typeOfVal = typeof receivedValue;
|
|
29
|
-
if (schemaData.type.length) {
|
|
30
|
-
if (!schemaData.type.includes(typeOfVal))
|
|
31
|
-
guardException(schemaData.type, typeOfVal, exCtx, commonTmap["c:invalidType"]);
|
|
32
|
-
}
|
|
33
|
-
if (schemaData.array) {
|
|
34
|
-
if (!Array.isArray(receivedValue)) return guardException("Array", receivedValue, exCtx, commonTmap["c:array"]);
|
|
35
|
-
schemaData.requiredValidations.forEach((requiredValidation) => {
|
|
36
|
-
requiredValidation(receivedValue, exCtx);
|
|
37
|
-
});
|
|
38
|
-
const schema2 = schemaData.array;
|
|
39
|
-
const pathToError = exCtx.pathToError;
|
|
40
|
-
const parsedReceivedValue = [];
|
|
41
|
-
receivedValue.forEach((elem, i) => {
|
|
42
|
-
const parsedElement = innerCheck(schema2, elem, {
|
|
43
|
-
...exCtx,
|
|
44
|
-
pathToError: `${pathToError}[${i}]`,
|
|
45
|
-
meta: schemaData.meta
|
|
46
|
-
});
|
|
47
|
-
parsedReceivedValue.push(parsedElement);
|
|
48
|
-
});
|
|
49
|
-
return parsedReceivedValue;
|
|
50
|
-
}
|
|
51
|
-
if (schemaData.object) {
|
|
52
|
-
if (typeOfVal !== "object") guardException("Object", receivedValue, exCtx, commonTmap["c:objectType"]);
|
|
53
|
-
if (Array.isArray(receivedValue)) guardException("Object", receivedValue, exCtx, commonTmap["c:objectTypeAsArray"]);
|
|
54
|
-
schemaData.requiredValidations.forEach((requiredValidation) => {
|
|
55
|
-
requiredValidation(receivedValue, exCtx);
|
|
56
|
-
});
|
|
57
|
-
const shapeSchema = schemaData.object;
|
|
58
|
-
const parsedReceivedValue = {};
|
|
59
|
-
if (!schemaData.allowUnrecognizedObjectProps) {
|
|
60
|
-
for (const keyPerReceivedValue of Object.keys(receivedValue)) {
|
|
61
|
-
if (shapeSchema[keyPerReceivedValue] === void 0)
|
|
62
|
-
guardException("Unrecognized property", keyPerReceivedValue, exCtx, commonTmap["c:unrecognizedProperty"]);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const pathToError = exCtx.pathToError;
|
|
66
|
-
for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {
|
|
67
|
-
const receivedObjectValuePropery = receivedValue[keyOfSchema];
|
|
68
|
-
if (receivedObjectValuePropery === void 0) {
|
|
69
|
-
if (!valueOfSchema[ctxSymbol].isOptional)
|
|
70
|
-
guardException("Required", receivedObjectValuePropery, exCtx, commonTmap["c:requiredProperty"]);
|
|
71
|
-
}
|
|
72
|
-
const parsedReceivedObjectValuePropery = innerCheck(valueOfSchema, receivedObjectValuePropery, {
|
|
73
|
-
...exCtx,
|
|
74
|
-
pathToError: `${pathToError}.${keyOfSchema}`,
|
|
75
|
-
meta: schemaData.meta
|
|
76
|
-
});
|
|
77
|
-
parsedReceivedValue[keyOfSchema] = parsedReceivedObjectValuePropery;
|
|
78
|
-
}
|
|
79
|
-
return parsedReceivedValue;
|
|
80
|
-
}
|
|
81
|
-
schemaData.requiredValidations.forEach((requiredValidation) => {
|
|
82
|
-
requiredValidation(receivedValue, exCtx);
|
|
83
|
-
});
|
|
84
|
-
return receivedValue;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export {
|
|
88
|
-
ctxSymbol,
|
|
89
|
-
innerCheck
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=chunk-BNCT7NOR.mjs.map
|
|
@@ -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';\nimport { isValidDateInner } from './isValidDateInner';\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, exCtx: ExceptionContext): unknown {\n const commonTmap = exCtx.t;\n const schemaData = schema[ctxSymbol];\n\n schemaData.transformListBefore?.forEach((transformCallback) => {\n receivedValue = transformCallback(receivedValue);\n });\n\n if (receivedValue === undefined) {\n if (schemaData.defaultValue !== undefined) return schemaData.defaultValue;\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.date) {\n if (!isValidDateInner(receivedValue)) guardException('Date', receivedValue, exCtx, commonTmap['c:date']);\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (schemaData.type.length) {\n if (!schemaData.type.includes(typeOfVal))\n guardException(schemaData.type, typeOfVal, exCtx, commonTmap['c:invalidType']);\n }\n\n if (schemaData.array) {\n if (!Array.isArray(receivedValue)) return guardException('Array', receivedValue, exCtx, commonTmap['c:array']);\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\n const schema = schemaData.array;\n const pathToError = exCtx.pathToError;\n const parsedReceivedValue: unknown[] = [];\n receivedValue.forEach((elem, i) => {\n const parsedElement = innerCheck(schema, elem, {\n ...exCtx,\n pathToError: `${pathToError}[${i}]`,\n meta: schemaData.meta,\n });\n parsedReceivedValue.push(parsedElement);\n });\n\n return parsedReceivedValue;\n }\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\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\n const shapeSchema = schemaData.object;\n const parsedReceivedValue: Record<string, unknown> = {};\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 const parsedReceivedObjectValuePropery = innerCheck(valueOfSchema, receivedObjectValuePropery, {\n ...exCtx,\n pathToError: `${pathToError}.${keyOfSchema}`,\n meta: schemaData.meta,\n });\n\n parsedReceivedValue[keyOfSchema] = parsedReceivedObjectValuePropery;\n }\n\n return parsedReceivedValue;\n }\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\n return receivedValue;\n}\n"],"mappings":";;;;;;;;AAAO,IAAM,YAAY,OAAO,eAAe;AAOxC,SAAS,WAAW,QAAsB,eAAwB,OAAkC;AACzG,QAAM,aAAa,MAAM;AACzB,QAAM,aAAa,OAAO,SAAS;AAEnC,aAAW,qBAAqB,QAAQ,CAAC,sBAAsB;AAC7D,oBAAgB,kBAAkB,aAAa;AAAA,EACjD,CAAC;AAED,MAAI,kBAAkB,QAAW;AAC/B,QAAI,WAAW,iBAAiB,OAAW,QAAO,WAAW;AAC7D,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,MAAM;AACnB,QAAI,CAAC,iBAAiB,aAAa,EAAG,gBAAe,QAAQ,eAAe,OAAO,WAAW,QAAQ,CAAC;AAAA,EACzG;AAEA,QAAM,YAAY,OAAO;AAEzB,MAAI,WAAW,KAAK,QAAQ;AAC1B,QAAI,CAAC,WAAW,KAAK,SAAS,SAAS;AACrC,qBAAe,WAAW,MAAM,WAAW,OAAO,WAAW,eAAe,CAAC;AAAA,EACjF;AAEA,MAAI,WAAW,OAAO;AACpB,QAAI,CAAC,MAAM,QAAQ,aAAa,EAAG,QAAO,eAAe,SAAS,eAAe,OAAO,WAAW,SAAS,CAAC;AAE7G,eAAW,oBAAoB,QAAQ,CAAC,uBAAuB;AAC7D,yBAAmB,eAAe,KAAK;AAAA,IACzC,CAAC;AAED,UAAMA,UAAS,WAAW;AAC1B,UAAM,cAAc,MAAM;AAC1B,UAAM,sBAAiC,CAAC;AACxC,kBAAc,QAAQ,CAAC,MAAM,MAAM;AACjC,YAAM,gBAAgB,WAAWA,SAAQ,MAAM;AAAA,QAC7C,GAAG;AAAA,QACH,aAAa,GAAG,WAAW,IAAI,CAAC;AAAA,QAChC,MAAM,WAAW;AAAA,MACnB,CAAC;AACD,0BAAoB,KAAK,aAAa;AAAA,IACxC,CAAC;AAED,WAAO;AAAA,EACT;AAEA,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;AAElH,eAAW,oBAAoB,QAAQ,CAAC,uBAAuB;AAC7D,yBAAmB,eAAe,KAAK;AAAA,IACzC,CAAC;AAED,UAAM,cAAc,WAAW;AAC/B,UAAM,sBAA+C,CAAC;AAEtD,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,YAAM,mCAAmC,WAAW,eAAe,4BAA4B;AAAA,QAC7F,GAAG;AAAA,QACH,aAAa,GAAG,WAAW,IAAI,WAAW;AAAA,QAC1C,MAAM,WAAW;AAAA,MACnB,CAAC;AAED,0BAAoB,WAAW,IAAI;AAAA,IACrC;AAEA,WAAO;AAAA,EACT;AAEA,aAAW,oBAAoB,QAAQ,CAAC,uBAAuB;AAC7D,uBAAmB,eAAe,KAAK;AAAA,EACzC,CAAC;AAED,SAAO;AACT;","names":["schema"]}
|
|
@@ -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, bigint and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match 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":[]}
|
package/lib/chunk-CHUPE6SJ.mjs
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
equalTo
|
|
3
|
-
} from "./chunk-C3EDEQ3W.mjs";
|
|
4
|
-
import {
|
|
5
|
-
oneOfValues
|
|
6
|
-
} from "./chunk-K7X6DVM2.mjs";
|
|
7
|
-
import {
|
|
8
|
-
ONLY_ONCE
|
|
9
|
-
} from "./chunk-ASZW6XRM.mjs";
|
|
10
|
-
import {
|
|
11
|
-
_setStrictType
|
|
12
|
-
} from "./chunk-H6LHV3EA.mjs";
|
|
13
|
-
import {
|
|
14
|
-
CommonSchema
|
|
15
|
-
} from "./chunk-7NBOVYSP.mjs";
|
|
16
|
-
import {
|
|
17
|
-
BuildSchemaError
|
|
18
|
-
} from "./chunk-FGZKNBDP.mjs";
|
|
19
|
-
|
|
20
|
-
// src/schemas/NumberSchema.ts
|
|
21
|
-
var NumberSchema = class extends CommonSchema {
|
|
22
|
-
_number = 1;
|
|
23
|
-
limit;
|
|
24
|
-
/**
|
|
25
|
-
* Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
26
|
-
*
|
|
27
|
-
* @param expectedValue - The value that the schema must exactly match.
|
|
28
|
-
* @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type
|
|
29
|
-
*
|
|
30
|
-
* @example - number().equalTo(42); // Infers the type 42
|
|
31
|
-
*/
|
|
32
|
-
equalTo(expectedValue) {
|
|
33
|
-
if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
|
|
34
|
-
this.limit = true;
|
|
35
|
-
_setStrictType(this, expectedValue);
|
|
36
|
-
return this.custom(equalTo(expectedValue));
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
|
|
40
|
-
*
|
|
41
|
-
* @param expectedValues - An array of values that the schema can match.
|
|
42
|
-
* @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* number().oneOfValues([5, 7]); // Infers the type 5 | 7
|
|
46
|
-
*/
|
|
47
|
-
oneOfValues(expectedValue) {
|
|
48
|
-
if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
|
|
49
|
-
this.limit = true;
|
|
50
|
-
_setStrictType(this, expectedValue);
|
|
51
|
-
return this.custom(oneOfValues(expectedValue));
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export {
|
|
56
|
-
NumberSchema
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=chunk-CHUPE6SJ.mjs.map
|
|
@@ -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 { WithBGuardType } from '../commonTypes';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n protected _number = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - number().equalTo(42); // Infers the type 42\n */\n public equalTo<Y extends number>(expectedValue: Y): WithBGuardType<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n public oneOfValues<Y extends number>(expectedValue: Y[]): WithBGuardType<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithBGuardType<this, Y>;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQO,IAAM,eAAN,cAA2B,aAAa;AAAA,EACnC,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,QAA0B,eAA2C;AAC1E,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,EAWO,YAA8B,eAA6C;AAChF,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":[]}
|
package/lib/chunk-ECBOZ3BM.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
-
|
|
3
|
-
var _chunkQIDWASOCjs = require('./chunk-QIDWASOC.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkSHJVKSEZjs = require('./chunk-SHJVKSEZ.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
|
|
10
|
-
|
|
11
|
-
// src/schemas/BooleanSchema.ts
|
|
12
|
-
var isBoolean = (expected) => (received, ctx) => {
|
|
13
|
-
if (received !== expected) _chunk5P6AZJCNjs.guardException.call(void 0, expected, received, ctx, "c:isBoolean");
|
|
14
|
-
};
|
|
15
|
-
var BooleanSchema = (_class = class extends _chunkSHJVKSEZjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
16
|
-
__init() {this._boolean = 1}
|
|
17
|
-
/**
|
|
18
|
-
* Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.
|
|
19
|
-
*
|
|
20
|
-
* @returns - The schema instance restricted to the value true, with the true value inferred as the TypeScript type
|
|
21
|
-
*
|
|
22
|
-
* @example - boolean().onlyTrue(); // Infers the type true
|
|
23
|
-
*/
|
|
24
|
-
onlyTrue() {
|
|
25
|
-
_chunkQIDWASOCjs._setStrictType.call(void 0, this, true);
|
|
26
|
-
return this.custom(isBoolean(true));
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Restricts the schema to exactly match the boolean value false and infers the false value as the TypeScript type.
|
|
30
|
-
*
|
|
31
|
-
* @returns - The schema instance restricted to the value false, with the false value inferred as the TypeScript type
|
|
32
|
-
*
|
|
33
|
-
* @example - boolean().onlyFalse(); // Infers the type false
|
|
34
|
-
*/
|
|
35
|
-
onlyFalse() {
|
|
36
|
-
_chunkQIDWASOCjs._setStrictType.call(void 0, this, false);
|
|
37
|
-
return this.custom(isBoolean(false));
|
|
38
|
-
}
|
|
39
|
-
}, _class);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
exports.BooleanSchema = BooleanSchema;
|
|
44
|
-
//# sourceMappingURL=chunk-ECBOZ3BM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-ECBOZ3BM.js","../src/schemas/BooleanSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACLA,IAAM,UAAA,EAAY,CAAC,QAAA,EAAA,GAAsB,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AACrF,EAAA,GAAA,CAAI,SAAA,IAAa,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,aAAa,CAAA;AAClF,CAAA;AAEO,IAAM,cAAA,YAAN,MAAA,QAA4B,8BAAa;AAAA,iBACpC,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASd,QAAA,CAAA,EAAuC;AAC5C,IAAA,6CAAA,IAAe,EAAM,IAAI,CAAA;AACzB,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,IAAI,CAAC,CAAA;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,SAAA,CAAA,EAAyC;AAC9C,IAAA,6CAAA,IAAe,EAAM,KAAK,CAAA;AAC1B,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,KAAK,CAAC,CAAA;AAAA,EACrC;AACF,UAAA;ADIA;AACA;AACE;AACF,sCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-ECBOZ3BM.js","sourcesContent":[null,"import { CommonSchema } from './CommonSchema';\nimport { guardException } from '../exceptions';\nimport { ExceptionContext, WithBGuardType } 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 protected _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 public onlyTrue(): WithBGuardType<this, true> {\n _setStrictType(this, true);\n return this.custom(isBoolean(true)) as WithBGuardType<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 public onlyFalse(): WithBGuardType<this, false> {\n _setStrictType(this, false);\n return this.custom(isBoolean(false)) as WithBGuardType<this, false>;\n }\n}\n\n// export type WithBoolean<T extends BooleanSchema, Y = boolean> = T & { validation_boolean: Y };\n// export type ExtractFromBoolean<T> = T extends WithBoolean<BooleanSchema, infer Y> ? Y : never;\n"]}
|
package/lib/chunk-FGZKNBDP.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// src/exceptions.ts
|
|
2
|
-
var ValidationError = class extends Error {
|
|
3
|
-
expected;
|
|
4
|
-
received;
|
|
5
|
-
pathToError;
|
|
6
|
-
message;
|
|
7
|
-
meta;
|
|
8
|
-
constructor(expected, received, pathToError, message, meta) {
|
|
9
|
-
super();
|
|
10
|
-
this.expected = expected;
|
|
11
|
-
this.received = received;
|
|
12
|
-
this.pathToError = pathToError;
|
|
13
|
-
this.message = message;
|
|
14
|
-
this.meta = meta;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var BuildSchemaError = class extends Error {
|
|
18
|
-
};
|
|
19
|
-
function replacePlaceholders(template, replacements) {
|
|
20
|
-
const regex = /{{(.*?)}}/g;
|
|
21
|
-
return template.replace(regex, (_, key) => {
|
|
22
|
-
return key in replacements ? `${replacements[key]}` : `{{${key}}}`;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function guardException(expected, received, ctx, messageKey) {
|
|
26
|
-
const rawMessage = ctx.t[messageKey] ?? messageKey;
|
|
27
|
-
const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: ctx.pathToError });
|
|
28
|
-
if (ctx.getAllErrors) {
|
|
29
|
-
ctx.errors.push({
|
|
30
|
-
expected,
|
|
31
|
-
received,
|
|
32
|
-
pathToError: ctx.pathToError,
|
|
33
|
-
message
|
|
34
|
-
});
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
throw new ValidationError(expected, received, ctx.pathToError, message, ctx.meta);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
ValidationError,
|
|
42
|
-
BuildSchemaError,
|
|
43
|
-
guardException
|
|
44
|
-
};
|
|
45
|
-
//# sourceMappingURL=chunk-FGZKNBDP.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/exceptions.ts"],"sourcesContent":["import type { ExceptionContext, MetaContext } from './commonTypes';\n\nexport class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n meta?: MetaContext;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string, meta?: MetaContext) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n this.meta = meta;\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 return key in replacements ? `${replacements[key] as string}` : `{{${key}}}`;\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, ctx.meta);\n}\n"],"mappings":";AAEO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB,MAAoB;AAC1G,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;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,WAAO,OAAO,eAAe,GAAG,aAAa,GAAG,CAAW,KAAK,KAAK,GAAG;AAAA,EAC1E,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,SAAS,IAAI,IAAI;AAClF;","names":[]}
|
package/lib/chunk-FP5QAEVQ.mjs
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
equalTo
|
|
3
|
-
} from "./chunk-C3EDEQ3W.mjs";
|
|
4
|
-
import {
|
|
5
|
-
oneOfValues
|
|
6
|
-
} from "./chunk-K7X6DVM2.mjs";
|
|
7
|
-
import {
|
|
8
|
-
ONLY_ONCE
|
|
9
|
-
} from "./chunk-ASZW6XRM.mjs";
|
|
10
|
-
import {
|
|
11
|
-
_setStrictType
|
|
12
|
-
} from "./chunk-H6LHV3EA.mjs";
|
|
13
|
-
import {
|
|
14
|
-
CommonSchema
|
|
15
|
-
} from "./chunk-7NBOVYSP.mjs";
|
|
16
|
-
import {
|
|
17
|
-
BuildSchemaError
|
|
18
|
-
} from "./chunk-FGZKNBDP.mjs";
|
|
19
|
-
|
|
20
|
-
// src/schemas/StringSchema.ts
|
|
21
|
-
var StringSchema = class extends CommonSchema {
|
|
22
|
-
_string = 1;
|
|
23
|
-
limit;
|
|
24
|
-
/**
|
|
25
|
-
* Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
26
|
-
*
|
|
27
|
-
* @param expectedValue - The value that the schema must exactly match.
|
|
28
|
-
* @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type
|
|
29
|
-
*
|
|
30
|
-
* @example - string().equalTo('hello'); // Infers the type 'hello'
|
|
31
|
-
*/
|
|
32
|
-
equalTo(expectedValue) {
|
|
33
|
-
this.limitCheck();
|
|
34
|
-
_setStrictType(this, `'${expectedValue}'`);
|
|
35
|
-
return this.custom(equalTo(expectedValue));
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
|
|
39
|
-
*
|
|
40
|
-
* @param expectedValues - An array of values that the schema can match.
|
|
41
|
-
* @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'
|
|
45
|
-
*/
|
|
46
|
-
oneOfValues(expectedValue) {
|
|
47
|
-
this.limitCheck();
|
|
48
|
-
_setStrictType(
|
|
49
|
-
this,
|
|
50
|
-
expectedValue.map((el) => `'${el}'`)
|
|
51
|
-
);
|
|
52
|
-
return this.custom(oneOfValues(expectedValue));
|
|
53
|
-
}
|
|
54
|
-
limitCheck() {
|
|
55
|
-
if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
|
|
56
|
-
this.limit = true;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export {
|
|
61
|
-
StringSchema
|
|
62
|
-
};
|
|
63
|
-
//# sourceMappingURL=chunk-FP5QAEVQ.mjs.map
|
|
@@ -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 { WithBGuardType } from '../commonTypes';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n protected _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 public equalTo<Y extends string>(expectedValue: Y): WithBGuardType<this, Y> {\n this.limitCheck();\n _setStrictType(this, `'${expectedValue}'`);\n\n return this.custom(equalTo(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n public oneOfValues<Y extends string>(expectedValue: Y[]): WithBGuardType<this, Y> {\n this.limitCheck();\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n private limitCheck() {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQO,IAAM,eAAN,cAA2B,aAAa;AAAA,EACnC,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,QAA0B,eAA2C;AAC1E,SAAK,WAAW;AAChB,mBAAe,MAAM,IAAI,aAAa,GAAG;AAEzC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWO,YAA8B,eAA6C;AAChF,SAAK,WAAW;AAChB;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,IAAI,EAAE,GAAG;AAAA,IACrC;AACA,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AAAA,EAEQ,aAAa;AACnB,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AAAA,EACf;AACF;","names":[]}
|
package/lib/chunk-G55SHHAR.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkX762EUSZjs = require('./chunk-X762EUSZ.js');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _chunk5YYRBKDPjs = require('./chunk-5YYRBKDP.js');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
|
|
11
|
-
|
|
12
|
-
// src/parseOrFail.ts
|
|
13
|
-
function parseOrFail(schema, receivedValue, options) {
|
|
14
|
-
try {
|
|
15
|
-
return _chunkX762EUSZjs.innerCheck.call(void 0, schema, receivedValue, {
|
|
16
|
-
t: _chunk5YYRBKDPjs.getTranslationByLocale.call(void 0, _optionalChain([options, 'optionalAccess', _ => _.lng])),
|
|
17
|
-
pathToError: "",
|
|
18
|
-
meta: schema[_chunkX762EUSZjs.ctxSymbol].meta
|
|
19
|
-
});
|
|
20
|
-
} catch (e) {
|
|
21
|
-
if (e instanceof _chunk5P6AZJCNjs.ValidationError) throw e;
|
|
22
|
-
throw new Error("Something unexpected happened");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
exports.parseOrFail = parseOrFail;
|
|
29
|
-
//# sourceMappingURL=chunk-G55SHHAR.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-G55SHHAR.js","../src/parseOrFail.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;AC+BO,SAAS,WAAA,CACd,MAAA,EACA,aAAA,EACA,OAAA,EACc;AACd,EAAA,IAAI;AACF,IAAA,OAAO,yCAAA,MAAW,EAAQ,aAAA,EAAe;AAAA,MACvC,CAAA,EAAG,qDAAA,gBAAuB,OAAA,2BAAS,KAAG,CAAA;AAAA,MACtC,WAAA,EAAa,EAAA;AAAA,MACb,IAAA,EAAM,MAAA,CAAO,0BAAS,CAAA,CAAE;AAAA,IAC1B,CAAC,CAAA;AAAA,EACH,EAAA,MAAA,CAAS,CAAA,EAAG;AACV,IAAA,GAAA,CAAI,EAAA,WAAa,gCAAA,EAAiB,MAAM,CAAA;AAExC,IAAA,MAAM,IAAI,KAAA,CAAM,+BAA+B,CAAA;AAAA,EACjD;AACF;ADlCA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-G55SHHAR.js","sourcesContent":[null,"import type { InferType } from './InferType';\nimport type { CommonSchema } from './schemas/CommonSchema';\nimport { ctxSymbol, innerCheck } from './helpers/core';\nimport { getTranslationByLocale } from './translationMap';\nimport { ValidationError } from './exceptions';\ninterface ParseOptions {\n /**\n * Set language keyword to map error messages.\n * @default 'default'\n * @example 'sr' or 'Serbia' or any string to identify language\n */\n lng?: string;\n}\n\n/**\n * Parses and validates a value against the provided schema, returning a type-safe result.\n *\n * This function will throw a `ValidationError` if the value does not conform to the schema.\n * The inferred TypeScript type of the returned value will match the structure defined by the schema.\n *\n * @template T\n * @param {T} schema - The schema to validate the received value against. This schema dictates the expected structure and type of the value.\n * @param {unknown} receivedValue - The value to be validated and parsed according to the schema.\n * @param {ParseOptions} options - Options\n * @param {ParseOptions.lng} options.lng - Set language keyword to map Error message\n * @returns {InferType<T>} The validated value, with its TypeScript type inferred from the schema.\n *\n * @throws {ValidationError} If the received value does not match the schema, a `ValidationError` will be thrown.\n * @throws {Error} If an unexpected error occurs during validation, an error will be thrown with a generic message.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number(),\n * });\n *\n * const result = parseOrFail(schema, { name: 'Alice', age: 30 });\n * // result will be inferred as { name: string; age: number }\n *\n * parseOrFail(schema, { name: 'Alice', age: '30' });\n * // Throws ValidationError because 'age' should be a number, not a string.\n */\nexport function parseOrFail<T extends CommonSchema>(\n schema: T,\n receivedValue: unknown,\n options?: ParseOptions,\n): InferType<T> {\n try {\n return innerCheck(schema, receivedValue, {\n t: getTranslationByLocale(options?.lng),\n pathToError: '',\n meta: schema[ctxSymbol].meta,\n }) as InferType<T>;\n } catch (e) {\n if (e instanceof ValidationError) throw e;\n /* istanbul ignore next */\n throw new Error('Something unexpected happened');\n }\n}\n"]}
|
|
@@ -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 'c:date': 'The received value is not a valid instance of Date',\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,EACf,UAAU;AAAA;AAEZ;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/helpers/setStrictType.ts"],"sourcesContent":["import { ctxSymbol } from './core';\nimport type { CommonSchema } from '../schemas/CommonSchema';\n\nexport function _setStrictType(that: CommonSchema, val: unknown) {\n that[ctxSymbol].strictType = true;\n that[ctxSymbol].strictTypeValue = val;\n}\n"],"mappings":";;;;;AAGO,SAAS,eAAe,MAAoB,KAAc;AAC/D,OAAK,SAAS,EAAE,aAAa;AAC7B,OAAK,SAAS,EAAE,kBAAkB;AACpC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-HP3DRZWK.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-HP3DRZWK.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, bigint and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match 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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-IZ3CBVEE.js","../src/asserts/mix/oneOfValues.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACHA,IAAM,wBAAA,EAA0B,6CAAA;AAChC,IAAM,oBAAA,EAAsB,eAAA;AAgBrB,IAAM,YAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AAC5C,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,QAAA,CAAS,QAAQ,CAAA,EAAG,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,mBAAmB,CAAA;AAC/F,CAAA;AAEF,WAAA,CAAY,IAAA,EAAM,mBAAA;AAClB,WAAA,CAAY,QAAA,EAAU,uBAAA;AACtB,iDAAA,WAA8B,CAAA;ADb9B;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-IZ3CBVEE.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst oneOfValuesErrorMessage = 'The received value is not equal to expected';\nconst oneOfValuesErrorKey = 'm:oneOfValues';\n\n/**\n * @description Creates a custom assertion that checks if a value is equal to the one of expected values.\n * @notice It has already been implemented in the number, bigint and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match at least one of the expected values.\n * @example\n * const schema = number().custom(oneOfValues([5, 4])); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 4); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:oneOfValues'\n */\nexport const oneOfValues =\n (expected: unknown[]): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (!expected.includes(received)) guardException(expected, received, ctx, oneOfValuesErrorKey);\n };\n\noneOfValues.key = oneOfValuesErrorKey;\noneOfValues.message = oneOfValuesErrorMessage;\nsetToDefaultLocale(oneOfValues);\n"]}
|
|
@@ -1 +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, bigint and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match at least one of the expected values.\n * @example\n * const schema = number().custom(oneOfValues([5, 4])); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 4); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:oneOfValues'\n */\nexport const oneOfValues =\n (expected: unknown[]): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (!expected.includes(received)) guardException(expected, received, ctx, oneOfValuesErrorKey);\n };\n\noneOfValues.key = oneOfValuesErrorKey;\noneOfValues.message = oneOfValuesErrorMessage;\nsetToDefaultLocale(oneOfValues);\n"],"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":["../src/schemas/ArraySchema.ts"],"sourcesContent":["import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class ArraySchema extends CommonSchema {\n protected _array = 1;\n constructor(ctx: ValidatorContext, arraySchema: CommonSchema) {\n super(ctx);\n this.validateArrayEntry(arraySchema);\n this[ctxSymbol].array = arraySchema;\n }\n\n private validateArrayEntry(arraySchema: CommonSchema) {\n if (!arraySchema) throw new BuildSchemaError('Missing schema in array method');\n if (!(arraySchema instanceof CommonSchema)) throw new BuildSchemaError('Invalid schema in array method');\n }\n}\n"],"mappings":";;;;;;;;;;;AAIO,IAAM,cAAN,cAA0B,aAAa;AAAA,EAClC,SAAS;AAAA,EACnB,YAAY,KAAuB,aAA2B;AAC5D,UAAM,GAAG;AACT,SAAK,mBAAmB,WAAW;AACnC,SAAK,SAAS,EAAE,QAAQ;AAAA,EAC1B;AAAA,EAEQ,mBAAmB,aAA2B;AACpD,QAAI,CAAC,YAAa,OAAM,IAAI,iBAAiB,gCAAgC;AAC7E,QAAI,EAAE,uBAAuB,cAAe,OAAM,IAAI,iBAAiB,gCAAgC;AAAA,EACzG;AACF;","names":[]}
|
package/lib/chunk-MHBY5OIQ.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CommonSchema
|
|
3
|
-
} from "./chunk-7NBOVYSP.mjs";
|
|
4
|
-
import {
|
|
5
|
-
ctxSymbol
|
|
6
|
-
} from "./chunk-BNCT7NOR.mjs";
|
|
7
|
-
|
|
8
|
-
// src/schemas/DateSchema.ts
|
|
9
|
-
var DateSchema = class extends CommonSchema {
|
|
10
|
-
_date = 1;
|
|
11
|
-
constructor(ctx) {
|
|
12
|
-
super(ctx);
|
|
13
|
-
this[ctxSymbol].date = true;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
DateSchema
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=chunk-MHBY5OIQ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/DateSchema.ts"],"sourcesContent":["import { ctxSymbol } from '../helpers/core';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class DateSchema extends CommonSchema {\n protected _date = 1;\n\n constructor(ctx: ValidatorContext) {\n super(ctx);\n this[ctxSymbol].date = true;\n }\n}\n"],"mappings":";;;;;;;;AAGO,IAAM,aAAN,cAAyB,aAAa;AAAA,EACjC,QAAQ;AAAA,EAElB,YAAY,KAAuB;AACjC,UAAM,GAAG;AACT,SAAK,SAAS,EAAE,OAAO;AAAA,EACzB;AACF;","names":[]}
|
package/lib/chunk-MLNQZ445.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
-
|
|
3
|
-
var _chunkHP3DRZWKjs = require('./chunk-HP3DRZWK.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkIZ3CBVEEjs = require('./chunk-IZ3CBVEE.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _chunkQIDWASOCjs = require('./chunk-QIDWASOC.js');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _chunkSHJVKSEZjs = require('./chunk-SHJVKSEZ.js');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
|
|
19
|
-
|
|
20
|
-
// src/schemas/NumberSchema.ts
|
|
21
|
-
var NumberSchema = (_class = class extends _chunkSHJVKSEZjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
22
|
-
__init() {this._number = 1}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
26
|
-
*
|
|
27
|
-
* @param expectedValue - The value that the schema must exactly match.
|
|
28
|
-
* @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type
|
|
29
|
-
*
|
|
30
|
-
* @example - number().equalTo(42); // Infers the type 42
|
|
31
|
-
*/
|
|
32
|
-
equalTo(expectedValue) {
|
|
33
|
-
if (this.limit) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
34
|
-
this.limit = true;
|
|
35
|
-
_chunkQIDWASOCjs._setStrictType.call(void 0, this, expectedValue);
|
|
36
|
-
return this.custom(_chunkHP3DRZWKjs.equalTo.call(void 0, expectedValue));
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
|
|
40
|
-
*
|
|
41
|
-
* @param expectedValues - An array of values that the schema can match.
|
|
42
|
-
* @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* number().oneOfValues([5, 7]); // Infers the type 5 | 7
|
|
46
|
-
*/
|
|
47
|
-
oneOfValues(expectedValue) {
|
|
48
|
-
if (this.limit) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
49
|
-
this.limit = true;
|
|
50
|
-
_chunkQIDWASOCjs._setStrictType.call(void 0, this, expectedValue);
|
|
51
|
-
return this.custom(_chunkIZ3CBVEEjs.oneOfValues.call(void 0, expectedValue));
|
|
52
|
-
}
|
|
53
|
-
}, _class);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
exports.NumberSchema = NumberSchema;
|
|
58
|
-
//# sourceMappingURL=chunk-MLNQZ445.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-MLNQZ445.js","../src/schemas/NumberSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACXO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBACnC,QAAA,EAAU,EAAA;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,OAAA,CAA0B,aAAA,EAA2C;AAC1E,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWO,WAAA,CAA8B,aAAA,EAA6C;AAChF,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADWA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-MLNQZ445.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { WithBGuardType } from '../commonTypes';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n protected _number = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - number().equalTo(42); // Infers the type 42\n */\n public equalTo<Y extends number>(expectedValue: Y): WithBGuardType<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n public oneOfValues<Y extends number>(expectedValue: Y[]): WithBGuardType<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithBGuardType<this, Y>;\n }\n}\n"]}
|
package/lib/chunk-QIDWASOC.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkX762EUSZjs = require('./chunk-X762EUSZ.js');
|
|
4
|
-
|
|
5
|
-
// src/helpers/setStrictType.ts
|
|
6
|
-
function _setStrictType(that, val) {
|
|
7
|
-
that[_chunkX762EUSZjs.ctxSymbol].strictType = true;
|
|
8
|
-
that[_chunkX762EUSZjs.ctxSymbol].strictTypeValue = val;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports._setStrictType = _setStrictType;
|
|
14
|
-
//# sourceMappingURL=chunk-QIDWASOC.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-QIDWASOC.js","../src/helpers/setStrictType.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACDO,SAAS,cAAA,CAAe,IAAA,EAAoB,GAAA,EAAc;AAC/D,EAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,EAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,gBAAA,EAAkB,GAAA;AACpC;ADGA;AACA;AACE;AACF,wCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-QIDWASOC.js","sourcesContent":[null,"import { ctxSymbol } from './core';\nimport type { CommonSchema } from '../schemas/CommonSchema';\n\nexport function _setStrictType(that: CommonSchema, val: unknown) {\n that[ctxSymbol].strictType = true;\n that[ctxSymbol].strictTypeValue = val;\n}\n"]}
|