bguard 0.6.0 → 0.7.1
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 +589 -5
- package/lib/InferType.d.mts +37 -3
- package/lib/InferType.d.ts +37 -3
- package/lib/asserts/array/index.d.mts +2 -1
- package/lib/asserts/array/index.d.ts +2 -1
- package/lib/asserts/array/index.js +8 -6
- package/lib/asserts/array/index.js.map +1 -1
- package/lib/asserts/array/index.mjs +7 -5
- package/lib/asserts/array/maxArrayLength.d.mts +2 -1
- package/lib/asserts/array/maxArrayLength.d.ts +2 -1
- package/lib/asserts/array/maxArrayLength.js +5 -4
- package/lib/asserts/array/maxArrayLength.js.map +1 -1
- package/lib/asserts/array/maxArrayLength.mjs +4 -3
- package/lib/asserts/array/minArrayLength.d.mts +2 -1
- package/lib/asserts/array/minArrayLength.d.ts +2 -1
- package/lib/asserts/array/minArrayLength.js +5 -4
- package/lib/asserts/array/minArrayLength.js.map +1 -1
- package/lib/asserts/array/minArrayLength.mjs +4 -3
- package/lib/asserts/bigint/bigintMax.d.mts +2 -1
- package/lib/asserts/bigint/bigintMax.d.ts +2 -1
- package/lib/asserts/bigint/bigintMax.js +4 -4
- package/lib/asserts/bigint/bigintMax.mjs +3 -3
- package/lib/asserts/bigint/bigintMaxExcluded.d.mts +2 -1
- package/lib/asserts/bigint/bigintMaxExcluded.d.ts +2 -1
- package/lib/asserts/bigint/bigintMaxExcluded.js +4 -4
- package/lib/asserts/bigint/bigintMaxExcluded.mjs +3 -3
- package/lib/asserts/bigint/bigintMin.d.mts +2 -1
- package/lib/asserts/bigint/bigintMin.d.ts +2 -1
- package/lib/asserts/bigint/bigintMin.js +4 -4
- package/lib/asserts/bigint/bigintMin.mjs +3 -3
- package/lib/asserts/bigint/bigintMinExcluded.d.mts +2 -1
- package/lib/asserts/bigint/bigintMinExcluded.d.ts +2 -1
- package/lib/asserts/bigint/bigintMinExcluded.js +4 -4
- package/lib/asserts/bigint/bigintMinExcluded.mjs +3 -3
- package/lib/asserts/bigint/index.d.mts +9 -4
- package/lib/asserts/bigint/index.d.ts +9 -4
- package/lib/asserts/bigint/index.js +11 -9
- package/lib/asserts/bigint/index.js.map +1 -1
- package/lib/asserts/bigint/index.mjs +10 -8
- package/lib/asserts/boolean/index.d.mts +10 -3
- package/lib/asserts/boolean/index.d.ts +10 -3
- package/lib/asserts/boolean/index.js +9 -7
- package/lib/asserts/boolean/index.js.map +1 -1
- package/lib/asserts/boolean/index.mjs +8 -6
- package/lib/asserts/coerce/bigint.d.mts +32 -0
- package/lib/asserts/coerce/bigint.d.ts +32 -0
- package/lib/asserts/coerce/bigint.js +16 -0
- package/lib/asserts/coerce/bigint.js.map +1 -0
- package/lib/asserts/coerce/bigint.mjs +16 -0
- package/lib/asserts/coerce/bigint.mjs.map +1 -0
- package/lib/asserts/coerce/boolean.d.mts +35 -0
- package/lib/asserts/coerce/boolean.d.ts +35 -0
- package/lib/asserts/coerce/boolean.js +14 -0
- package/lib/asserts/coerce/boolean.js.map +1 -0
- package/lib/asserts/coerce/boolean.mjs +14 -0
- package/lib/asserts/coerce/boolean.mjs.map +1 -0
- package/lib/asserts/coerce/date.d.mts +32 -0
- package/lib/asserts/coerce/date.d.ts +32 -0
- package/lib/asserts/coerce/date.js +13 -0
- package/lib/asserts/coerce/date.js.map +1 -0
- package/lib/asserts/coerce/date.mjs +13 -0
- package/lib/asserts/coerce/date.mjs.map +1 -0
- package/lib/asserts/coerce/index.d.mts +41 -0
- package/lib/asserts/coerce/index.d.ts +41 -0
- package/lib/asserts/coerce/index.js +41 -0
- package/lib/asserts/coerce/index.js.map +1 -0
- package/lib/asserts/coerce/index.mjs +41 -0
- package/lib/asserts/coerce/index.mjs.map +1 -0
- package/lib/asserts/coerce/number.d.mts +33 -0
- package/lib/asserts/coerce/number.d.ts +33 -0
- package/lib/asserts/coerce/number.js +16 -0
- package/lib/asserts/coerce/number.js.map +1 -0
- package/lib/asserts/coerce/number.mjs +16 -0
- package/lib/asserts/coerce/number.mjs.map +1 -0
- package/lib/asserts/coerce/string.d.mts +30 -0
- package/lib/asserts/coerce/string.d.ts +30 -0
- package/lib/asserts/coerce/string.js +17 -0
- package/lib/asserts/coerce/string.js.map +1 -0
- package/lib/asserts/coerce/string.mjs +17 -0
- package/lib/asserts/coerce/string.mjs.map +1 -0
- package/lib/asserts/date/dateMax.d.mts +2 -1
- package/lib/asserts/date/dateMax.d.ts +2 -1
- package/lib/asserts/date/dateMax.js +4 -4
- package/lib/asserts/date/dateMax.mjs +3 -3
- package/lib/asserts/date/dateMin.d.mts +2 -1
- package/lib/asserts/date/dateMin.d.ts +2 -1
- package/lib/asserts/date/dateMin.js +4 -4
- package/lib/asserts/date/dateMin.mjs +3 -3
- package/lib/asserts/date/index.d.mts +2 -1
- package/lib/asserts/date/index.d.ts +2 -1
- package/lib/asserts/date/index.js +8 -6
- package/lib/asserts/date/index.js.map +1 -1
- package/lib/asserts/date/index.mjs +7 -5
- package/lib/asserts/intersection/index.d.mts +36 -0
- package/lib/asserts/intersection/index.d.ts +36 -0
- package/lib/asserts/intersection/index.js +13 -0
- package/lib/asserts/intersection/index.js.map +1 -0
- package/lib/asserts/intersection/index.mjs +13 -0
- package/lib/asserts/intersection/index.mjs.map +1 -0
- package/lib/asserts/lazy/index.d.mts +42 -0
- package/lib/asserts/lazy/index.d.ts +42 -0
- package/lib/asserts/lazy/index.js +12 -0
- package/lib/asserts/lazy/index.js.map +1 -0
- package/lib/asserts/lazy/index.mjs +12 -0
- package/lib/asserts/lazy/index.mjs.map +1 -0
- package/lib/asserts/mix/equalTo.d.mts +2 -1
- package/lib/asserts/mix/equalTo.d.ts +2 -1
- package/lib/asserts/mix/equalTo.js +4 -4
- package/lib/asserts/mix/equalTo.mjs +3 -3
- package/lib/asserts/mix/index.d.mts +10 -3
- package/lib/asserts/mix/index.d.ts +10 -3
- package/lib/asserts/mix/index.js +6 -6
- package/lib/asserts/mix/index.mjs +5 -5
- package/lib/asserts/mix/oneOfValues.d.mts +2 -1
- package/lib/asserts/mix/oneOfValues.d.ts +2 -1
- package/lib/asserts/mix/oneOfValues.js +4 -4
- package/lib/asserts/mix/oneOfValues.mjs +3 -3
- package/lib/asserts/number/index.d.mts +4 -3
- package/lib/asserts/number/index.d.ts +4 -3
- package/lib/asserts/number/index.js +11 -9
- package/lib/asserts/number/index.js.map +1 -1
- package/lib/asserts/number/index.mjs +10 -8
- package/lib/asserts/number/max.d.mts +2 -1
- package/lib/asserts/number/max.d.ts +2 -1
- package/lib/asserts/number/max.js +5 -4
- package/lib/asserts/number/max.js.map +1 -1
- package/lib/asserts/number/max.mjs +4 -3
- package/lib/asserts/number/maxExcluded.d.mts +2 -1
- package/lib/asserts/number/maxExcluded.d.ts +2 -1
- package/lib/asserts/number/maxExcluded.js +5 -4
- package/lib/asserts/number/maxExcluded.js.map +1 -1
- package/lib/asserts/number/maxExcluded.mjs +4 -3
- package/lib/asserts/number/min.d.mts +2 -1
- package/lib/asserts/number/min.d.ts +2 -1
- package/lib/asserts/number/min.js +5 -4
- package/lib/asserts/number/min.js.map +1 -1
- package/lib/asserts/number/min.mjs +4 -3
- package/lib/asserts/number/minExcluded.d.mts +2 -1
- package/lib/asserts/number/minExcluded.d.ts +2 -1
- package/lib/asserts/number/minExcluded.js +5 -4
- package/lib/asserts/number/minExcluded.js.map +1 -1
- package/lib/asserts/number/minExcluded.mjs +4 -3
- package/lib/asserts/number/negative.d.mts +2 -1
- package/lib/asserts/number/negative.d.ts +2 -1
- package/lib/asserts/number/negative.js +5 -4
- package/lib/asserts/number/negative.js.map +1 -1
- package/lib/asserts/number/negative.mjs +4 -3
- package/lib/asserts/number/positive.d.mts +2 -1
- package/lib/asserts/number/positive.d.ts +2 -1
- package/lib/asserts/number/positive.js +5 -4
- package/lib/asserts/number/positive.js.map +1 -1
- package/lib/asserts/number/positive.mjs +4 -3
- package/lib/asserts/object/extend.d.mts +29 -0
- package/lib/asserts/object/extend.d.ts +29 -0
- package/lib/asserts/object/extend.js +14 -0
- package/lib/asserts/object/extend.js.map +1 -0
- package/lib/asserts/object/extend.mjs +14 -0
- package/lib/asserts/object/extend.mjs.map +1 -0
- package/lib/asserts/object/index.d.mts +3 -2
- package/lib/asserts/object/index.d.ts +3 -2
- package/lib/asserts/object/index.js +8 -6
- package/lib/asserts/object/index.js.map +1 -1
- package/lib/asserts/object/index.mjs +7 -5
- package/lib/asserts/object/maxKeys.d.mts +2 -1
- package/lib/asserts/object/maxKeys.d.ts +2 -1
- package/lib/asserts/object/maxKeys.js +5 -4
- package/lib/asserts/object/maxKeys.js.map +1 -1
- package/lib/asserts/object/maxKeys.mjs +4 -3
- package/lib/asserts/object/omit.d.mts +27 -0
- package/lib/asserts/object/omit.d.ts +27 -0
- package/lib/asserts/object/omit.js +14 -0
- package/lib/asserts/object/omit.js.map +1 -0
- package/lib/asserts/object/omit.mjs +14 -0
- package/lib/asserts/object/omit.mjs.map +1 -0
- package/lib/asserts/object/partial.d.mts +34 -0
- package/lib/asserts/object/partial.d.ts +34 -0
- package/lib/asserts/object/partial.js +14 -0
- package/lib/asserts/object/partial.js.map +1 -0
- package/lib/asserts/object/partial.mjs +14 -0
- package/lib/asserts/object/partial.mjs.map +1 -0
- package/lib/asserts/object/pick.d.mts +32 -0
- package/lib/asserts/object/pick.d.ts +32 -0
- package/lib/asserts/object/pick.js +17 -0
- package/lib/asserts/object/pick.js.map +1 -0
- package/lib/asserts/object/pick.mjs +17 -0
- package/lib/asserts/object/pick.mjs.map +1 -0
- package/lib/asserts/object/required.d.mts +39 -0
- package/lib/asserts/object/required.d.ts +39 -0
- package/lib/asserts/object/required.js +14 -0
- package/lib/asserts/object/required.js.map +1 -0
- package/lib/asserts/object/required.mjs +14 -0
- package/lib/asserts/object/required.mjs.map +1 -0
- package/lib/asserts/record/index.d.mts +28 -0
- package/lib/asserts/record/index.d.ts +28 -0
- package/lib/asserts/record/index.js +12 -0
- package/lib/asserts/record/index.js.map +1 -0
- package/lib/asserts/record/index.mjs +12 -0
- package/lib/asserts/record/index.mjs.map +1 -0
- package/lib/asserts/string/atLeastOneDigit.d.mts +2 -1
- package/lib/asserts/string/atLeastOneDigit.d.ts +2 -1
- package/lib/asserts/string/atLeastOneDigit.js +4 -4
- package/lib/asserts/string/atLeastOneDigit.mjs +3 -3
- package/lib/asserts/string/atLeastOneLowerChar.d.mts +2 -1
- package/lib/asserts/string/atLeastOneLowerChar.d.ts +2 -1
- package/lib/asserts/string/atLeastOneLowerChar.js +4 -4
- package/lib/asserts/string/atLeastOneLowerChar.mjs +3 -3
- package/lib/asserts/string/atLeastOneSpecialChar.d.mts +2 -1
- package/lib/asserts/string/atLeastOneSpecialChar.d.ts +2 -1
- package/lib/asserts/string/atLeastOneSpecialChar.js +4 -4
- package/lib/asserts/string/atLeastOneSpecialChar.mjs +3 -3
- package/lib/asserts/string/atLeastOneUpperChar.d.mts +2 -1
- package/lib/asserts/string/atLeastOneUpperChar.d.ts +2 -1
- package/lib/asserts/string/atLeastOneUpperChar.js +4 -4
- package/lib/asserts/string/atLeastOneUpperChar.mjs +3 -3
- package/lib/asserts/string/contains.d.mts +2 -1
- package/lib/asserts/string/contains.d.ts +2 -1
- package/lib/asserts/string/contains.js +4 -4
- package/lib/asserts/string/contains.mjs +3 -3
- package/lib/asserts/string/email.d.mts +2 -1
- package/lib/asserts/string/email.d.ts +2 -1
- package/lib/asserts/string/email.js +5 -4
- package/lib/asserts/string/email.js.map +1 -1
- package/lib/asserts/string/email.mjs +4 -3
- package/lib/asserts/string/endsWith.d.mts +2 -1
- package/lib/asserts/string/endsWith.d.ts +2 -1
- package/lib/asserts/string/endsWith.js +4 -4
- package/lib/asserts/string/endsWith.mjs +3 -3
- package/lib/asserts/string/index.d.mts +9 -4
- package/lib/asserts/string/index.d.ts +9 -4
- package/lib/asserts/string/index.js +12 -9
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +11 -8
- package/lib/asserts/string/isValidDate.d.mts +2 -1
- package/lib/asserts/string/isValidDate.d.ts +2 -1
- package/lib/asserts/string/isValidDate.js +5 -4
- package/lib/asserts/string/isValidDate.js.map +1 -1
- package/lib/asserts/string/isValidDate.mjs +4 -3
- package/lib/asserts/string/isValidDateTime.d.mts +2 -1
- package/lib/asserts/string/isValidDateTime.d.ts +2 -1
- package/lib/asserts/string/isValidDateTime.js +5 -4
- package/lib/asserts/string/isValidDateTime.js.map +1 -1
- package/lib/asserts/string/isValidDateTime.mjs +4 -3
- package/lib/asserts/string/isValidTime.d.mts +2 -1
- package/lib/asserts/string/isValidTime.d.ts +2 -1
- package/lib/asserts/string/isValidTime.js +5 -4
- package/lib/asserts/string/isValidTime.js.map +1 -1
- package/lib/asserts/string/isValidTime.mjs +4 -3
- package/lib/asserts/string/lowerCase.d.mts +2 -1
- package/lib/asserts/string/lowerCase.d.ts +2 -1
- package/lib/asserts/string/lowerCase.js +4 -4
- package/lib/asserts/string/lowerCase.mjs +3 -3
- package/lib/asserts/string/maxLength.d.mts +2 -1
- package/lib/asserts/string/maxLength.d.ts +2 -1
- package/lib/asserts/string/maxLength.js +5 -4
- package/lib/asserts/string/maxLength.js.map +1 -1
- package/lib/asserts/string/maxLength.mjs +4 -3
- package/lib/asserts/string/minLength.d.mts +2 -1
- package/lib/asserts/string/minLength.d.ts +2 -1
- package/lib/asserts/string/minLength.js +5 -4
- package/lib/asserts/string/minLength.js.map +1 -1
- package/lib/asserts/string/minLength.mjs +4 -3
- package/lib/asserts/string/regExp.d.mts +2 -1
- package/lib/asserts/string/regExp.d.ts +2 -1
- package/lib/asserts/string/regExp.js +5 -4
- package/lib/asserts/string/regExp.js.map +1 -1
- package/lib/asserts/string/regExp.mjs +4 -3
- package/lib/asserts/string/startsWith.d.mts +2 -1
- package/lib/asserts/string/startsWith.d.ts +2 -1
- package/lib/asserts/string/startsWith.js +4 -4
- package/lib/asserts/string/startsWith.mjs +3 -3
- package/lib/asserts/string/upperCase.d.mts +2 -1
- package/lib/asserts/string/upperCase.d.ts +2 -1
- package/lib/asserts/string/upperCase.js +4 -4
- package/lib/asserts/string/upperCase.mjs +3 -3
- package/lib/asserts/string/uuid.d.mts +2 -1
- package/lib/asserts/string/uuid.d.ts +2 -1
- package/lib/asserts/string/uuid.js +5 -4
- package/lib/asserts/string/uuid.js.map +1 -1
- package/lib/asserts/string/uuid.mjs +4 -3
- package/lib/asserts/string/uuidV1.d.mts +2 -1
- package/lib/asserts/string/uuidV1.d.ts +2 -1
- package/lib/asserts/string/uuidV1.js +4 -4
- package/lib/asserts/string/uuidV1.mjs +3 -3
- package/lib/asserts/string/uuidV2.d.mts +2 -1
- package/lib/asserts/string/uuidV2.d.ts +2 -1
- package/lib/asserts/string/uuidV2.js +4 -4
- package/lib/asserts/string/uuidV2.mjs +3 -3
- package/lib/asserts/string/uuidV3.d.mts +2 -1
- package/lib/asserts/string/uuidV3.d.ts +2 -1
- package/lib/asserts/string/uuidV3.js +4 -4
- package/lib/asserts/string/uuidV3.mjs +3 -3
- package/lib/asserts/string/uuidV4.d.mts +2 -1
- package/lib/asserts/string/uuidV4.d.ts +2 -1
- package/lib/asserts/string/uuidV4.js +4 -4
- package/lib/asserts/string/uuidV4.mjs +3 -3
- package/lib/asserts/string/uuidV5.d.mts +2 -1
- package/lib/asserts/string/uuidV5.d.ts +2 -1
- package/lib/asserts/string/uuidV5.js +4 -4
- package/lib/asserts/string/uuidV5.mjs +3 -3
- package/lib/asserts/string/validUrl.d.mts +2 -1
- package/lib/asserts/string/validUrl.d.ts +2 -1
- package/lib/asserts/string/validUrl.js +5 -4
- package/lib/asserts/string/validUrl.js.map +1 -1
- package/lib/asserts/string/validUrl.mjs +4 -3
- package/lib/asserts/tuple/index.d.mts +28 -0
- package/lib/asserts/tuple/index.d.ts +28 -0
- package/lib/asserts/tuple/index.js +12 -0
- package/lib/asserts/tuple/index.js.map +1 -0
- package/lib/asserts/tuple/index.mjs +12 -0
- package/lib/asserts/tuple/index.mjs.map +1 -0
- package/lib/asserts/union/index.d.mts +29 -0
- package/lib/asserts/union/index.d.ts +29 -0
- package/lib/asserts/union/index.js +12 -0
- package/lib/asserts/union/index.js.map +1 -0
- package/lib/asserts/union/index.mjs +12 -0
- package/lib/asserts/union/index.mjs.map +1 -0
- package/lib/chunk-23R5R7PL.js +69 -0
- package/lib/chunk-23R5R7PL.js.map +1 -0
- package/lib/{chunk-Y5MNJGFX.js → chunk-2AYQ7GRP.js} +9 -6
- package/lib/chunk-2AYQ7GRP.js.map +1 -0
- package/lib/{chunk-OMSHZITC.js → chunk-2KLV3CHA.js} +3 -3
- package/lib/{chunk-OMSHZITC.js.map → chunk-2KLV3CHA.js.map} +1 -1
- package/lib/{chunk-MHWPSQB3.js → chunk-2X6V3ODY.js} +3 -3
- package/lib/{chunk-MHWPSQB3.js.map → chunk-2X6V3ODY.js.map} +1 -1
- package/lib/{chunk-QIFA6S5U.mjs → chunk-346TIMNH.mjs} +2 -2
- package/lib/{chunk-QIFA6S5U.mjs.map → chunk-346TIMNH.mjs.map} +1 -1
- package/lib/{chunk-PAV4SQQL.js → chunk-3D6TPN7F.js} +3 -3
- package/lib/{chunk-PAV4SQQL.js.map → chunk-3D6TPN7F.js.map} +1 -1
- package/lib/{chunk-4UPXP4I3.js → chunk-3OAUE5VW.js} +8 -5
- package/lib/chunk-3OAUE5VW.js.map +1 -0
- package/lib/chunk-3PTVMZY7.js +22 -0
- package/lib/chunk-3PTVMZY7.js.map +1 -0
- package/lib/{chunk-QEG24G7E.mjs → chunk-3T5QKF7X.mjs} +2 -2
- package/lib/{chunk-QEG24G7E.mjs.map → chunk-3T5QKF7X.mjs.map} +1 -1
- package/lib/{chunk-FI737YZJ.js → chunk-45K4AUO3.js} +9 -6
- package/lib/chunk-45K4AUO3.js.map +1 -0
- package/lib/{chunk-PNSDUVRE.mjs → chunk-4AZOGLHD.mjs} +2 -2
- package/lib/{chunk-PNSDUVRE.mjs.map → chunk-4AZOGLHD.mjs.map} +1 -1
- package/lib/chunk-4PPMVVQY.js +67 -0
- package/lib/chunk-4PPMVVQY.js.map +1 -0
- package/lib/{chunk-HWVM4SYU.mjs → chunk-54F462SS.mjs} +7 -4
- package/lib/chunk-54F462SS.mjs.map +1 -0
- package/lib/{chunk-S4FWDTEW.mjs → chunk-55P4YTMX.mjs} +2 -2
- package/lib/{chunk-S4FWDTEW.mjs.map → chunk-55P4YTMX.mjs.map} +1 -1
- package/lib/chunk-56TWNROC.js +20 -0
- package/lib/chunk-56TWNROC.js.map +1 -0
- package/lib/chunk-5PIGAEGL.mjs +22 -0
- package/lib/chunk-5PIGAEGL.mjs.map +1 -0
- package/lib/{chunk-NFD7D5GZ.mjs → chunk-5PXMSVTE.mjs} +30 -22
- package/lib/chunk-5PXMSVTE.mjs.map +1 -0
- package/lib/{chunk-ZGUF5ZDP.mjs → chunk-5U5CYDRB.mjs} +2 -2
- package/lib/{chunk-ZGUF5ZDP.mjs.map → chunk-5U5CYDRB.mjs.map} +1 -1
- package/lib/{chunk-V7C77FML.mjs → chunk-5WLWZKC6.mjs} +7 -4
- package/lib/chunk-5WLWZKC6.mjs.map +1 -0
- package/lib/{chunk-GFWZQ4XW.mjs → chunk-5WV7FMW7.mjs} +8 -5
- package/lib/chunk-5WV7FMW7.mjs.map +1 -0
- package/lib/{chunk-OE3L7EKN.mjs → chunk-65X7NTUS.mjs} +18 -9
- package/lib/chunk-65X7NTUS.mjs.map +1 -0
- package/lib/chunk-6LUSV3SS.js +595 -0
- package/lib/chunk-6LUSV3SS.js.map +1 -0
- package/lib/{chunk-BRFUFNU4.js → chunk-7A4RN5UD.js} +9 -6
- package/lib/chunk-7A4RN5UD.js.map +1 -0
- package/lib/{chunk-ENZ5WDUQ.js → chunk-7CNZKYPM.js} +8 -5
- package/lib/chunk-7CNZKYPM.js.map +1 -0
- package/lib/{chunk-NS4GXUCA.mjs → chunk-7F4P72SG.mjs} +2 -2
- package/lib/{chunk-NS4GXUCA.mjs.map → chunk-7F4P72SG.mjs.map} +1 -1
- package/lib/{chunk-6WKSLMJG.mjs → chunk-A2LPSUNQ.mjs} +8 -7
- package/lib/{chunk-6WKSLMJG.mjs.map → chunk-A2LPSUNQ.mjs.map} +1 -1
- package/lib/chunk-A36G62K5.mjs +49 -0
- package/lib/chunk-A36G62K5.mjs.map +1 -0
- package/lib/{chunk-24LO7MNY.js → chunk-A5OEVSSV.js} +8 -5
- package/lib/chunk-A5OEVSSV.js.map +1 -0
- package/lib/{chunk-KRCOKWAB.mjs → chunk-ABSZMCDX.mjs} +8 -5
- package/lib/chunk-ABSZMCDX.mjs.map +1 -0
- package/lib/chunk-AGB5RWYD.js +32 -0
- package/lib/chunk-AGB5RWYD.js.map +1 -0
- package/lib/{chunk-PVQALO2H.js → chunk-ALXDH7GS.js} +3 -3
- package/lib/{chunk-PVQALO2H.js.map → chunk-ALXDH7GS.js.map} +1 -1
- package/lib/chunk-AO6DKPJZ.js +49 -0
- package/lib/chunk-AO6DKPJZ.js.map +1 -0
- package/lib/{chunk-TQDMUHTA.mjs → chunk-AYJCGPXI.mjs} +2 -2
- package/lib/{chunk-TQDMUHTA.mjs.map → chunk-AYJCGPXI.mjs.map} +1 -1
- package/lib/{chunk-OSFIPFQ3.mjs → chunk-AYSJLD4S.mjs} +5 -5
- package/lib/{chunk-OSFIPFQ3.mjs.map → chunk-AYSJLD4S.mjs.map} +1 -1
- package/lib/chunk-B3IWQRZF.mjs +22 -0
- package/lib/chunk-B3IWQRZF.mjs.map +1 -0
- package/lib/{chunk-DCPRPCZ3.js → chunk-B4WB3UB7.js} +3 -3
- package/lib/{chunk-DCPRPCZ3.js.map → chunk-B4WB3UB7.js.map} +1 -1
- package/lib/chunk-BZ6R6RWE.mjs +19 -0
- package/lib/chunk-BZ6R6RWE.mjs.map +1 -0
- package/lib/{chunk-MCQHWS3E.mjs → chunk-C6ICGQEX.mjs} +7 -4
- package/lib/chunk-C6ICGQEX.mjs.map +1 -0
- package/lib/{chunk-2ANPCB4O.mjs → chunk-C76DLZFD.mjs} +2 -2
- package/lib/{chunk-2ANPCB4O.mjs.map → chunk-C76DLZFD.mjs.map} +1 -1
- package/lib/chunk-CLRHVTVY.js +50 -0
- package/lib/chunk-CLRHVTVY.js.map +1 -0
- package/lib/{chunk-QMIH3A4D.js → chunk-CWYS6MUA.js} +3 -3
- package/lib/{chunk-QMIH3A4D.js.map → chunk-CWYS6MUA.js.map} +1 -1
- package/lib/{chunk-W3U7RYLP.mjs → chunk-D42AL6CN.mjs} +2 -2
- package/lib/{chunk-W3U7RYLP.mjs.map → chunk-D42AL6CN.mjs.map} +1 -1
- package/lib/{chunk-YDTQASAY.mjs → chunk-D4YY45O2.mjs} +8 -5
- package/lib/chunk-D4YY45O2.mjs.map +1 -0
- package/lib/{chunk-WLPDAJB3.js → chunk-DKGRAVID.js} +29 -11
- package/lib/chunk-DKGRAVID.js.map +1 -0
- package/lib/{chunk-TZBAW5OO.mjs → chunk-DLEDKNPD.mjs} +2 -2
- package/lib/{chunk-TZBAW5OO.mjs.map → chunk-DLEDKNPD.mjs.map} +1 -1
- package/lib/{chunk-OZ3BTSSQ.mjs → chunk-DS2LUTTF.mjs} +23 -20
- package/lib/chunk-DS2LUTTF.mjs.map +1 -0
- package/lib/{chunk-6JPYR2TS.js → chunk-ECLNZ233.js} +9 -6
- package/lib/chunk-ECLNZ233.js.map +1 -0
- package/lib/chunk-EEKYR5IA.js +19 -0
- package/lib/chunk-EEKYR5IA.js.map +1 -0
- package/lib/chunk-EI6TQG4L.js +80 -0
- package/lib/chunk-EI6TQG4L.js.map +1 -0
- package/lib/{chunk-6LPQRAFN.js → chunk-EN745GWN.js} +10 -7
- package/lib/chunk-EN745GWN.js.map +1 -0
- package/lib/chunk-ET2I4EXQ.mjs +18 -0
- package/lib/chunk-ET2I4EXQ.mjs.map +1 -0
- package/lib/{chunk-OFZMO7PB.mjs → chunk-ETBJ4NF4.mjs} +7 -4
- package/lib/chunk-ETBJ4NF4.mjs.map +1 -0
- package/lib/chunk-FA3S35LQ.mjs +20 -0
- package/lib/chunk-FA3S35LQ.mjs.map +1 -0
- package/lib/{chunk-23QTSXPQ.js → chunk-FJEBPEGR.js} +8 -5
- package/lib/chunk-FJEBPEGR.js.map +1 -0
- package/lib/chunk-FTHEF6SB.js +14 -0
- package/lib/{chunk-XDVSL5B6.js.map → chunk-FTHEF6SB.js.map} +1 -1
- package/lib/{chunk-WYM2TIVW.mjs → chunk-FU5WAVRB.mjs} +5 -4
- package/lib/{chunk-WYM2TIVW.mjs.map → chunk-FU5WAVRB.mjs.map} +1 -1
- package/lib/chunk-G2VC3SQB.js +22 -0
- package/lib/chunk-G2VC3SQB.js.map +1 -0
- package/lib/{chunk-NOJB5GBZ.mjs → chunk-G6YZVGWC.mjs} +8 -5
- package/lib/chunk-G6YZVGWC.mjs.map +1 -0
- package/lib/{chunk-Z2HZXSDA.js → chunk-GSLVYDXO.js} +3 -3
- package/lib/{chunk-Z2HZXSDA.js.map → chunk-GSLVYDXO.js.map} +1 -1
- package/lib/{chunk-H4OW6OUF.js → chunk-GTGXSQKC.js} +3 -3
- package/lib/{chunk-H4OW6OUF.js.map → chunk-GTGXSQKC.js.map} +1 -1
- package/lib/{chunk-Z3NPFUIA.mjs → chunk-H3FXZTYS.mjs} +2 -2
- package/lib/{chunk-Z3NPFUIA.mjs.map → chunk-H3FXZTYS.mjs.map} +1 -1
- package/lib/{chunk-T2A3XXQZ.mjs → chunk-HKDDJSN2.mjs} +8 -5
- package/lib/chunk-HKDDJSN2.mjs.map +1 -0
- package/lib/chunk-HU5SDECP.js +29 -0
- package/lib/chunk-HU5SDECP.js.map +1 -0
- package/lib/{chunk-THU5VBSO.mjs → chunk-IIL6D2UL.mjs} +2 -2
- package/lib/{chunk-AJHBPMZT.mjs → chunk-IWNVHB2K.mjs} +8 -5
- package/lib/chunk-IWNVHB2K.mjs.map +1 -0
- package/lib/{chunk-UYQFYQQG.mjs → chunk-J3EKIWPZ.mjs} +33 -22
- package/lib/chunk-J3EKIWPZ.mjs.map +1 -0
- package/lib/chunk-JCX2TB7E.js +13 -0
- package/lib/chunk-JCX2TB7E.js.map +1 -0
- package/lib/{chunk-2ESDKTV4.js → chunk-JF7KZZ7R.js} +9 -6
- package/lib/chunk-JF7KZZ7R.js.map +1 -0
- package/lib/chunk-JHONMWCE.js +27 -0
- package/lib/chunk-JHONMWCE.js.map +1 -0
- package/lib/{chunk-DED5KDLM.js → chunk-JLEQOYDW.js} +15 -13
- package/lib/chunk-JLEQOYDW.js.map +1 -0
- package/lib/{chunk-HD37VXPZ.mjs → chunk-JND3VAPR.mjs} +2 -2
- package/lib/{chunk-HD37VXPZ.mjs.map → chunk-JND3VAPR.mjs.map} +1 -1
- package/lib/chunk-K4YXIN2V.mjs +33 -0
- package/lib/chunk-K4YXIN2V.mjs.map +1 -0
- package/lib/{chunk-NY2TPU6O.mjs → chunk-K6QYFFMX.mjs} +8 -5
- package/lib/chunk-K6QYFFMX.mjs.map +1 -0
- package/lib/chunk-K7CDOU6F.js +13 -0
- package/lib/chunk-K7CDOU6F.js.map +1 -0
- package/lib/{chunk-M3HYPZLE.mjs → chunk-KAFZGQ2W.mjs} +10 -8
- package/lib/chunk-KAFZGQ2W.mjs.map +1 -0
- package/lib/chunk-KALHMMEN.mjs +29 -0
- package/lib/chunk-KALHMMEN.mjs.map +1 -0
- package/lib/{chunk-DFYP4GKE.js → chunk-KDPYWGMJ.js} +8 -5
- package/lib/chunk-KDPYWGMJ.js.map +1 -0
- package/lib/chunk-KGXWQ3XP.mjs +69 -0
- package/lib/chunk-KGXWQ3XP.mjs.map +1 -0
- package/lib/{chunk-R25HSJPH.js → chunk-KIVIWBIY.js} +3 -3
- package/lib/{chunk-R25HSJPH.js.map → chunk-KIVIWBIY.js.map} +1 -1
- package/lib/{chunk-ZNQHNLKW.js → chunk-KZBW5WCK.js} +8 -5
- package/lib/chunk-KZBW5WCK.js.map +1 -0
- package/lib/{chunk-VVXKATDH.js → chunk-L36PQXUB.js} +8 -5
- package/lib/chunk-L36PQXUB.js.map +1 -0
- package/lib/chunk-LDZFOOWN.mjs +595 -0
- package/lib/chunk-LDZFOOWN.mjs.map +1 -0
- package/lib/{chunk-AXKX5BGH.js → chunk-LHEU4XAC.js} +2 -2
- package/lib/chunk-LHEU4XAC.js.map +1 -0
- package/lib/chunk-LNBZ7SJR.js +26 -0
- package/lib/chunk-LNBZ7SJR.js.map +1 -0
- package/lib/{chunk-AQCV7PB4.mjs → chunk-M7EMQU7U.mjs} +5 -5
- package/lib/{chunk-AQCV7PB4.mjs.map → chunk-M7EMQU7U.mjs.map} +1 -1
- package/lib/{chunk-GGWJJFXY.mjs → chunk-MOHROZTD.mjs} +2 -2
- package/lib/{chunk-GGWJJFXY.mjs.map → chunk-MOHROZTD.mjs.map} +1 -1
- package/lib/{chunk-SBO6OQIX.mjs → chunk-MQGE7GIK.mjs} +8 -5
- package/lib/chunk-MQGE7GIK.mjs.map +1 -0
- package/lib/chunk-MUXY6Q45.mjs +13 -0
- package/lib/chunk-MUXY6Q45.mjs.map +1 -0
- package/lib/{chunk-H2M4FCRZ.mjs → chunk-NC7E2FQR.mjs} +2 -2
- package/lib/{chunk-H2M4FCRZ.mjs.map → chunk-NC7E2FQR.mjs.map} +1 -1
- package/lib/chunk-NM3VRT77.mjs +120 -0
- package/lib/chunk-NM3VRT77.mjs.map +1 -0
- package/lib/{chunk-OHUOBIHX.mjs → chunk-NM4TCTZM.mjs} +28 -10
- package/lib/chunk-NM4TCTZM.mjs.map +1 -0
- package/lib/chunk-NXS5ULAJ.mjs +22 -0
- package/lib/chunk-NXS5ULAJ.mjs.map +1 -0
- package/lib/{chunk-2D3HCTJV.js → chunk-NZOANK7A.js} +3 -3
- package/lib/{chunk-2D3HCTJV.js.map → chunk-NZOANK7A.js.map} +1 -1
- package/lib/{chunk-ZTCXXAKD.mjs → chunk-O2WD4JBG.mjs} +8 -2
- package/lib/chunk-O2WD4JBG.mjs.map +1 -0
- package/lib/chunk-O4FVL7CA.js +33 -0
- package/lib/chunk-O4FVL7CA.js.map +1 -0
- package/lib/{chunk-ARIYSQMH.js → chunk-OHJ2EB4T.js} +3 -3
- package/lib/{chunk-ARIYSQMH.js.map → chunk-OHJ2EB4T.js.map} +1 -1
- package/lib/{chunk-TLPVFRWR.js → chunk-OPA6AXSH.js} +3 -3
- package/lib/{chunk-TLPVFRWR.js.map → chunk-OPA6AXSH.js.map} +1 -1
- package/lib/chunk-OQB5UGWG.mjs +24 -0
- package/lib/chunk-OQB5UGWG.mjs.map +1 -0
- package/lib/{chunk-3W2COCXV.js → chunk-ORQBVFHY.js} +3 -3
- package/lib/{chunk-3W2COCXV.js.map → chunk-ORQBVFHY.js.map} +1 -1
- package/lib/{chunk-C44KAKMR.js → chunk-OW7RK5YW.js} +3 -3
- package/lib/{chunk-C44KAKMR.js.map → chunk-OW7RK5YW.js.map} +1 -1
- package/lib/{chunk-22254THF.mjs → chunk-OY5DJBRV.mjs} +2 -2
- package/lib/{chunk-22254THF.mjs.map → chunk-OY5DJBRV.mjs.map} +1 -1
- package/lib/chunk-P2SQQBVB.js +22 -0
- package/lib/chunk-P2SQQBVB.js.map +1 -0
- package/lib/chunk-P6CI5ITJ.js +22 -0
- package/lib/chunk-P6CI5ITJ.js.map +1 -0
- package/lib/{chunk-2IPGGARK.mjs → chunk-P6M6QZU5.mjs} +7 -4
- package/lib/chunk-P6M6QZU5.mjs.map +1 -0
- package/lib/{chunk-Y54K6TQO.js → chunk-PFADKWMO.js} +3 -3
- package/lib/{chunk-Y54K6TQO.js.map → chunk-PFADKWMO.js.map} +1 -1
- package/lib/chunk-POPLWPM4.mjs +19 -0
- package/lib/chunk-POPLWPM4.mjs.map +1 -0
- package/lib/{chunk-VOFKYSJD.js → chunk-POQZCV3D.js} +3 -3
- package/lib/{chunk-VOFKYSJD.js.map → chunk-POQZCV3D.js.map} +1 -1
- package/lib/{chunk-M2GOQ7TZ.mjs → chunk-QM4MJTTD.mjs} +7 -4
- package/lib/chunk-QM4MJTTD.mjs.map +1 -0
- package/lib/{chunk-WJGXVKZY.js → chunk-QNA4O6AU.js} +3 -3
- package/lib/{chunk-WJGXVKZY.js.map → chunk-QNA4O6AU.js.map} +1 -1
- package/lib/{chunk-ZDXO3TGZ.mjs → chunk-RCD6EO4Q.mjs} +7 -4
- package/lib/chunk-RCD6EO4Q.mjs.map +1 -0
- package/lib/{chunk-ZEGRYDE5.mjs → chunk-RDJK3X4J.mjs} +8 -5
- package/lib/chunk-RDJK3X4J.mjs.map +1 -0
- package/lib/{chunk-4N5J426R.mjs → chunk-RXU74KSN.mjs} +2 -2
- package/lib/{chunk-4N5J426R.mjs.map → chunk-RXU74KSN.mjs.map} +1 -1
- package/lib/{chunk-S5D5AFDF.js → chunk-S6N4N4FT.js} +9 -6
- package/lib/chunk-S6N4N4FT.js.map +1 -0
- package/lib/chunk-SBNUNRI3.mjs +13 -0
- package/lib/chunk-SBNUNRI3.mjs.map +1 -0
- package/lib/{chunk-SFIX77W5.js → chunk-SGWF66HS.js} +3 -3
- package/lib/{chunk-SFIX77W5.js.map → chunk-SGWF66HS.js.map} +1 -1
- package/lib/{chunk-OU5BTUDV.mjs → chunk-SKMDZ4S6.mjs} +2 -2
- package/lib/{chunk-OU5BTUDV.mjs.map → chunk-SKMDZ4S6.mjs.map} +1 -1
- package/lib/chunk-SVRCKC65.js +120 -0
- package/lib/chunk-SVRCKC65.js.map +1 -0
- package/lib/{chunk-OQYS7JVF.js → chunk-SY2V2V54.js} +6 -6
- package/lib/{chunk-OQYS7JVF.js.map → chunk-SY2V2V54.js.map} +1 -1
- package/lib/{chunk-YMPRYKNY.js → chunk-SZO4SUUG.js} +9 -6
- package/lib/chunk-SZO4SUUG.js.map +1 -0
- package/lib/chunk-TCHVA6VG.js +24 -0
- package/lib/chunk-TCHVA6VG.js.map +1 -0
- package/lib/chunk-TD3Y3IV3.js +13 -0
- package/lib/chunk-TD3Y3IV3.js.map +1 -0
- package/lib/{chunk-C2VSTWID.js → chunk-TJ7IQSHU.js} +9 -6
- package/lib/chunk-TJ7IQSHU.js.map +1 -0
- package/lib/{chunk-7JL66G7G.mjs → chunk-TPSWNY5K.mjs} +2 -2
- package/lib/{chunk-7JL66G7G.mjs.map → chunk-TPSWNY5K.mjs.map} +1 -1
- package/lib/chunk-UCY3HEYZ.mjs +13 -0
- package/lib/chunk-UCY3HEYZ.mjs.map +1 -0
- package/lib/{chunk-HPIF2CMT.js → chunk-UIJIIIOA.js} +9 -6
- package/lib/chunk-UIJIIIOA.js.map +1 -0
- package/lib/chunk-UMS4M7FU.mjs +22 -0
- package/lib/chunk-UMS4M7FU.mjs.map +1 -0
- package/lib/{chunk-N3EHGKZV.mjs → chunk-UN5S46LE.mjs} +7 -4
- package/lib/chunk-UN5S46LE.mjs.map +1 -0
- package/lib/chunk-UYAF7QRD.mjs +22 -0
- package/lib/chunk-UYAF7QRD.mjs.map +1 -0
- package/lib/chunk-VERUOTB3.mjs +10 -0
- package/lib/chunk-VERUOTB3.mjs.map +1 -0
- package/lib/{chunk-62EKGBXF.js → chunk-VGOAXY26.js} +8 -5
- package/lib/chunk-VGOAXY26.js.map +1 -0
- package/lib/chunk-VKSBOWCE.mjs +50 -0
- package/lib/chunk-VKSBOWCE.mjs.map +1 -0
- package/lib/chunk-VT2JBMWQ.mjs +27 -0
- package/lib/chunk-VT2JBMWQ.mjs.map +1 -0
- package/lib/{chunk-LXZTBF7F.js → chunk-VWHKNZLG.js} +3 -3
- package/lib/{chunk-LXZTBF7F.js.map → chunk-VWHKNZLG.js.map} +1 -1
- package/lib/chunk-WH7WJMFF.js +79 -0
- package/lib/chunk-WH7WJMFF.js.map +1 -0
- package/lib/{chunk-TLRVQWCI.mjs → chunk-WL7BV4XV.mjs} +9 -6
- package/lib/chunk-WL7BV4XV.mjs.map +1 -0
- package/lib/chunk-WLZZTIOV.js +18 -0
- package/lib/chunk-WLZZTIOV.js.map +1 -0
- package/lib/chunk-WOPNDC4R.js +10 -0
- package/lib/chunk-WOPNDC4R.js.map +1 -0
- package/lib/chunk-X6SI76NQ.js +22 -0
- package/lib/chunk-X6SI76NQ.js.map +1 -0
- package/lib/{chunk-UHMICS34.mjs → chunk-YETYTLAD.mjs} +2 -2
- package/lib/{chunk-UHMICS34.mjs.map → chunk-YETYTLAD.mjs.map} +1 -1
- package/lib/chunk-YJUYGFG2.mjs +26 -0
- package/lib/chunk-YJUYGFG2.mjs.map +1 -0
- package/lib/chunk-YOF36UOS.js +19 -0
- package/lib/chunk-YOF36UOS.js.map +1 -0
- package/lib/{chunk-NBR3QGKW.js → chunk-YPOEO3UF.js} +7 -6
- package/lib/chunk-YPOEO3UF.js.map +1 -0
- package/lib/{chunk-4ZKU4RJL.mjs → chunk-YQP44G45.mjs} +2 -2
- package/lib/{chunk-4ZKU4RJL.mjs.map → chunk-YQP44G45.mjs.map} +1 -1
- package/lib/{chunk-22VHHJSS.js → chunk-Z7LBOQRQ.js} +6 -6
- package/lib/{chunk-22VHHJSS.js.map → chunk-Z7LBOQRQ.js.map} +1 -1
- package/lib/{chunk-IDDU6B6T.js → chunk-ZIBHO6FI.js} +3 -3
- package/lib/{chunk-IDDU6B6T.js.map → chunk-ZIBHO6FI.js.map} +1 -1
- package/lib/{chunk-TJQ5NVL4.js → chunk-ZJGY6EOE.js} +19 -10
- package/lib/chunk-ZJGY6EOE.js.map +1 -0
- package/lib/{chunk-V2J4TQR5.mjs → chunk-ZQKVVWD5.mjs} +2 -2
- package/lib/{chunk-V2J4TQR5.mjs.map → chunk-ZQKVVWD5.mjs.map} +1 -1
- package/lib/{chunk-FIDPCCCW.js → chunk-ZWFSAKQK.js} +8 -2
- package/lib/chunk-ZWFSAKQK.js.map +1 -0
- package/lib/codeGen.d.mts +1 -0
- package/lib/codeGen.d.ts +1 -0
- package/lib/codeGen.js +3 -3
- package/lib/codeGen.mjs +2 -2
- package/lib/commonTypes.d.mts +34 -1
- package/lib/commonTypes.d.ts +34 -1
- package/lib/core.d.mts +153 -23
- package/lib/core.d.ts +153 -23
- package/lib/core.js +9 -5
- package/lib/core.js.map +1 -1
- package/lib/core.mjs +10 -6
- package/lib/exceptions.d.mts +5 -1
- package/lib/exceptions.d.ts +5 -1
- package/lib/exceptions.js +2 -2
- package/lib/exceptions.mjs +1 -1
- package/lib/formatErrors.d.mts +40 -0
- package/lib/formatErrors.d.ts +40 -0
- package/lib/formatErrors.js +9 -0
- package/lib/formatErrors.js.map +1 -0
- package/lib/formatErrors.mjs +9 -0
- package/lib/formatErrors.mjs.map +1 -0
- package/lib/helpers/constants.js +2 -2
- package/lib/helpers/constants.mjs +1 -1
- package/lib/helpers/jsonSchemaConstraint.d.mts +18 -0
- package/lib/helpers/jsonSchemaConstraint.d.ts +18 -0
- package/lib/helpers/jsonSchemaConstraint.js +7 -0
- package/lib/helpers/jsonSchemaConstraint.js.map +1 -0
- package/lib/helpers/jsonSchemaConstraint.mjs +7 -0
- package/lib/helpers/jsonSchemaConstraint.mjs.map +1 -0
- package/lib/helpers/quoteStringLiteral.d.mts +3 -0
- package/lib/helpers/quoteStringLiteral.d.ts +3 -0
- package/lib/helpers/quoteStringLiteral.js +7 -0
- package/lib/helpers/quoteStringLiteral.js.map +1 -0
- package/lib/helpers/quoteStringLiteral.mjs +7 -0
- package/lib/helpers/quoteStringLiteral.mjs.map +1 -0
- package/lib/helpers/setStrictType.d.mts +1 -0
- package/lib/helpers/setStrictType.d.ts +1 -0
- package/lib/helpers/setStrictType.js +3 -3
- package/lib/helpers/setStrictType.mjs +2 -2
- package/lib/index.d.mts +21 -2
- package/lib/index.d.ts +21 -2
- package/lib/index.js +135 -55
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +166 -86
- package/lib/standardSchema.d.mts +44 -0
- package/lib/standardSchema.d.ts +44 -0
- package/lib/standardSchema.js +1 -0
- package/lib/standardSchema.js.map +1 -0
- package/lib/standardSchema.mjs +1 -0
- package/lib/standardSchema.mjs.map +1 -0
- package/lib/toJSONSchema.d.mts +44 -0
- package/lib/toJSONSchema.d.ts +44 -0
- package/lib/toJSONSchema.js +12 -0
- package/lib/toJSONSchema.js.map +1 -0
- package/lib/toJSONSchema.mjs +12 -0
- package/lib/toJSONSchema.mjs.map +1 -0
- package/lib/translationMap.d.mts +7 -0
- package/lib/translationMap.d.ts +7 -0
- package/lib/translationMap.js +3 -3
- package/lib/translationMap.mjs +2 -2
- package/package.json +194 -46
- package/lib/chunk-23QTSXPQ.js.map +0 -1
- package/lib/chunk-24LO7MNY.js.map +0 -1
- package/lib/chunk-2ESDKTV4.js.map +0 -1
- package/lib/chunk-2HGS4STD.js +0 -48
- package/lib/chunk-2HGS4STD.js.map +0 -1
- package/lib/chunk-2IPGGARK.mjs.map +0 -1
- package/lib/chunk-4UPXP4I3.js.map +0 -1
- package/lib/chunk-5NYVRFG3.mjs +0 -48
- package/lib/chunk-5NYVRFG3.mjs.map +0 -1
- package/lib/chunk-62EKGBXF.js.map +0 -1
- package/lib/chunk-6JPYR2TS.js.map +0 -1
- package/lib/chunk-6LPQRAFN.js.map +0 -1
- package/lib/chunk-AJHBPMZT.mjs.map +0 -1
- package/lib/chunk-AXKX5BGH.js.map +0 -1
- package/lib/chunk-BRFUFNU4.js.map +0 -1
- package/lib/chunk-C2VSTWID.js.map +0 -1
- package/lib/chunk-D6G32F2K.js +0 -69
- package/lib/chunk-D6G32F2K.js.map +0 -1
- package/lib/chunk-DED5KDLM.js.map +0 -1
- package/lib/chunk-DFYP4GKE.js.map +0 -1
- package/lib/chunk-ENZ5WDUQ.js.map +0 -1
- package/lib/chunk-FI737YZJ.js.map +0 -1
- package/lib/chunk-FIDPCCCW.js.map +0 -1
- package/lib/chunk-GFWZQ4XW.mjs.map +0 -1
- package/lib/chunk-HPIF2CMT.js.map +0 -1
- package/lib/chunk-HUWO5UKU.js +0 -64
- package/lib/chunk-HUWO5UKU.js.map +0 -1
- package/lib/chunk-HWVM4SYU.mjs.map +0 -1
- package/lib/chunk-KRCOKWAB.mjs.map +0 -1
- package/lib/chunk-M2GOQ7TZ.mjs.map +0 -1
- package/lib/chunk-M3HYPZLE.mjs.map +0 -1
- package/lib/chunk-MCQHWS3E.mjs.map +0 -1
- package/lib/chunk-N3EHGKZV.mjs.map +0 -1
- package/lib/chunk-NBR3QGKW.js.map +0 -1
- package/lib/chunk-NFD7D5GZ.mjs.map +0 -1
- package/lib/chunk-NOJB5GBZ.mjs.map +0 -1
- package/lib/chunk-NY2TPU6O.mjs.map +0 -1
- package/lib/chunk-OE3L7EKN.mjs.map +0 -1
- package/lib/chunk-OFZMO7PB.mjs.map +0 -1
- package/lib/chunk-OHUOBIHX.mjs.map +0 -1
- package/lib/chunk-OZ3BTSSQ.mjs.map +0 -1
- package/lib/chunk-QIPGUTIG.mjs +0 -302
- package/lib/chunk-QIPGUTIG.mjs.map +0 -1
- package/lib/chunk-S5D5AFDF.js.map +0 -1
- package/lib/chunk-SBO6OQIX.mjs.map +0 -1
- package/lib/chunk-T2A3XXQZ.mjs.map +0 -1
- package/lib/chunk-TCDQA2NU.js +0 -31
- package/lib/chunk-TCDQA2NU.js.map +0 -1
- package/lib/chunk-TJQ5NVL4.js.map +0 -1
- package/lib/chunk-TLRVQWCI.mjs.map +0 -1
- package/lib/chunk-UYQFYQQG.mjs.map +0 -1
- package/lib/chunk-V7C77FML.mjs.map +0 -1
- package/lib/chunk-VN4GLOEN.js +0 -302
- package/lib/chunk-VN4GLOEN.js.map +0 -1
- package/lib/chunk-VVXKATDH.js.map +0 -1
- package/lib/chunk-WLPDAJB3.js.map +0 -1
- package/lib/chunk-XBE75VFX.js +0 -13
- package/lib/chunk-XBE75VFX.js.map +0 -1
- package/lib/chunk-XDVSL5B6.js +0 -14
- package/lib/chunk-XIOV4SHZ.mjs +0 -13
- package/lib/chunk-XIOV4SHZ.mjs.map +0 -1
- package/lib/chunk-Y5MNJGFX.js.map +0 -1
- package/lib/chunk-YDTQASAY.mjs.map +0 -1
- package/lib/chunk-YMPRYKNY.js.map +0 -1
- package/lib/chunk-Z4XOKGU3.js +0 -71
- package/lib/chunk-Z4XOKGU3.js.map +0 -1
- package/lib/chunk-ZDXO3TGZ.mjs.map +0 -1
- package/lib/chunk-ZEGRYDE5.mjs.map +0 -1
- package/lib/chunk-ZNQHNLKW.js.map +0 -1
- package/lib/chunk-ZTCXXAKD.mjs.map +0 -1
- /package/lib/{chunk-THU5VBSO.mjs.map → chunk-IIL6D2UL.mjs.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-ENZ5WDUQ.js","../src/asserts/number/maxExcluded.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACDA,IAAM,wBAAA,EAA0B,yDAAA;AAChC,IAAM,oBAAA,EAAsB,eAAA;AAerB,IAAM,YAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,SAAA,GAAY,QAAA,EAAU,GAAA,CAAI,QAAA,CAAS,QAAA,EAAU,QAAA,EAAU,mBAAmB,CAAA;AAChF,CAAA;AAEF,WAAA,CAAY,IAAA,EAAM,mBAAA;AAClB,WAAA,CAAY,QAAA,EAAU,uBAAA;AACtB,iDAAA,WAA8B,CAAA;ADd9B;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-ENZ5WDUQ.js","sourcesContent":[null,"import { setToDefaultLocale } from '../../translationMap';\nimport type { ExceptionContext, RequiredValidation } from '../../core';\n\nconst maxExcludedErrorMessage = 'The received value is greater than or equal to expected';\nconst maxExcludedErrorKey = 'n:maxExcluded';\n\n/**\n * @description - Asserts that a number value is strictly less than a specified maximum value (i.e., the maximum value is excluded).\n * @param {number} expected - The maximum allowable value, which is excluded.\n * @returns {RequiredValidation} - A validation function that takes a received number and an exception context.\n * @throws {ValidationError} if the received value is greater than or equal to the expected maximum value.\n * @example\n * const schema = number().custom(maxExcluded(100));\n * parseOrFail(schema, 99); // Valid\n * parseOrFail(schema, 100); // Throws an error: 'The received value is greater than or equal to expected'\n * parseOrFail(schema, 101); // Throws an error: 'The received value is greater than or equal to expected'\n *\n * @translation Error Translation Key = 'n:maxExcluded'\n */\nexport const maxExcluded =\n (expected: number): RequiredValidation =>\n (received: number, ctx: ExceptionContext) => {\n if (expected <= received) ctx.addIssue(expected, received, maxExcludedErrorKey);\n };\n\nmaxExcluded.key = maxExcludedErrorKey;\nmaxExcluded.message = maxExcludedErrorMessage;\nsetToDefaultLocale(maxExcluded);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-FI737YZJ.js","../src/asserts/string/email.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACDA,IAAM,YAAA,EAAc,sBAAA;AACpB,IAAM,kBAAA,EAAoB,8DAAA;AAC1B,IAAM,cAAA,EAAgB,SAAA;AAaf,IAAM,MAAA,EAAQ,CAAA,EAAA,GAA0B,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC1F,EAAA,GAAA,CAAI,CAAC,WAAA,CAAY,IAAA,CAAK,QAAQ,CAAA,EAAG,GAAA,CAAI,QAAA,CAAS,WAAA,EAAa,QAAA,EAAU,iBAAiB,CAAA;AACxF,CAAA;AAEA,KAAA,CAAM,IAAA,EAAM,aAAA;AACZ,KAAA,CAAM,QAAA,EAAU,iBAAA;AAChB,iDAAA,KAAwB,CAAA;ADVxB;AACA;AACE;AACF,sBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-FI737YZJ.js","sourcesContent":[null,"import type { ExceptionContext, RequiredValidation } from '../../core';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst emailRegExp = /^[^@]+@[^@]+\\.[^@]+$/;\nconst emailErrorMessage = 'The received value does not match the required email pattern';\nconst emailErrorKey = 's:email';\n\n/**\n * @description Asserts that a string value matches the email pattern. The pattern checks for a basic email format.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value does not match the email pattern.\n * @example\n * const schema = string().custom(email());\n * parseOrFail(schema, 'example@example.com'); // Valid\n * parseOrFail(schema, 'invalid-email'); // Throws an error: 'The received value does not match the required email pattern'\n *\n * @translation - Error Translation Key = 's:email'\n */\nexport const email = (): RequiredValidation => (received: string, ctx: ExceptionContext) => {\n if (!emailRegExp.test(received)) ctx.addIssue(emailRegExp, received, emailErrorMessage);\n};\n\nemail.key = emailErrorKey;\nemail.message = emailErrorMessage;\nsetToDefaultLocale(email);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-FIDPCCCW.js","../src/exceptions.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,gBAAA,EAAN,MAAA,QAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAA,CAAY,QAAA,EAAmB,QAAA,EAAmB,WAAA,EAAqB,OAAA,EAAiB,IAAA,EAAoB;AAC1G,IAAA,KAAA,CAAM,CAAA;AACN,IAAA,IAAA,CAAK,SAAA,EAAW,QAAA;AAChB,IAAA,IAAA,CAAK,SAAA,EAAW,QAAA;AAChB,IAAA,IAAA,CAAK,YAAA,EAAc,WAAA;AACnB,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA;AACf,IAAA,IAAA,CAAK,KAAA,EAAO,IAAA;AAAA,EACd;AACF,CAAA;AAEO,IAAM,iBAAA,EAAN,MAAA,QAA+B,MAAM;AAAC,CAAA;ADA7C;AACA;AACE;AACA;AACF,uFAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-FIDPCCCW.js","sourcesContent":[null,"import type { 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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/string/isValidDateTime.ts"],"sourcesContent":["import { setToDefaultLocale } from '../../translationMap';\nimport type { ExceptionContext, RequiredValidation } from '../../core';\n\n// Default error messages and keys\nconst dateTimeErrorMessage = 'The received value is not a valid ISO 8601 datetime string';\nconst dateTimeErrorKey = 's:isValidDateTime';\n\ntype DateTimeOptions = {\n offset?: boolean;\n precision?: number;\n};\n\nconst defaultOptions: DateTimeOptions = {\n offset: false,\n precision: undefined,\n};\n\n/**\n * @description Asserts that a string value is a valid ISO 8601 datetime string.\n * @param {DateTimeOptions} options Options to control the validation:\n * - `offset`: If `true`, allows timezone offsets in the datetime string.\n * - `precision`: Specify the exact number of fractional second digits allowed (e.g., 3 for milliseconds).\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value is not a valid datetime string according to the options.\n * @example\n * const schema = string().custom(isValidDateTime());\n * parseOrFail(schema, \"2024-01-01T00:00:00Z\"); // Valid\n * parseOrFail(schema, \"2024-01-01T00:00:00.123Z\"); // Valid\n * parseOrFail(schema, \"2024-01-01T00:00:00+03:00\"); // Invalid (no offsets allowed)\n *\n * const schemaWithOffset = string().custom(isValidDateTime({ offset: true }));\n * parseOrFail(schemaWithOffset, \"2024-01-01T00:00:00+04:00\"); // Valid\n *\n * const schemaWithPrecision = string().custom(isValidDateTime({ precision: 3 }));\n * parseOrFail(schemaWithPrecision, \"2024-01-01T00:00:00.123Z\"); // Valid\n * parseOrFail(schemaWithPrecision, \"2024-01-01T00:00:00.123456Z\"); // Invalid\n *\n * @translation Error Translation Key = 's:isValidDateTime'\n */\nexport const isValidDateTime = (options: DateTimeOptions = defaultOptions): RequiredValidation => {\n return (received: string, ctx: ExceptionContext) => {\n const { offset, precision } = options;\n\n const dateTimeRegex = new RegExp(\n `^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}` +\n (precision !== undefined ? `(\\\\.\\\\d{${precision}})` : `(\\\\.\\\\d+)?`) +\n `(${offset ? `([+-]\\\\d{2}:\\\\d{2}|[+-]\\\\d{2}\\\\d{2}|[+-]\\\\d{2}|Z)` : 'Z'})$`,\n );\n\n if (!dateTimeRegex.test(received)) {\n ctx.addIssue(received, dateTimeErrorMessage, dateTimeErrorKey);\n }\n };\n};\n\nisValidDateTime.key = dateTimeErrorKey;\nisValidDateTime.message = dateTimeErrorMessage;\nsetToDefaultLocale(isValidDateTime);\n"],"mappings":";;;;;AAIA,IAAM,uBAAuB;AAC7B,IAAM,mBAAmB;AAOzB,IAAM,iBAAkC;AAAA,EACtC,QAAQ;AAAA,EACR,WAAW;AACb;AAwBO,IAAM,kBAAkB,CAAC,UAA2B,mBAAuC;AAChG,SAAO,CAAC,UAAkB,QAA0B;AAClD,UAAM,EAAE,QAAQ,UAAU,IAAI;AAE9B,UAAM,gBAAgB,IAAI;AAAA,MACxB,gDACG,cAAc,SAAY,WAAW,SAAS,OAAO,gBACtD,IAAI,SAAS,sDAAsD,GAAG;AAAA,IAC1E;AAEA,QAAI,CAAC,cAAc,KAAK,QAAQ,GAAG;AACjC,UAAI,SAAS,UAAU,sBAAsB,gBAAgB;AAAA,IAC/D;AAAA,EACF;AACF;AAEA,gBAAgB,MAAM;AACtB,gBAAgB,UAAU;AAC1B,mBAAmB,eAAe;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-HPIF2CMT.js","../src/asserts/string/maxLength.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACDA,IAAM,sBAAA,EAAwB,oDAAA;AAC9B,IAAM,kBAAA,EAAoB,aAAA;AAcnB,IAAM,UAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,QAAA,CAAS,OAAA,EAAS,QAAA,EAAU,GAAA,CAAI,QAAA,CAAS,QAAA,EAAU,QAAA,EAAU,qBAAqB,CAAA;AACxF,CAAA;AAEF,SAAA,CAAU,IAAA,EAAM,iBAAA;AAChB,SAAA,CAAU,QAAA,EAAU,qBAAA;AACpB,iDAAA,SAA4B,CAAA;ADb5B;AACA;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-HPIF2CMT.js","sourcesContent":[null,"import type { ExceptionContext, RequiredValidation } from '../../core';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst maxLengthErrorMessage = 'The received value length is greater than expected';\nconst maxLengthErrorKey = 's:maxLength';\n\n/**\n * @description Asserts that the length of a string value is not greater than a specified maximum length.\n * @param {number} expected The maximum allowed length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the length of the received value is greater than the expected length.\n * @example\n * const schema = string().custom(maxLength(10));\n * parseOrFail(schema, 'short'); // Valid\n * parseOrFail(schema, 'this is a very long string'); // Throws an error: 'The received value length is greater than expected'\n *\n * @translation Error Translation Key = 's:maxLength'\n */\nexport const maxLength =\n (expected: number): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (received.length > expected) ctx.addIssue(expected, received, maxLengthErrorMessage);\n };\n\nmaxLength.key = maxLengthErrorKey;\nmaxLength.message = maxLengthErrorMessage;\nsetToDefaultLocale(maxLength);\n"]}
|
package/lib/chunk-HUWO5UKU.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
|
-
|
|
3
|
-
var _chunkPAV4SQQLjs = require('./chunk-PAV4SQQL.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkTLPVFRWRjs = require('./chunk-TLPVFRWR.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkXDVSL5B6js = require('./chunk-XDVSL5B6.js');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _chunkVN4GLOENjs = require('./chunk-VN4GLOEN.js');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _chunkFIDPCCCWjs = require('./chunk-FIDPCCCW.js');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _chunkAXKX5BGHjs = require('./chunk-AXKX5BGH.js');
|
|
19
|
-
|
|
20
|
-
// src/asserts/number/index.ts
|
|
21
|
-
function number() {
|
|
22
|
-
return new NumberSchema({ type: ["number"], requiredValidations: [] });
|
|
23
|
-
}
|
|
24
|
-
var NumberSchema = (_class = class extends _chunkVN4GLOENjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
25
|
-
__init() {this._number = 1}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @method equalTo
|
|
29
|
-
* @description Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
30
|
-
* @param expectedValue - The value that the schema must exactly match.
|
|
31
|
-
* @returns The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type
|
|
32
|
-
* @example
|
|
33
|
-
* number().equalTo(42); // Infers the type 42
|
|
34
|
-
*
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
37
|
-
equalTo(expectedValue) {
|
|
38
|
-
if (this.limit) throw new (0, _chunkFIDPCCCWjs.BuildSchemaError)(_chunkAXKX5BGHjs.ONLY_ONCE);
|
|
39
|
-
this.limit = true;
|
|
40
|
-
_chunkXDVSL5B6js._setStrictType.call(void 0, this, expectedValue);
|
|
41
|
-
return this.custom(_chunkTLPVFRWRjs.equalTo.call(void 0, expectedValue));
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* @method oneOfValues
|
|
45
|
-
* @description Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
|
|
46
|
-
* @param expectedValues - An array of values that the schema can match.
|
|
47
|
-
* @returns The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.
|
|
48
|
-
* @example
|
|
49
|
-
* number().oneOfValues([5, 7]); // Infers the type 5 | 7
|
|
50
|
-
*
|
|
51
|
-
* @public
|
|
52
|
-
*/
|
|
53
|
-
oneOfValues(expectedValue) {
|
|
54
|
-
if (this.limit) throw new (0, _chunkFIDPCCCWjs.BuildSchemaError)(_chunkAXKX5BGHjs.ONLY_ONCE);
|
|
55
|
-
this.limit = true;
|
|
56
|
-
_chunkXDVSL5B6js._setStrictType.call(void 0, this, expectedValue);
|
|
57
|
-
return this.custom(_chunkPAV4SQQLjs.oneOfValues.call(void 0, expectedValue));
|
|
58
|
-
}
|
|
59
|
-
}, _class);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
exports.number = number;
|
|
64
|
-
//# sourceMappingURL=chunk-HUWO5UKU.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-HUWO5UKU.js","../src/asserts/number/index.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;ACDO,SAAS,MAAA,CAAA,EAA+C;AAC7D,EAAA,OAAO,IAAI,YAAA,CAAa,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;AAEA,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC5B,QAAA,EAAU,EAAA;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYD,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;AAAA,EAYO,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;ADAA;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-HUWO5UKU.js","sourcesContent":[null,"import { WithBGuardType } from '../../commonTypes';\nimport { BuildSchemaError } from '../../exceptions';\nimport { ONLY_ONCE } from '../../helpers/constants';\nimport { CommonSchema } from '../../core';\nimport { _setStrictType } from '../../helpers/setStrictType';\nimport { equalTo } from '../mix/equalTo';\nimport { oneOfValues } from '../mix/oneOfValues';\n\n/**\n * @description Creates a new schema for validating number values.\n * @returns {NumberSchema} A new instance of `NumberSchema` for validating numbers.\n * @example\n * const schema = number();\n * parseOrFail(schema, 42); // Validates successfully\n * parseOrFail(schema, '42'); // Throws a validation error\n *\n * @instance Of NumberSchema\n */\nexport function number(): WithBGuardType<NumberSchema, number> {\n return new NumberSchema({ type: ['number'], requiredValidations: [] }) as WithBGuardType<NumberSchema, number>;\n}\n\nclass NumberSchema extends CommonSchema {\n protected _number = 1;\n private limit: boolean | undefined;\n\n /**\n * @method equalTo\n * @description Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\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 * @example\n * number().equalTo(42); // Infers the type 42\n *\n * @public\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 * @method oneOfValues\n * @description Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\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 * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n *\n * @public\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/number/maxExcluded.ts"],"sourcesContent":["import { setToDefaultLocale } from '../../translationMap';\nimport type { ExceptionContext, RequiredValidation } from '../../core';\n\nconst maxExcludedErrorMessage = 'The received value is greater than or equal to expected';\nconst maxExcludedErrorKey = 'n:maxExcluded';\n\n/**\n * @description - Asserts that a number value is strictly less than a specified maximum value (i.e., the maximum value is excluded).\n * @param {number} expected - The maximum allowable value, which is excluded.\n * @returns {RequiredValidation} - A validation function that takes a received number and an exception context.\n * @throws {ValidationError} if the received value is greater than or equal to the expected maximum value.\n * @example\n * const schema = number().custom(maxExcluded(100));\n * parseOrFail(schema, 99); // Valid\n * parseOrFail(schema, 100); // Throws an error: 'The received value is greater than or equal to expected'\n * parseOrFail(schema, 101); // Throws an error: 'The received value is greater than or equal to expected'\n *\n * @translation Error Translation Key = 'n:maxExcluded'\n */\nexport const maxExcluded =\n (expected: number): RequiredValidation =>\n (received: number, ctx: ExceptionContext) => {\n if (expected <= received) ctx.addIssue(expected, received, maxExcludedErrorKey);\n };\n\nmaxExcluded.key = maxExcludedErrorKey;\nmaxExcluded.message = maxExcludedErrorMessage;\nsetToDefaultLocale(maxExcluded);\n"],"mappings":";;;;;AAGA,IAAM,0BAA0B;AAChC,IAAM,sBAAsB;AAerB,IAAM,cACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,YAAY,SAAU,KAAI,SAAS,UAAU,UAAU,mBAAmB;AAChF;AAEF,YAAY,MAAM;AAClB,YAAY,UAAU;AACtB,mBAAmB,WAAW;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/string/maxLength.ts"],"sourcesContent":["import type { ExceptionContext, RequiredValidation } from '../../core';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst maxLengthErrorMessage = 'The received value length is greater than expected';\nconst maxLengthErrorKey = 's:maxLength';\n\n/**\n * @description Asserts that the length of a string value is not greater than a specified maximum length.\n * @param {number} expected The maximum allowed length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the length of the received value is greater than the expected length.\n * @example\n * const schema = string().custom(maxLength(10));\n * parseOrFail(schema, 'short'); // Valid\n * parseOrFail(schema, 'this is a very long string'); // Throws an error: 'The received value length is greater than expected'\n *\n * @translation Error Translation Key = 's:maxLength'\n */\nexport const maxLength =\n (expected: number): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (received.length > expected) ctx.addIssue(expected, received, maxLengthErrorMessage);\n };\n\nmaxLength.key = maxLengthErrorKey;\nmaxLength.message = maxLengthErrorMessage;\nsetToDefaultLocale(maxLength);\n"],"mappings":";;;;;AAGA,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB;AAcnB,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,SAAS,SAAS,SAAU,KAAI,SAAS,UAAU,UAAU,qBAAqB;AACxF;AAEF,UAAU,MAAM;AAChB,UAAU,UAAU;AACpB,mBAAmB,SAAS;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/object/maxKeys.ts"],"sourcesContent":["import type { ExceptionContext, RequiredValidation } from '../../core';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst maxKeysErrorMessage = 'The received number of keys is greater than expected';\nconst maxKeysErrorKey = 'o:maxKeys';\n\n/**\n * @description Ensures that the object has no more than the specified number of keys.\n * @param {number} expected - The maximum number of keys allowed in the object.\n * @returns {RequiredValidation} A validation function that takes a received object and an exception context.\n * @throws {ValidationError} if the number of the received keys is greater than the expected value.\n * @example\n * const schema = object({\n * name: string(),\n * email: string(),\n * })\n * .allowUnrecognized()\n * .custom(maxKeys(2));\n *\n * // This will pass\n * parseOrFail(schema, { name: 'John', email: 'john@example.com' });\n *\n * // This will throw an error because there are 3 keys\n * parseOrFail(schema, { name: 'John', email: 'john@example.com', address: '123 Main St' });\n *\n * @translation Error Translation Key = 'o:maxKeys'\n */\nexport const maxKeys =\n (expected: number): RequiredValidation =>\n (receivedObject: Record<string, unknown>, ctx: ExceptionContext) => {\n const keysCount = Object.keys(receivedObject).length;\n if (keysCount > expected) {\n ctx.addIssue(expected, keysCount, maxKeysErrorKey);\n }\n };\n\nmaxKeys.key = maxKeysErrorKey;\nmaxKeys.message = maxKeysErrorMessage;\nsetToDefaultLocale(maxKeys);\n"],"mappings":";;;;;AAGA,IAAM,sBAAsB;AAC5B,IAAM,kBAAkB;AAuBjB,IAAM,UACX,CAAC,aACD,CAAC,gBAAyC,QAA0B;AAClE,QAAM,YAAY,OAAO,KAAK,cAAc,EAAE;AAC9C,MAAI,YAAY,UAAU;AACxB,QAAI,SAAS,UAAU,WAAW,eAAe;AAAA,EACnD;AACF;AAEF,QAAQ,MAAM;AACd,QAAQ,UAAU;AAClB,mBAAmB,OAAO;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/object/index.ts"],"sourcesContent":["import { WithObject } from '../../commonTypes';\nimport { BuildSchemaError } from '../../exceptions';\nimport { ctxSymbol } from '../../helpers/constants';\nimport { CommonSchema, ValidatorContext, type ObjectShapeSchemaType } from '../../core';\n\nclass ObjectSchema extends CommonSchema {\n protected _object = 1;\n constructor(ctx: ValidatorContext, shapeSchema: ObjectShapeSchemaType) {\n super(ctx);\n this.validateObjectEntry(shapeSchema);\n this[ctxSymbol].object = shapeSchema;\n }\n\n private validateObjectEntry(shapeSchema: ObjectShapeSchemaType) {\n if (!shapeSchema) throw new BuildSchemaError('Missing schema in object method');\n if (shapeSchema instanceof CommonSchema) throw new BuildSchemaError('Invalid schema in object');\n for (const [key, value] of Object.entries(shapeSchema)) {\n if (!(value instanceof CommonSchema))\n throw new BuildSchemaError(`Invalid schema in object method for property '${key}'`);\n }\n }\n\n /**\n * @method allowUnrecognized\n * @description 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 * @returns {this} The current ObjectSchema instance.\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\n */\n public allowUnrecognized(): this {\n this[ctxSymbol].allowUnrecognizedObjectProps = true;\n return this;\n }\n}\n\n/**\n * @description Creates a new schema for validating objects where each property must match the specified schema.\n * @template T\n * @param {T} shapeSchema - The schema that each property of the object must match.\n * @returns {WithObject<ObjectSchema, T>} A new instance of `ObjectSchema` for validating objects with properties matching the specified schema.\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 *\n * @instance Of ObjectSchema\n */\nexport function object<T extends ObjectShapeSchemaType>(shapeSchema: T): WithObject<ObjectSchema, T> {\n return new ObjectSchema({ type: [], requiredValidations: [] }, shapeSchema) as WithObject<ObjectSchema, T>;\n}\n"],"mappings":";;;;;;;;;;;AAKA,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC5B,UAAU;AAAA,EACpB,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;AAAA,EAoBO,oBAA0B;AAC/B,SAAK,SAAS,EAAE,+BAA+B;AAC/C,WAAO;AAAA,EACT;AACF;AAiBO,SAAS,OAAwC,aAA6C;AACnG,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,EAAE,GAAG,WAAW;AAC5E;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/number/negative.ts"],"sourcesContent":["import { setToDefaultLocale } from '../../translationMap';\nimport type { ExceptionContext, RequiredValidation } from '../../core';\n\nconst negativeErrorMessage = 'The received value is not a negative number';\nconst negativeErrorKey = 'n:negative';\n\n/**\n * @description Asserts that a number value is negative (less than zero).\n * @returns {RequiredValidation} A validation function that takes a received number and an exception context.\n * @throws {ValidationError} if the received value is not negative.\n * @example\n * const schema = number().custom(negative());\n * parseOrFail(schema, -10); // Valid\n * parseOrFail(schema, 0); // Throws an error: 'The received value is not a negative number'\n * parseOrFail(schema, 5); // Throws an error: 'The received value is not a negative number'\n *\n * @translation - Error Translation Key = 'n:negative'\n */\nexport const negative = (): RequiredValidation => (received: number, ctx: ExceptionContext) => {\n if (received >= 0) ctx.addIssue('negative', received, negativeErrorKey);\n};\n\nnegative.key = negativeErrorKey;\nnegative.message = negativeErrorMessage;\nsetToDefaultLocale(negative);\n"],"mappings":";;;;;AAGA,IAAM,uBAAuB;AAC7B,IAAM,mBAAmB;AAclB,IAAM,WAAW,MAA0B,CAAC,UAAkB,QAA0B;AAC7F,MAAI,YAAY,EAAG,KAAI,SAAS,YAAY,UAAU,gBAAgB;AACxE;AAEA,SAAS,MAAM;AACf,SAAS,UAAU;AACnB,mBAAmB,QAAQ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/string/validUrl.ts"],"sourcesContent":["import type { ExceptionContext, RequiredValidation } from '../../core';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst validUrlErrorMessage = 'The received value is not a valid URL';\nconst validUrlErrorKey = 's:validUrl';\n\nconst urlRegex = /^(http:\\/\\/|https:\\/\\/)([a-zA-Z0-9\\-.]+)(:\\d+)?(\\/[^\\s]*)?$/;\n\n/**\n * @description Asserts that the string value is a valid URL with optional protocol validation.\n * @param {string} [protocol] The protocol that the URL must start with (e.g., 'http'). If not provided, any URL starting with 'http://' or 'https://' is considered valid.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value does not match the expected URL pattern.\n * @example\n * const schema = string().custom(validUrl()); // Validates any URL starting with 'http://' or 'https://'\n * parseOrFail(schema, 'http://example.com'); // Valid\n * parseOrFail(schema, 'https://example.com'); // Valid\n * parseOrFail(schema, 'ftp://example.com'); // Throws an error\n * parseOrFail(schema, 'http:example.com'); // Throws an error\n *\n * @translation Error Translation Key = 's:url'\n */\nexport const validUrl =\n (protocol?: string): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n let regex = urlRegex;\n if (protocol) {\n regex = new RegExp(`^${protocol}:\\\\/\\\\/([a-zA-Z0-9\\\\-\\\\.]+)(:[0-9]+)?(\\\\/[^\\\\s]*)?$`);\n }\n\n if (!regex.test(received)) {\n ctx.addIssue('Invalid URL', received, validUrlErrorKey);\n }\n };\n\nvalidUrl.key = validUrlErrorKey;\nvalidUrl.message = validUrlErrorMessage;\nsetToDefaultLocale(validUrl);\n"],"mappings":";;;;;AAGA,IAAM,uBAAuB;AAC7B,IAAM,mBAAmB;AAEzB,IAAM,WAAW;AAgBV,IAAM,WACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,QAAQ;AACZ,MAAI,UAAU;AACZ,YAAQ,IAAI,OAAO,IAAI,QAAQ,qDAAqD;AAAA,EACtF;AAEA,MAAI,CAAC,MAAM,KAAK,QAAQ,GAAG;AACzB,QAAI,SAAS,eAAe,UAAU,gBAAgB;AAAA,EACxD;AACF;AAEF,SAAS,MAAM;AACf,SAAS,UAAU;AACnB,mBAAmB,QAAQ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-NBR3QGKW.js","../src/asserts/date/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACOO,SAAS,IAAA,CAAA,EAAyC;AACvD,EAAA,OAAO,IAAI,UAAA,CAAW,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACrE;AAEA,IAAM,WAAA,YAAN,MAAA,QAAyB,8BAAa;AAAA,iBAC1B,MAAA,EAAQ,EAAA;AAAA,EAElB,WAAA,CAAY,GAAA,EAAuB;AACjC,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,KAAA,EAAO,IAAA;AAAA,EACzB;AACF,UAAA;ADPA;AACA;AACE;AACF,oBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-NBR3QGKW.js","sourcesContent":[null,"import { WithBGuardType } from '../../commonTypes';\nimport { ctxSymbol } from '../../helpers/constants';\nimport { CommonSchema, ValidatorContext } from '../../core';\n\n/**\n * @description Creates a new schema for validating date values.\n * @returns {WithBGuardType<DateSchema, Date>} A new instance of `DateSchema` for validating booleans.\n * @example\n * const schema = date();\n * parseOrFail(schema, true); // Validates successfully\n * parseOrFail(schema, 'true'); // Throws a validation error\n *\n * @instance Of DateSchema\n */\nexport function date(): WithBGuardType<DateSchema, Date> {\n return new DateSchema({ type: ['object'], requiredValidations: [] }) as WithBGuardType<DateSchema, Date>;\n}\n\nclass DateSchema extends CommonSchema {\n protected _date = 1;\n\n constructor(ctx: ValidatorContext) {\n super(ctx);\n this[ctxSymbol].date = true;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/bigint/index.ts"],"sourcesContent":["import { WithBGuardType } from '../../commonTypes';\nimport { BuildSchemaError } from '../../exceptions';\nimport { ONLY_ONCE } from '../../helpers/constants';\nimport { CommonSchema } from '../../core';\nimport { _setStrictType } from '../../helpers/setStrictType';\nimport { equalTo } from '../mix/equalTo';\nimport { oneOfValues } from '../mix/oneOfValues';\n\n/**\n * @description - Creates a new schema for validating bigint values.\n * @returns {WithBGuardType<BigIntSchema, bigint>} A new instance of `BigIntSchema` for validating bigints.\n * @example\n * const schema = bigint();\n * parseOrFail(schema, 42n); // Validates successfully\n * parseOrFail(schema, 42); // Throws a validation error\n * parseOrFail(schema, '42'); // Throws a validation error\n *\n * @instance Of BigIntSchema\n */\nexport function bigint(): WithBGuardType<BigIntSchema, bigint> {\n return new BigIntSchema({ type: ['bigint'], requiredValidations: [] }) as WithBGuardType<BigIntSchema, bigint>;\n}\n\nclass BigIntSchema extends CommonSchema {\n protected _bigint = 1;\n private limit: boolean | undefined;\n\n /**\n * @method equalTo\n * @description Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\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 * @example\n * bigint().equalTo(42n); // Infers the type 42n\n *\n * @public\n */\n public equalTo<Y extends bigint>(expectedValue: Y): WithBGuardType<this, Y> {\n this.defaultValueCheck();\n this.limitCheck();\n _setStrictType(this, `${expectedValue}n`);\n return this.custom(equalTo(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n /**\n * @method oneOfValues\n * @description Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\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 * @example\n * bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n\n *\n * @public\n */\n public oneOfValues<Y extends bigint>(expectedValue: Y[]): WithBGuardType<this, Y> {\n this.defaultValueCheck();\n this.limitCheck();\n _setStrictType(\n this,\n expectedValue.map((el) => `${el}n`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n private limitCheck() {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,SAA+C;AAC7D,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,QAAQ,GAAG,qBAAqB,CAAC,EAAE,CAAC;AACvE;AAEA,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC5B,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYD,QAA0B,eAA2C;AAC1E,SAAK,kBAAkB;AACvB,SAAK,WAAW;AAChB,mBAAe,MAAM,GAAG,aAAa,GAAG;AACxC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYO,YAA8B,eAA6C;AAChF,SAAK,kBAAkB;AACvB,SAAK,WAAW;AAChB;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG;AAAA,IACpC;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":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/string/minLength.ts"],"sourcesContent":["import type { ExceptionContext, RequiredValidation } from '../../core';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst minLengthErrorMessage = 'The received value length is less than expected';\nconst minLengthErrorKey = 's:minLength';\n\n/**\n * @description Asserts that the length of a string value is not less than a specified minimum length.\n * @param {number} expected The minimum required length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the length of the received value is less than the expected length.\n * @example\n * const schema = string().custom(minLength(5));\n * parseOrFail(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseOrFail(schema, 'adequate'); // Valid\n *\n * @translation Error Translation Key = 's:minLength'\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (received.length < expected) ctx.addIssue(expected, received, minLengthErrorMessage);\n };\n\nminLength.key = minLengthErrorKey;\nminLength.message = minLengthErrorMessage;\nsetToDefaultLocale(minLength);\n"],"mappings":";;;;;AAGA,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB;AAcnB,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,SAAS,SAAS,SAAU,KAAI,SAAS,UAAU,UAAU,qBAAqB;AACxF;AAEF,UAAU,MAAM;AAChB,UAAU,UAAU;AACpB,mBAAmB,SAAS;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/array/maxArrayLength.ts"],"sourcesContent":["import type { ExceptionContext, RequiredValidation } from '../../core';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst maxArrayLengthErrorMessage = 'The received value length is greater than expected';\nconst maxArrayLengthErrorKey = 'a:maxArrayLength';\n\n/**\n * @description Asserts that the length of an array is not greater than a specified maximum length.\n * @param {number} expected The maximum allowed length for the array.\n * @returns {RequiredValidation} A validation function that takes a received array and an exception context.\n * @throws {ValidationError} if the length of the received value is greater than the expected length.\n * @example\n * const schema = array(string()).custom(maxArrayLength(3));\n * parseOrFail(schema, ['adequate', 'array']); // Valid\n * parseOrFail(schema, ['adequate', 'array', 'length']); // Valid\n * parseOrFail(schema, ['adequate', 'array', 'length', 'test']); // Throws an error: 'The received value length is greater than expected'\n *\n * @translation Error Translation Key = 'a:maxArrayLength'\n */\nexport const maxArrayLength =\n (expected: number): RequiredValidation =>\n (received: unknown[], ctx: ExceptionContext) => {\n if (received.length > expected) ctx.addIssue(expected, received, maxArrayLengthErrorMessage);\n };\n\nmaxArrayLength.key = maxArrayLengthErrorKey;\nmaxArrayLength.message = maxArrayLengthErrorMessage;\nsetToDefaultLocale(maxArrayLength);\n"],"mappings":";;;;;AAGA,IAAM,6BAA6B;AACnC,IAAM,yBAAyB;AAexB,IAAM,iBACX,CAAC,aACD,CAAC,UAAqB,QAA0B;AAC9C,MAAI,SAAS,SAAS,SAAU,KAAI,SAAS,UAAU,UAAU,0BAA0B;AAC7F;AAEF,eAAe,MAAM;AACrB,eAAe,UAAU;AACzB,mBAAmB,cAAc;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/translationMap.ts"],"sourcesContent":["import { BuildSchemaError } from './exceptions';\nimport type { TranslationErrorMap } from './commonTypes';\nimport type { RequiredValidation } from './core';\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 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":";;;;;AAKA,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,OAAK,GAAG,MAAM,EAAE,GAAG,gBAAgB;AACnC,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/number/min.ts"],"sourcesContent":["import { setToDefaultLocale } from '../../translationMap';\nimport type { ExceptionContext, RequiredValidation } from '../../core';\n\nconst minErrorMessage = 'The received value is less than expected';\nconst minErrorKey = 'n:min';\n\n/**\n * @description Asserts that a number value is not less than a specified minimum value.\n * @param {number} expected The minimum allowable value.\n * @returns {RequiredValidation} A validation function that takes a received number and an exception context.\n * @throws {ValidationError} if the received value is less than the expected minimum value.\n * @example\n * const schema = number().custom(min(10));\n * parseOrFail(schema, 11); // Valid\n * parseOrFail(schema, 10); // Valid\n * parseOrFail(schema, 9); // Throws an error: 'The received value is less than expected'\n *\n * @translation Error Translation Key = 'n:min'\n */\nexport const min =\n (expected: number): RequiredValidation =>\n (received: number, ctx: ExceptionContext) => {\n if (expected > received) ctx.addIssue(expected, received, minErrorKey);\n };\n\nmin.key = minErrorKey;\nmin.message = minErrorMessage;\nsetToDefaultLocale(min);\n"],"mappings":";;;;;AAGA,IAAM,kBAAkB;AACxB,IAAM,cAAc;AAeb,IAAM,MACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,WAAW,SAAU,KAAI,SAAS,UAAU,UAAU,WAAW;AACvE;AAEF,IAAI,MAAM;AACV,IAAI,UAAU;AACd,mBAAmB,GAAG;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/codeGen.ts"],"sourcesContent":["import { ctxSymbol } from './helpers/constants';\nimport { type CommonSchema, type ValidatorContext } from './core';\n\nfunction generateBaseType(schemaData: ValidatorContext) {\n if (schemaData.date) return 'Date';\n\n if (schemaData.strictType) {\n if (Array.isArray(schemaData.strictTypeValue)) return schemaData.strictTypeValue.join(' | ');\n return schemaData.strictTypeValue;\n }\n if (!schemaData.type.length) return '';\n const joined = schemaData.type.join(' | ');\n return joined;\n}\n\nconst INDENT_DEFAULT = ` `;\n\nfunction innerGenerator(schema: CommonSchema, isProperty: boolean, indent = INDENT_DEFAULT): string {\n const schemaData = schema[ctxSymbol];\n let code = '';\n\n if (isProperty) {\n code = code + (schemaData.isOptional ? '?: ' : ': ');\n }\n\n if (schemaData.array) {\n const innerArrayCode = innerGenerator(schemaData.array, false, indent + INDENT_DEFAULT);\n code = code + (innerArrayCode.includes('|') ? `(${innerArrayCode})[]` : `${innerArrayCode}[]`);\n }\n\n if (schemaData.object) {\n code = code + '{\\n';\n for (const [keyOfSchema, valueOfSchema] of Object.entries(schemaData.object)) {\n code = code + indent + keyOfSchema + innerGenerator(valueOfSchema, true, indent + INDENT_DEFAULT) + ';\\n';\n }\n code = code + indent.slice(0, -INDENT_DEFAULT.length) + '}';\n }\n\n code = code + generateBaseType(schemaData);\n code = code + (schemaData.isNullable ? ' | null' : '');\n code = code + (schemaData.isOptional ? ' | undefined' : '');\n\n return code;\n}\n\nexport function codeGen(schema: CommonSchema): string {\n const result = innerGenerator(schema, false) + ';';\n return result;\n}\n\nexport function codeGenWithName(typeName: string, schema: CommonSchema): string {\n const result = 'type ' + typeName + ' = ' + codeGen(schema) + '\\n';\n return result;\n}\n"],"mappings":";;;;;AAGA,SAAS,iBAAiB,YAA8B;AACtD,MAAI,WAAW,KAAM,QAAO;AAE5B,MAAI,WAAW,YAAY;AACzB,QAAI,MAAM,QAAQ,WAAW,eAAe,EAAG,QAAO,WAAW,gBAAgB,KAAK,KAAK;AAC3F,WAAO,WAAW;AAAA,EACpB;AACA,MAAI,CAAC,WAAW,KAAK,OAAQ,QAAO;AACpC,QAAM,SAAS,WAAW,KAAK,KAAK,KAAK;AACzC,SAAO;AACT;AAEA,IAAM,iBAAiB;AAEvB,SAAS,eAAe,QAAsB,YAAqB,SAAS,gBAAwB;AAClG,QAAM,aAAa,OAAO,SAAS;AACnC,MAAI,OAAO;AAEX,MAAI,YAAY;AACd,WAAO,QAAQ,WAAW,aAAa,QAAQ;AAAA,EACjD;AAEA,MAAI,WAAW,OAAO;AACpB,UAAM,iBAAiB,eAAe,WAAW,OAAO,OAAO,SAAS,cAAc;AACtF,WAAO,QAAQ,eAAe,SAAS,GAAG,IAAI,IAAI,cAAc,QAAQ,GAAG,cAAc;AAAA,EAC3F;AAEA,MAAI,WAAW,QAAQ;AACrB,WAAO,OAAO;AACd,eAAW,CAAC,aAAa,aAAa,KAAK,OAAO,QAAQ,WAAW,MAAM,GAAG;AAC5E,aAAO,OAAO,SAAS,cAAc,eAAe,eAAe,MAAM,SAAS,cAAc,IAAI;AAAA,IACtG;AACA,WAAO,OAAO,OAAO,MAAM,GAAG,CAAC,eAAe,MAAM,IAAI;AAAA,EAC1D;AAEA,SAAO,OAAO,iBAAiB,UAAU;AACzC,SAAO,QAAQ,WAAW,aAAa,YAAY;AACnD,SAAO,QAAQ,WAAW,aAAa,iBAAiB;AAExD,SAAO;AACT;AAEO,SAAS,QAAQ,QAA8B;AACpD,QAAM,SAAS,eAAe,QAAQ,KAAK,IAAI;AAC/C,SAAO;AACT;AAEO,SAAS,gBAAgB,UAAkB,QAA8B;AAC9E,QAAM,SAAS,UAAU,WAAW,QAAQ,QAAQ,MAAM,IAAI;AAC9D,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/number/index.ts"],"sourcesContent":["import { WithBGuardType } from '../../commonTypes';\nimport { BuildSchemaError } from '../../exceptions';\nimport { ONLY_ONCE } from '../../helpers/constants';\nimport { CommonSchema } from '../../core';\nimport { _setStrictType } from '../../helpers/setStrictType';\nimport { equalTo } from '../mix/equalTo';\nimport { oneOfValues } from '../mix/oneOfValues';\n\n/**\n * @description Creates a new schema for validating number values.\n * @returns {NumberSchema} A new instance of `NumberSchema` for validating numbers.\n * @example\n * const schema = number();\n * parseOrFail(schema, 42); // Validates successfully\n * parseOrFail(schema, '42'); // Throws a validation error\n *\n * @instance Of NumberSchema\n */\nexport function number(): WithBGuardType<NumberSchema, number> {\n return new NumberSchema({ type: ['number'], requiredValidations: [] }) as WithBGuardType<NumberSchema, number>;\n}\n\nclass NumberSchema extends CommonSchema {\n protected _number = 1;\n private limit: boolean | undefined;\n\n /**\n * @method equalTo\n * @description Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\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 * @example\n * number().equalTo(42); // Infers the type 42\n *\n * @public\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 * @method oneOfValues\n * @description Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\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 * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n *\n * @public\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":";;;;;;;;;;;;;;;;;;;;AAkBO,SAAS,SAA+C;AAC7D,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,QAAQ,GAAG,qBAAqB,CAAC,EAAE,CAAC;AACvE;AAEA,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC5B,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYD,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;AAAA,EAYO,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-QIPGUTIG.mjs
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isValidDateInner
|
|
3
|
-
} from "./chunk-YBVMP4EI.mjs";
|
|
4
|
-
import {
|
|
5
|
-
getTranslationByLocale
|
|
6
|
-
} from "./chunk-OE3L7EKN.mjs";
|
|
7
|
-
import {
|
|
8
|
-
BuildSchemaError,
|
|
9
|
-
ValidationError
|
|
10
|
-
} from "./chunk-ZTCXXAKD.mjs";
|
|
11
|
-
import {
|
|
12
|
-
ctxSymbol
|
|
13
|
-
} from "./chunk-2ANPCB4O.mjs";
|
|
14
|
-
|
|
15
|
-
// src/core.ts
|
|
16
|
-
var replacePlaceholdersRegex = /{{(.*?)}}/g;
|
|
17
|
-
function replacePlaceholders(template, replacements) {
|
|
18
|
-
return template.replace(replacePlaceholdersRegex, (_, key) => {
|
|
19
|
-
return key in replacements ? `${replacements[key]}` : `{{${key}}}`;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
var ExceptionContext = class _ExceptionContext {
|
|
23
|
-
constructor(initialReceived, t, pathToError, errors, meta) {
|
|
24
|
-
this.initialReceived = initialReceived;
|
|
25
|
-
this.t = t;
|
|
26
|
-
this.pathToError = pathToError;
|
|
27
|
-
this.errors = errors;
|
|
28
|
-
this.meta = meta;
|
|
29
|
-
}
|
|
30
|
-
createChild(childPathToError, childMeta) {
|
|
31
|
-
return new _ExceptionContext(this.initialReceived, this.t, childPathToError, this.errors, childMeta);
|
|
32
|
-
}
|
|
33
|
-
ref(path) {
|
|
34
|
-
let ref = this.initialReceived;
|
|
35
|
-
const parsedRefPath = path.split(".");
|
|
36
|
-
parsedRefPath.forEach((el) => {
|
|
37
|
-
ref = ref[el];
|
|
38
|
-
});
|
|
39
|
-
return ref;
|
|
40
|
-
}
|
|
41
|
-
addIssue(expected, received, messageKey) {
|
|
42
|
-
const rawMessage = this.t[messageKey] ?? messageKey;
|
|
43
|
-
const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: this.pathToError });
|
|
44
|
-
if (this.errors) {
|
|
45
|
-
this.errors.push({
|
|
46
|
-
expected,
|
|
47
|
-
received,
|
|
48
|
-
pathToError: this.pathToError,
|
|
49
|
-
message
|
|
50
|
-
});
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
throw new ValidationError(expected, received, this.pathToError, message, this.meta);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
function innerCheck(schema, receivedValue, exCtx) {
|
|
57
|
-
const commonTmap = exCtx.t;
|
|
58
|
-
const schemaData = schema[ctxSymbol];
|
|
59
|
-
schemaData.transformListBefore?.forEach((transformCallback) => {
|
|
60
|
-
receivedValue = transformCallback(receivedValue);
|
|
61
|
-
});
|
|
62
|
-
if (receivedValue === void 0) {
|
|
63
|
-
if (schemaData.defaultValue !== void 0) return schemaData.defaultValue;
|
|
64
|
-
if (!schemaData.isOptional) exCtx.addIssue("Required", receivedValue, commonTmap["c:optional"]);
|
|
65
|
-
return receivedValue;
|
|
66
|
-
}
|
|
67
|
-
if (receivedValue === null) {
|
|
68
|
-
if (!schemaData.isNullable) exCtx.addIssue("Not null", receivedValue, commonTmap["c:nullable"]);
|
|
69
|
-
return receivedValue;
|
|
70
|
-
}
|
|
71
|
-
if (schemaData.date) {
|
|
72
|
-
if (!isValidDateInner(receivedValue)) exCtx.addIssue("Date", receivedValue, commonTmap["c:date"]);
|
|
73
|
-
}
|
|
74
|
-
const typeOfVal = typeof receivedValue;
|
|
75
|
-
if (schemaData.type.length) {
|
|
76
|
-
if (!schemaData.type.includes(typeOfVal)) exCtx.addIssue(schemaData.type, typeOfVal, commonTmap["c:invalidType"]);
|
|
77
|
-
}
|
|
78
|
-
if (schemaData.array) {
|
|
79
|
-
if (!Array.isArray(receivedValue)) return exCtx.addIssue("Array", receivedValue, commonTmap["c:array"]);
|
|
80
|
-
schemaData.requiredValidations.forEach((requiredValidation) => {
|
|
81
|
-
requiredValidation(receivedValue, exCtx);
|
|
82
|
-
});
|
|
83
|
-
const schema2 = schemaData.array;
|
|
84
|
-
const pathToError = exCtx.pathToError;
|
|
85
|
-
const parsedReceivedValue = [];
|
|
86
|
-
receivedValue.forEach((elem, i) => {
|
|
87
|
-
const parsedElement = innerCheck(schema2, elem, exCtx.createChild(`${pathToError}[${i}]`, schemaData.meta));
|
|
88
|
-
parsedReceivedValue.push(parsedElement);
|
|
89
|
-
});
|
|
90
|
-
return parsedReceivedValue;
|
|
91
|
-
}
|
|
92
|
-
if (schemaData.object) {
|
|
93
|
-
if (typeOfVal !== "object") exCtx.addIssue("Object", receivedValue, commonTmap["c:objectType"]);
|
|
94
|
-
if (Array.isArray(receivedValue)) exCtx.addIssue("Object", receivedValue, commonTmap["c:objectTypeAsArray"]);
|
|
95
|
-
schemaData.requiredValidations.forEach((requiredValidation) => {
|
|
96
|
-
requiredValidation(receivedValue, exCtx);
|
|
97
|
-
});
|
|
98
|
-
const shapeSchema = schemaData.object;
|
|
99
|
-
const parsedReceivedValue = {};
|
|
100
|
-
if (!schemaData.allowUnrecognizedObjectProps) {
|
|
101
|
-
for (const keyPerReceivedValue of Object.keys(receivedValue)) {
|
|
102
|
-
if (shapeSchema[keyPerReceivedValue] === void 0)
|
|
103
|
-
exCtx.addIssue("Unrecognized property", keyPerReceivedValue, commonTmap["c:unrecognizedProperty"]);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
const pathToError = exCtx.pathToError;
|
|
107
|
-
for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {
|
|
108
|
-
const receivedObjectValuePropery = receivedValue[keyOfSchema];
|
|
109
|
-
if (receivedObjectValuePropery === void 0) {
|
|
110
|
-
if (!valueOfSchema[ctxSymbol].isOptional)
|
|
111
|
-
exCtx.addIssue("Required", receivedObjectValuePropery, commonTmap["c:requiredProperty"]);
|
|
112
|
-
}
|
|
113
|
-
const parsedReceivedObjectValuePropery = innerCheck(
|
|
114
|
-
valueOfSchema,
|
|
115
|
-
receivedObjectValuePropery,
|
|
116
|
-
exCtx.createChild(`${pathToError}.${keyOfSchema}`, schemaData.meta)
|
|
117
|
-
);
|
|
118
|
-
parsedReceivedValue[keyOfSchema] = parsedReceivedObjectValuePropery;
|
|
119
|
-
}
|
|
120
|
-
return parsedReceivedValue;
|
|
121
|
-
}
|
|
122
|
-
schemaData.requiredValidations.forEach((requiredValidation) => {
|
|
123
|
-
requiredValidation(receivedValue, exCtx);
|
|
124
|
-
});
|
|
125
|
-
return receivedValue;
|
|
126
|
-
}
|
|
127
|
-
var CommonSchema = class {
|
|
128
|
-
[ctxSymbol];
|
|
129
|
-
constructor(ctx) {
|
|
130
|
-
this[ctxSymbol] = ctx;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* @param validators - One or more custom validation functions.
|
|
134
|
-
* @returns {this} The schema instance with the added custom validation.
|
|
135
|
-
*/
|
|
136
|
-
custom(...validators) {
|
|
137
|
-
this.defaultValueCheck();
|
|
138
|
-
this[ctxSymbol].requiredValidations.push(...validators);
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Marks the schema as nullable, allowing the value to be `null`.
|
|
143
|
-
*
|
|
144
|
-
* @returns {WithNull<this>} The schema instance marked as nullable.
|
|
145
|
-
*/
|
|
146
|
-
nullable() {
|
|
147
|
-
this.defaultValueCheck();
|
|
148
|
-
this[ctxSymbol].isNullable = true;
|
|
149
|
-
return this;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Marks the schema as optional, allowing the value to be `undefined`.
|
|
153
|
-
*
|
|
154
|
-
* @returns {WithUndefined<this>} The schema instance marked as optional.
|
|
155
|
-
*/
|
|
156
|
-
optional() {
|
|
157
|
-
this.defaultValueCheck();
|
|
158
|
-
this[ctxSymbol].isOptional = true;
|
|
159
|
-
return this;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Marks the schema as optional, allowing the value to be `undefined`.
|
|
163
|
-
*
|
|
164
|
-
* @returns {this} The schema instance. This method should be used as a last one because it does the check of previous methods and
|
|
165
|
-
*/
|
|
166
|
-
default(defaultValue) {
|
|
167
|
-
const ctx = this[ctxSymbol];
|
|
168
|
-
if (ctx.isOptional) {
|
|
169
|
-
throw new BuildSchemaError(`Cannot call method 'default' after method 'optional'`);
|
|
170
|
-
}
|
|
171
|
-
try {
|
|
172
|
-
parseOrFail(this, defaultValue);
|
|
173
|
-
} catch (e) {
|
|
174
|
-
throw new BuildSchemaError(e.message);
|
|
175
|
-
}
|
|
176
|
-
this[ctxSymbol].defaultValue = defaultValue;
|
|
177
|
-
return this;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Applies a transformation to the input value before any validation occurs.
|
|
181
|
-
* The transformation should return a value of the same type as the inferred type of the schema,
|
|
182
|
-
* ensuring that the overall type is not altered.
|
|
183
|
-
*
|
|
184
|
-
* @template In - The type of the input value before transformation (defaults to `unknown`).
|
|
185
|
-
* @param {TransformCallback<In, InferType<this>>} cb - The callback function that performs the transformation.
|
|
186
|
-
* @returns {this} The updated schema with the applied transformation.
|
|
187
|
-
*
|
|
188
|
-
* @example
|
|
189
|
-
* const schema = string()
|
|
190
|
-
* .nullable()
|
|
191
|
-
* .transformBeforeValidation((val) => val + '') // Ensure the value is a string
|
|
192
|
-
* .transformBeforeValidation((val: string) => (val === '' ? null : val)); // Convert empty strings to null
|
|
193
|
-
*
|
|
194
|
-
* // Parse 'test' will pass as 'test' is a valid string longer than 3 characters.
|
|
195
|
-
* parseOrFail(schema, 'test');
|
|
196
|
-
*
|
|
197
|
-
* // Parsing '' will be transformed to null and will pass due to .nullable().
|
|
198
|
-
* parseOrFail(schema, '');
|
|
199
|
-
*/
|
|
200
|
-
transformBeforeValidation(cb) {
|
|
201
|
-
const ctx = this[ctxSymbol];
|
|
202
|
-
if (ctx.transformListBefore) {
|
|
203
|
-
ctx.transformListBefore.push(cb);
|
|
204
|
-
} else {
|
|
205
|
-
ctx.transformListBefore = [cb];
|
|
206
|
-
}
|
|
207
|
-
return this;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Assigns a unique identifier to the schema.
|
|
211
|
-
* This ID can be used to track or map validation errors back to specific fields
|
|
212
|
-
* in a form or other structures.
|
|
213
|
-
*
|
|
214
|
-
* @param {string} value - The unique identifier for the schema.
|
|
215
|
-
* @returns {this} The updated schema with the assigned ID.
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* const schema = string().id('username');
|
|
219
|
-
*/
|
|
220
|
-
id(value) {
|
|
221
|
-
return this.meta("id", value);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Provides a description for the schema, offering additional context or information.
|
|
225
|
-
* The description can be used when displaying validation errors or for documentation purposes.
|
|
226
|
-
*
|
|
227
|
-
* @param {string} value - The description for the schema.
|
|
228
|
-
* @returns {this} The updated schema with the added description.
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* const schema = string().description('The username of the account holder.');
|
|
232
|
-
*/
|
|
233
|
-
description(value) {
|
|
234
|
-
return this.meta("description", value);
|
|
235
|
-
}
|
|
236
|
-
meta(key, value) {
|
|
237
|
-
const ctx = this[ctxSymbol];
|
|
238
|
-
ctx.meta = { ...ctx.meta, [key]: value };
|
|
239
|
-
return this;
|
|
240
|
-
}
|
|
241
|
-
defaultValueCheck() {
|
|
242
|
-
if (this[ctxSymbol].defaultValue !== void 0) {
|
|
243
|
-
throw new BuildSchemaError("Default value must be the last method called in schema");
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
function parseOrFail(schema, receivedValue, options) {
|
|
248
|
-
try {
|
|
249
|
-
const ctx = new ExceptionContext(
|
|
250
|
-
receivedValue,
|
|
251
|
-
getTranslationByLocale(options?.lng),
|
|
252
|
-
"",
|
|
253
|
-
void 0,
|
|
254
|
-
schema[ctxSymbol].meta
|
|
255
|
-
);
|
|
256
|
-
return innerCheck(schema, receivedValue, ctx);
|
|
257
|
-
} catch (e) {
|
|
258
|
-
if (e instanceof ValidationError) throw e;
|
|
259
|
-
throw new Error("Something unexpected happened");
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
function parse(schema, receivedValue, options) {
|
|
263
|
-
try {
|
|
264
|
-
const ctx = new ExceptionContext(
|
|
265
|
-
receivedValue,
|
|
266
|
-
getTranslationByLocale(options?.lng),
|
|
267
|
-
"",
|
|
268
|
-
options?.getAllErrors ? [] : void 0,
|
|
269
|
-
schema[ctxSymbol].meta
|
|
270
|
-
);
|
|
271
|
-
const parsedValue = innerCheck(schema, receivedValue, ctx);
|
|
272
|
-
if (ctx.errors?.length) {
|
|
273
|
-
return [ctx.errors, void 0];
|
|
274
|
-
}
|
|
275
|
-
return [void 0, parsedValue];
|
|
276
|
-
} catch (e) {
|
|
277
|
-
if (e instanceof ValidationError) {
|
|
278
|
-
delete e.stack;
|
|
279
|
-
return [[e], void 0];
|
|
280
|
-
}
|
|
281
|
-
return [
|
|
282
|
-
[
|
|
283
|
-
{
|
|
284
|
-
message: "Something unexpected happened",
|
|
285
|
-
expected: "",
|
|
286
|
-
received: "",
|
|
287
|
-
pathToError: "",
|
|
288
|
-
meta: void 0
|
|
289
|
-
}
|
|
290
|
-
],
|
|
291
|
-
void 0
|
|
292
|
-
];
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export {
|
|
297
|
-
ExceptionContext,
|
|
298
|
-
CommonSchema,
|
|
299
|
-
parseOrFail,
|
|
300
|
-
parse
|
|
301
|
-
};
|
|
302
|
-
//# sourceMappingURL=chunk-QIPGUTIG.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core.ts"],"sourcesContent":["import { isValidDateInner } from './helpers/isValidDateInner';\nimport {\n BaseType,\n MetaContext,\n TransformCallback,\n TranslationErrorMap,\n ValidationErrorData,\n WithNull,\n WithUndefined,\n} from './commonTypes';\nimport { type InferType } from './InferType';\nimport { BuildSchemaError, ValidationError } from './exceptions';\nimport { getTranslationByLocale } from './translationMap';\nimport { ctxSymbol } from './helpers/constants';\n\nconst replacePlaceholdersRegex = /{{(.*?)}}/g;\n\nfunction replacePlaceholders(template: string, replacements: Record<string, unknown>): string {\n return template.replace(replacePlaceholdersRegex, (_, key) => {\n return key in replacements ? `${replacements[key] as string}` : `{{${key}}}`;\n });\n}\n\nexport class ExceptionContext {\n constructor(\n public readonly initialReceived: unknown,\n public readonly t: TranslationErrorMap,\n public readonly pathToError: string,\n public readonly errors?: ValidationErrorData[],\n public readonly meta?: MetaContext,\n ) {}\n\n createChild(childPathToError: string, childMeta?: MetaContext) {\n return new ExceptionContext(this.initialReceived, this.t, childPathToError, this.errors, childMeta);\n }\n\n public ref(path: string): unknown {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let ref: any = this.initialReceived;\n const parsedRefPath = path.split('.');\n parsedRefPath.forEach((el) => {\n ref = ref[el];\n });\n\n return ref;\n }\n\n public addIssue(expected: unknown, received: unknown, messageKey: string): never | void {\n const rawMessage = this.t[messageKey] ?? messageKey;\n const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: this.pathToError });\n\n if (this.errors) {\n this.errors.push({\n expected,\n received,\n pathToError: this.pathToError,\n message,\n });\n\n return;\n }\n\n throw new ValidationError(expected, received, this.pathToError, message, this.meta);\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RequiredValidation = (received: any, ctx: ExceptionContext) => void;\n\nfunction 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) exCtx.addIssue('Required', receivedValue, commonTmap['c:optional']);\n return receivedValue;\n }\n\n if (receivedValue === null) {\n if (!schemaData.isNullable) exCtx.addIssue('Not null', receivedValue, commonTmap['c:nullable']);\n return receivedValue;\n }\n\n if (schemaData.date) {\n if (!isValidDateInner(receivedValue)) exCtx.addIssue('Date', receivedValue, commonTmap['c:date']);\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (schemaData.type.length) {\n if (!schemaData.type.includes(typeOfVal)) exCtx.addIssue(schemaData.type, typeOfVal, commonTmap['c:invalidType']);\n }\n\n if (schemaData.array) {\n if (!Array.isArray(receivedValue)) return exCtx.addIssue('Array', receivedValue, 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, exCtx.createChild(`${pathToError}[${i}]`, schemaData.meta));\n parsedReceivedValue.push(parsedElement);\n });\n\n return parsedReceivedValue;\n }\n\n if (schemaData.object) {\n if (typeOfVal !== 'object') exCtx.addIssue('Object', receivedValue, commonTmap['c:objectType']);\n if (Array.isArray(receivedValue)) exCtx.addIssue('Object', receivedValue, 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 exCtx.addIssue('Unrecognized property', keyPerReceivedValue, 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 exCtx.addIssue('Required', receivedObjectValuePropery, commonTmap['c:requiredProperty']);\n }\n\n const parsedReceivedObjectValuePropery = innerCheck(\n valueOfSchema,\n receivedObjectValuePropery,\n exCtx.createChild(`${pathToError}.${keyOfSchema}`, 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\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport interface ValidatorContext {\n type: BaseType[];\n isNullable?: boolean;\n isOptional?: boolean;\n requiredValidations: RequiredValidation[];\n array?: CommonSchema;\n object?: ObjectShapeSchemaType;\n allowUnrecognizedObjectProps?: boolean;\n strictType?: boolean;\n strictTypeValue?: unknown;\n date?: boolean;\n defaultValue?: unknown;\n meta?: MetaContext;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformListBefore?: TransformCallback<any, any>[];\n}\n\nexport class CommonSchema {\n [ctxSymbol]: ValidatorContext;\n constructor(ctx: ValidatorContext) {\n this[ctxSymbol] = ctx;\n }\n\n /**\n * @param validators - One or more custom validation functions.\n * @returns {this} The schema instance with the added custom validation.\n */\n public custom(...validators: RequiredValidation[]): this {\n this.defaultValueCheck();\n this[ctxSymbol].requiredValidations.push(...validators);\n return this;\n }\n\n /**\n * Marks the schema as nullable, allowing the value to be `null`.\n *\n * @returns {WithNull<this>} The schema instance marked as nullable.\n */\n public nullable(): WithNull<this> {\n this.defaultValueCheck();\n this[ctxSymbol].isNullable = true;\n return this as WithNull<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {WithUndefined<this>} The schema instance marked as optional.\n */\n public optional(): WithUndefined<this> {\n this.defaultValueCheck();\n this[ctxSymbol].isOptional = true;\n return this as WithUndefined<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {this} The schema instance. This method should be used as a last one because it does the check of previous methods and\n */\n public default(defaultValue: InferType<this>): this {\n const ctx = this[ctxSymbol];\n if (ctx.isOptional) {\n throw new BuildSchemaError(`Cannot call method 'default' after method 'optional'`);\n }\n\n try {\n parseOrFail(this, defaultValue);\n } catch (e) {\n throw new BuildSchemaError((e as Error).message);\n }\n\n this[ctxSymbol].defaultValue = defaultValue;\n return this;\n }\n\n /**\n * Applies a transformation to the input value before any validation occurs.\n * The transformation should return a value of the same type as the inferred type of the schema,\n * ensuring that the overall type is not altered.\n *\n * @template In - The type of the input value before transformation (defaults to `unknown`).\n * @param {TransformCallback<In, InferType<this>>} cb - The callback function that performs the transformation.\n * @returns {this} The updated schema with the applied transformation.\n *\n * @example\n * const schema = string()\n * .nullable()\n * .transformBeforeValidation((val) => val + '') // Ensure the value is a string\n * .transformBeforeValidation((val: string) => (val === '' ? null : val)); // Convert empty strings to null\n *\n * // Parse 'test' will pass as 'test' is a valid string longer than 3 characters.\n * parseOrFail(schema, 'test');\n *\n * // Parsing '' will be transformed to null and will pass due to .nullable().\n * parseOrFail(schema, '');\n */\n public transformBeforeValidation<In>(cb: TransformCallback<In, InferType<this>>): this {\n const ctx = this[ctxSymbol];\n if (ctx.transformListBefore) {\n ctx.transformListBefore.push(cb);\n } else {\n ctx.transformListBefore = [cb];\n }\n\n return this;\n }\n\n /**\n * Assigns a unique identifier to the schema.\n * This ID can be used to track or map validation errors back to specific fields\n * in a form or other structures.\n *\n * @param {string} value - The unique identifier for the schema.\n * @returns {this} The updated schema with the assigned ID.\n *\n * @example\n * const schema = string().id('username');\n */\n public id(value: string): this {\n return this.meta('id', value);\n }\n\n /**\n * Provides a description for the schema, offering additional context or information.\n * The description can be used when displaying validation errors or for documentation purposes.\n *\n * @param {string} value - The description for the schema.\n * @returns {this} The updated schema with the added description.\n *\n * @example\n * const schema = string().description('The username of the account holder.');\n */\n public description(value: string): this {\n return this.meta('description', value);\n }\n\n private meta(key: string, value: string): this {\n const ctx = this[ctxSymbol];\n ctx.meta = { ...ctx.meta, [key]: value };\n return this;\n }\n\n protected defaultValueCheck() {\n if (this[ctxSymbol].defaultValue !== undefined) {\n throw new BuildSchemaError('Default value must be the last method called in schema');\n }\n }\n}\n\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 const ctx = new ExceptionContext(\n receivedValue,\n getTranslationByLocale(options?.lng),\n '',\n undefined,\n schema[ctxSymbol].meta,\n );\n return innerCheck(schema, receivedValue, ctx) as InferType<T>;\n } catch (e) {\n /* istanbul ignore next */\n if (e instanceof ValidationError) throw e;\n /* istanbul ignore next */\n throw new Error('Something unexpected happened');\n }\n}\n\ninterface ParseOptions {\n /**\n * Set language keyword to map error messages.\n * @default 'default'\n * @example 'sr' or 'Serbia' or any string to identify language\n */\n lng?: string;\n\n /**\n * If true, collects all validation errors and returns them.\n * If false or undefined, returns the first validation error it can find and stops looking,\n * which provides a small runtime optimization.\n * @default undefined\n */\n getAllErrors?: boolean;\n}\n\n/**\n * Parses and validates a value against the provided schema, returning a type-safe parsedValue.\n *\n * This function will throw a `ValidationError` if the value does not conform to the schema.\n * The inferred TypeScript type of the returned value will match the structure defined by the schema.\n *\n * @template T\n * @param {T} schema - The schema to validate the received value against. This schema dictates the expected structure and type of the value.\n * @param {unknown} receivedValue - The value to be validated and parsed according to the schema.\n * @param {ParseOptions} options - Options\n * @param {ParseOptions.lng} options.lng - Set language keyword to map Error messages\n * @param {ParseOptions.lng} options.getAllErrors - If `false` or `undefined` - returns the first validation error it can find and stops looking, which provides a small runtime optimization.\n * @returns {[undefined, InferType<T>]} A tuple of [undefined, InferType<T>] if parsing is successful.\n * @returns {[ValidationErrorData[], undefined]} A tuple of [ValidationErrorData[], undefined]] if errors occur.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number(),\n * });\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: 30 });\n * // parsedValue will be inferred as { name: string; age: number }\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: '30' });\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // Array 'errors' returns only one element.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { getAllErrors: true});\n * // Returns array \"errors\" with multiple errors because 'age' should be a number and 'name' a string.\n * // With provided options { getAllErrors: true}, we can expecte more than one error in 'errors' array.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { lng: 'SR'});\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // With provided options { lng: 'SR'}, errors will be translated to a language mapped with keyword 'SR'\n */\nexport function parse<T extends CommonSchema>(\n schema: T,\n receivedValue: unknown,\n options?: ParseOptions,\n): [ValidationErrorData[], undefined] | [undefined, InferType<T>] {\n try {\n const ctx = new ExceptionContext(\n receivedValue,\n getTranslationByLocale(options?.lng),\n '',\n options?.getAllErrors ? [] : undefined,\n schema[ctxSymbol].meta,\n );\n\n const parsedValue = innerCheck(schema, receivedValue, ctx) as InferType<T>;\n\n if (ctx.errors?.length) {\n return [ctx.errors, undefined];\n }\n\n return [undefined, parsedValue];\n } catch (e) {\n /* istanbul ignore next */\n if (e instanceof ValidationError) {\n delete e.stack;\n return [[e], undefined];\n }\n /* istanbul ignore next */\n return [\n [\n {\n message: 'Something unexpected happened',\n expected: '',\n received: '',\n pathToError: '',\n meta: undefined,\n },\n ],\n undefined,\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAM,2BAA2B;AAEjC,SAAS,oBAAoB,UAAkB,cAA+C;AAC5F,SAAO,SAAS,QAAQ,0BAA0B,CAAC,GAAG,QAAQ;AAC5D,WAAO,OAAO,eAAe,GAAG,aAAa,GAAG,CAAW,KAAK,KAAK,GAAG;AAAA,EAC1E,CAAC;AACH;AAEO,IAAM,mBAAN,MAAM,kBAAiB;AAAA,EAC5B,YACkB,iBACA,GACA,aACA,QACA,MAChB;AALgB;AACA;AACA;AACA;AACA;AAAA,EACf;AAAA,EAEH,YAAY,kBAA0B,WAAyB;AAC7D,WAAO,IAAI,kBAAiB,KAAK,iBAAiB,KAAK,GAAG,kBAAkB,KAAK,QAAQ,SAAS;AAAA,EACpG;AAAA,EAEO,IAAI,MAAuB;AAEhC,QAAI,MAAW,KAAK;AACpB,UAAM,gBAAgB,KAAK,MAAM,GAAG;AACpC,kBAAc,QAAQ,CAAC,OAAO;AAC5B,YAAM,IAAI,EAAE;AAAA,IACd,CAAC;AAED,WAAO;AAAA,EACT;AAAA,EAEO,SAAS,UAAmB,UAAmB,YAAkC;AACtF,UAAM,aAAa,KAAK,EAAE,UAAU,KAAK;AACzC,UAAM,UAAU,oBAAoB,YAAY,EAAE,GAAG,UAAU,GAAG,UAAU,GAAG,KAAK,YAAY,CAAC;AAEjG,QAAI,KAAK,QAAQ;AACf,WAAK,OAAO,KAAK;AAAA,QACf;AAAA,QACA;AAAA,QACA,aAAa,KAAK;AAAA,QAClB;AAAA,MACF,CAAC;AAED;AAAA,IACF;AAEA,UAAM,IAAI,gBAAgB,UAAU,UAAU,KAAK,aAAa,SAAS,KAAK,IAAI;AAAA,EACpF;AACF;AAKA,SAAS,WAAW,QAAsB,eAAwB,OAAkC;AAClG,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,OAAM,SAAS,YAAY,eAAe,WAAW,YAAY,CAAC;AAC9F,WAAO;AAAA,EACT;AAEA,MAAI,kBAAkB,MAAM;AAC1B,QAAI,CAAC,WAAW,WAAY,OAAM,SAAS,YAAY,eAAe,WAAW,YAAY,CAAC;AAC9F,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,MAAM;AACnB,QAAI,CAAC,iBAAiB,aAAa,EAAG,OAAM,SAAS,QAAQ,eAAe,WAAW,QAAQ,CAAC;AAAA,EAClG;AAEA,QAAM,YAAY,OAAO;AAEzB,MAAI,WAAW,KAAK,QAAQ;AAC1B,QAAI,CAAC,WAAW,KAAK,SAAS,SAAS,EAAG,OAAM,SAAS,WAAW,MAAM,WAAW,WAAW,eAAe,CAAC;AAAA,EAClH;AAEA,MAAI,WAAW,OAAO;AACpB,QAAI,CAAC,MAAM,QAAQ,aAAa,EAAG,QAAO,MAAM,SAAS,SAAS,eAAe,WAAW,SAAS,CAAC;AAEtG,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,MAAM,YAAY,GAAG,WAAW,IAAI,CAAC,KAAK,WAAW,IAAI,CAAC;AACzG,0BAAoB,KAAK,aAAa;AAAA,IACxC,CAAC;AAED,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,QAAQ;AACrB,QAAI,cAAc,SAAU,OAAM,SAAS,UAAU,eAAe,WAAW,cAAc,CAAC;AAC9F,QAAI,MAAM,QAAQ,aAAa,EAAG,OAAM,SAAS,UAAU,eAAe,WAAW,qBAAqB,CAAC;AAE3G,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,gBAAM,SAAS,yBAAyB,qBAAqB,WAAW,wBAAwB,CAAC;AAAA,MACrG;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,gBAAM,SAAS,YAAY,4BAA4B,WAAW,oBAAoB,CAAC;AAAA,MAC3F;AAEA,YAAM,mCAAmC;AAAA,QACvC;AAAA,QACA;AAAA,QACA,MAAM,YAAY,GAAG,WAAW,IAAI,WAAW,IAAI,WAAW,IAAI;AAAA,MACpE;AAEA,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;AAqBO,IAAM,eAAN,MAAmB;AAAA,EACxB,CAAC,SAAS;AAAA,EACV,YAAY,KAAuB;AACjC,SAAK,SAAS,IAAI;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,UAAU,YAAwC;AACvD,SAAK,kBAAkB;AACvB,SAAK,SAAS,EAAE,oBAAoB,KAAK,GAAG,UAAU;AACtD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,WAA2B;AAChC,SAAK,kBAAkB;AACvB,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,WAAgC;AACrC,SAAK,kBAAkB;AACvB,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,QAAQ,cAAqC;AAClD,UAAM,MAAM,KAAK,SAAS;AAC1B,QAAI,IAAI,YAAY;AAClB,YAAM,IAAI,iBAAiB,sDAAsD;AAAA,IACnF;AAEA,QAAI;AACF,kBAAY,MAAM,YAAY;AAAA,IAChC,SAAS,GAAG;AACV,YAAM,IAAI,iBAAkB,EAAY,OAAO;AAAA,IACjD;AAEA,SAAK,SAAS,EAAE,eAAe;AAC/B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBO,0BAA8B,IAAkD;AACrF,UAAM,MAAM,KAAK,SAAS;AAC1B,QAAI,IAAI,qBAAqB;AAC3B,UAAI,oBAAoB,KAAK,EAAE;AAAA,IACjC,OAAO;AACL,UAAI,sBAAsB,CAAC,EAAE;AAAA,IAC/B;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaO,GAAG,OAAqB;AAC7B,WAAO,KAAK,KAAK,MAAM,KAAK;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYO,YAAY,OAAqB;AACtC,WAAO,KAAK,KAAK,eAAe,KAAK;AAAA,EACvC;AAAA,EAEQ,KAAK,KAAa,OAAqB;AAC7C,UAAM,MAAM,KAAK,SAAS;AAC1B,QAAI,OAAO,EAAE,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,MAAM;AACvC,WAAO;AAAA,EACT;AAAA,EAEU,oBAAoB;AAC5B,QAAI,KAAK,SAAS,EAAE,iBAAiB,QAAW;AAC9C,YAAM,IAAI,iBAAiB,wDAAwD;AAAA,IACrF;AAAA,EACF;AACF;AAuCO,SAAS,YACd,QACA,eACA,SACc;AACd,MAAI;AACF,UAAM,MAAM,IAAI;AAAA,MACd;AAAA,MACA,uBAAuB,SAAS,GAAG;AAAA,MACnC;AAAA,MACA;AAAA,MACA,OAAO,SAAS,EAAE;AAAA,IACpB;AACA,WAAO,WAAW,QAAQ,eAAe,GAAG;AAAA,EAC9C,SAAS,GAAG;AAEV,QAAI,aAAa,gBAAiB,OAAM;AAExC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AACF;AA0DO,SAAS,MACd,QACA,eACA,SACgE;AAChE,MAAI;AACF,UAAM,MAAM,IAAI;AAAA,MACd;AAAA,MACA,uBAAuB,SAAS,GAAG;AAAA,MACnC;AAAA,MACA,SAAS,eAAe,CAAC,IAAI;AAAA,MAC7B,OAAO,SAAS,EAAE;AAAA,IACpB;AAEA,UAAM,cAAc,WAAW,QAAQ,eAAe,GAAG;AAEzD,QAAI,IAAI,QAAQ,QAAQ;AACtB,aAAO,CAAC,IAAI,QAAQ,MAAS;AAAA,IAC/B;AAEA,WAAO,CAAC,QAAW,WAAW;AAAA,EAChC,SAAS,GAAG;AAEV,QAAI,aAAa,iBAAiB;AAChC,aAAO,EAAE;AACT,aAAO,CAAC,CAAC,CAAC,GAAG,MAAS;AAAA,IACxB;AAEA,WAAO;AAAA,MACL;AAAA,QACE;AAAA,UACE,SAAS;AAAA,UACT,UAAU;AAAA,UACV,UAAU;AAAA,UACV,aAAa;AAAA,UACb,MAAM;AAAA,QACR;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":["schema"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-S5D5AFDF.js","../src/asserts/string/regExp.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACDA,IAAM,mBAAA,EAAqB,6DAAA;AAC3B,IAAM,eAAA,EAAiB,UAAA;AAchB,IAAM,OAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA,EAAG,GAAA,CAAI,QAAA,CAAS,QAAA,EAAU,QAAA,EAAU,kBAAkB,CAAA;AACnF,CAAA;AAEF,MAAA,CAAO,IAAA,EAAM,cAAA;AACb,MAAA,CAAO,QAAA,EAAU,kBAAA;AACjB,iDAAA,MAAyB,CAAA;ADbzB;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-S5D5AFDF.js","sourcesContent":[null,"import type { ExceptionContext, RequiredValidation } from '../../core';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst regExpErrorMessage = 'The received value does not match the required text pattern';\nconst regExpErrorKey = 's:regExp';\n\n/**\n * @description Asserts that a string value matches a specified regular expression pattern.\n * @param {RegExp} expected The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value does not match the expected pattern.\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseOrFail(schema, 'valid123'); // Valid\n * parseOrFail(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n *\n * @translation Error Translation Key = 's:regExp'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (!expected.test(received)) ctx.addIssue(expected, received, regExpErrorMessage);\n };\n\nregExp.key = regExpErrorKey;\nregExp.message = regExpErrorMessage;\nsetToDefaultLocale(regExp);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/string/isValidDate.ts"],"sourcesContent":["import { setToDefaultLocale } from '../../translationMap';\nimport type { ExceptionContext, RequiredValidation } from '../../core';\n\nconst dateErrorMessage = 'The received value is not a valid date';\nconst dateErrorKey = 's:isValidDate';\n\n// Regex to match YYYY-MM-DD format\nconst dateRegexPattern = /^(19|20)\\d\\d-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$/;\n\n/**\n * @description Asserts that a string is a valid date in the format YYYY-MM-DD.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received string is not a valid date.\n * @example\n * const schema = string().custom(isValidDate());\n * parseOrFail(schema, \"2020-01-01\"); // Valid\n * parseOrFail(schema, \"2020-1-1\"); // Throws an error: 'The received value is not a valid date'\n * parseOrFail(schema, \"2020-01-32\"); // Throws an error: 'The received value is not a valid date'\n *\n * @translation Error Translation Key = 's:isValidDate'\n */\nexport const isValidDate = (): RequiredValidation => {\n return (received: string, ctx: ExceptionContext) => {\n if (!dateRegexPattern.test(received)) {\n ctx.addIssue(received, dateErrorMessage, dateErrorKey);\n }\n };\n};\n\nisValidDate.key = dateErrorKey;\nisValidDate.message = dateErrorMessage;\nsetToDefaultLocale(isValidDate);\n"],"mappings":";;;;;AAGA,IAAM,mBAAmB;AACzB,IAAM,eAAe;AAGrB,IAAM,mBAAmB;AAclB,IAAM,cAAc,MAA0B;AACnD,SAAO,CAAC,UAAkB,QAA0B;AAClD,QAAI,CAAC,iBAAiB,KAAK,QAAQ,GAAG;AACpC,UAAI,SAAS,UAAU,kBAAkB,YAAY;AAAA,IACvD;AAAA,EACF;AACF;AAEA,YAAY,MAAM;AAClB,YAAY,UAAU;AACtB,mBAAmB,WAAW;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asserts/string/regExp.ts"],"sourcesContent":["import type { ExceptionContext, RequiredValidation } from '../../core';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst regExpErrorMessage = 'The received value does not match the required text pattern';\nconst regExpErrorKey = 's:regExp';\n\n/**\n * @description Asserts that a string value matches a specified regular expression pattern.\n * @param {RegExp} expected The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value does not match the expected pattern.\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseOrFail(schema, 'valid123'); // Valid\n * parseOrFail(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n *\n * @translation Error Translation Key = 's:regExp'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (!expected.test(received)) ctx.addIssue(expected, received, regExpErrorMessage);\n };\n\nregExp.key = regExpErrorKey;\nregExp.message = regExpErrorMessage;\nsetToDefaultLocale(regExp);\n"],"mappings":";;;;;AAGA,IAAM,qBAAqB;AAC3B,IAAM,iBAAiB;AAchB,IAAM,SACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,CAAC,SAAS,KAAK,QAAQ,EAAG,KAAI,SAAS,UAAU,UAAU,kBAAkB;AACnF;AAEF,OAAO,MAAM;AACb,OAAO,UAAU;AACjB,mBAAmB,MAAM;","names":[]}
|