bguard 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +571 -5
- package/lib/InferType.d.mts +37 -3
- package/lib/InferType.d.ts +37 -3
- package/lib/asserts/array/index.d.mts +1 -0
- package/lib/asserts/array/index.d.ts +1 -0
- package/lib/asserts/array/index.js +6 -6
- package/lib/asserts/array/index.mjs +5 -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 +8 -3
- package/lib/asserts/bigint/index.d.ts +8 -3
- package/lib/asserts/bigint/index.js +9 -9
- package/lib/asserts/bigint/index.mjs +8 -8
- package/lib/asserts/boolean/index.d.mts +9 -2
- package/lib/asserts/boolean/index.d.ts +9 -2
- package/lib/asserts/boolean/index.js +7 -7
- package/lib/asserts/boolean/index.mjs +6 -6
- package/lib/asserts/coerce/index.d.mts +52 -0
- package/lib/asserts/coerce/index.d.ts +52 -0
- package/lib/asserts/coerce/index.js +21 -0
- package/lib/asserts/coerce/index.js.map +1 -0
- package/lib/asserts/coerce/index.mjs +21 -0
- package/lib/asserts/coerce/index.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 +1 -0
- package/lib/asserts/date/index.d.ts +1 -0
- package/lib/asserts/date/index.js +6 -6
- package/lib/asserts/date/index.mjs +5 -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 +3 -2
- package/lib/asserts/number/index.d.ts +3 -2
- package/lib/asserts/number/index.js +9 -9
- package/lib/asserts/number/index.mjs +8 -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 +8 -3
- package/lib/asserts/string/index.d.ts +8 -3
- package/lib/asserts/string/index.js +10 -9
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +9 -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-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-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-5PIGAEGL.mjs +22 -0
- package/lib/chunk-5PIGAEGL.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-5VZDHJKM.mjs +68 -0
- package/lib/chunk-5VZDHJKM.mjs.map +1 -0
- 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-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-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-6WKSLMJG.mjs → chunk-B2R5S6OH.mjs} +6 -6
- 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-OZ3BTSSQ.mjs → chunk-CJCIOMS7.mjs} +19 -17
- package/lib/chunk-CJCIOMS7.mjs.map +1 -0
- 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-NBR3QGKW.js → chunk-DPXTSNEX.js} +5 -5
- package/lib/{chunk-NBR3QGKW.js.map → chunk-DPXTSNEX.js.map} +1 -1
- 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-TCDQA2NU.js → chunk-EJCCIGXH.js} +8 -8
- package/lib/{chunk-TCDQA2NU.js.map → chunk-EJCCIGXH.js.map} +1 -1
- package/lib/{chunk-6LPQRAFN.js → chunk-EN745GWN.js} +10 -7
- package/lib/chunk-EN745GWN.js.map +1 -0
- package/lib/{chunk-OFZMO7PB.mjs → chunk-ETBJ4NF4.mjs} +7 -4
- package/lib/chunk-ETBJ4NF4.mjs.map +1 -0
- package/lib/chunk-EVM26M2C.js +66 -0
- package/lib/chunk-EVM26M2C.js.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-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-GYLCPX6O.js +68 -0
- package/lib/chunk-GYLCPX6O.js.map +1 -0
- 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-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-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-M3HYPZLE.mjs → chunk-KAFZGQ2W.mjs} +10 -8
- package/lib/chunk-KAFZGQ2W.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-KGNT5T35.mjs +70 -0
- package/lib/chunk-KGNT5T35.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-L7YFDMZU.js +78 -0
- package/lib/chunk-L7YFDMZU.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-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-WYM2TIVW.mjs → chunk-O646PJXY.mjs} +3 -3
- 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-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-C2VSTWID.js → chunk-TJ7IQSHU.js} +9 -6
- package/lib/chunk-TJ7IQSHU.js.map +1 -0
- package/lib/chunk-TLLR2DXI.js +70 -0
- package/lib/chunk-TLLR2DXI.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-UCHEFFWR.js +79 -0
- package/lib/chunk-UCHEFFWR.js.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-NFD7D5GZ.mjs → chunk-UWONIZJZ.mjs} +26 -19
- package/lib/chunk-UWONIZJZ.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-TLRVQWCI.mjs → chunk-WL7BV4XV.mjs} +9 -6
- package/lib/chunk-WL7BV4XV.mjs.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-UYQFYQQG.mjs → chunk-YJZXJKM4.mjs} +30 -20
- package/lib/chunk-YJZXJKM4.mjs.map +1 -0
- package/lib/chunk-YOF36UOS.js +19 -0
- package/lib/chunk-YOF36UOS.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 +16 -2
- package/lib/index.d.ts +16 -2
- package/lib/index.js +115 -55
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +135 -75
- 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 +183 -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-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-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-6WKSLMJG.mjs.map → chunk-B2R5S6OH.mjs.map} +0 -0
- /package/lib/{chunk-THU5VBSO.mjs.map → chunk-IIL6D2UL.mjs.map} +0 -0
- /package/lib/{chunk-WYM2TIVW.mjs.map → chunk-O646PJXY.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -22,6 +22,20 @@ Table of contents
|
|
|
22
22
|
* [optional()](#h4_chaining_optional)
|
|
23
23
|
* [id(value: string)](#h4_chaining_id)
|
|
24
24
|
* [description(value: string)](#h4_chaining_description)
|
|
25
|
+
* [Composing Schemas](#h3_union_and_record)
|
|
26
|
+
* [union(schemas)](#h4_union)
|
|
27
|
+
* [record(keySchema, valueSchema)](#h4_record)
|
|
28
|
+
* [tuple(schemas)](#h4_tuple)
|
|
29
|
+
* [intersection(schemas)](#h4_intersection)
|
|
30
|
+
* [lazy(typeName, getSchema)](#h4_lazy)
|
|
31
|
+
* [Standard Schema](#h3_standard_schema)
|
|
32
|
+
* [Error Shape](#h3_error_shape)
|
|
33
|
+
* [Deriving Object Schemas](#h3_object_utilities)
|
|
34
|
+
* [Formatting Errors](#h3_formatting_errors)
|
|
35
|
+
* [Coercion](#h3_coercion)
|
|
36
|
+
* [InferInput and InferOutput](#h3_infer_input)
|
|
37
|
+
* [Async Validation](#h3_async)
|
|
38
|
+
* [JSON Schema](#h3_json_schema)
|
|
25
39
|
* [Literals](#h3_literals)
|
|
26
40
|
* [Custom (Library Built-in) Assertions](#h3_custom_builtin_assertions)
|
|
27
41
|
* [Create Custom Assertions](#h3_create_custom_assertions)
|
|
@@ -84,7 +98,12 @@ Table of contents
|
|
|
84
98
|
* [oneOfValues](#assert_oneofvalues_mix)
|
|
85
99
|
* [object](#assertdir_object)
|
|
86
100
|
* [allowUnrecognized](#assert_object_method_allowunrecognized)
|
|
101
|
+
* [extend](#assert_extend_object)
|
|
87
102
|
* [maxKeys](#assert_maxkeys_object)
|
|
103
|
+
* [omit](#assert_omit_object)
|
|
104
|
+
* [partial](#assert_partial_object)
|
|
105
|
+
* [pick](#assert_pick_object)
|
|
106
|
+
* [required](#assert_required_object)
|
|
88
107
|
|
|
89
108
|
### <a id="h3_features"> Features </a>
|
|
90
109
|
|
|
@@ -304,7 +323,7 @@ The `parseOrFail` method validates the data and throws an error on the first val
|
|
|
304
323
|
**Syntax:**
|
|
305
324
|
|
|
306
325
|
```typeScript
|
|
307
|
-
import { parseOrFail } from 'bguard';
|
|
326
|
+
import { parseOrFail, ValidationError } from 'bguard';
|
|
308
327
|
// import other dependencies
|
|
309
328
|
|
|
310
329
|
try {
|
|
@@ -312,8 +331,12 @@ try {
|
|
|
312
331
|
const validatedData = parseOrFail(studentSchema, validStudentData);
|
|
313
332
|
// If the data is valid, validatedData will contain the parsed value with inferred TypeScript types
|
|
314
333
|
} catch (error) {
|
|
315
|
-
// If the data does not conform to the schema,
|
|
316
|
-
|
|
334
|
+
// If the data does not conform to the schema, a ValidationError will be thrown
|
|
335
|
+
if (error instanceof ValidationError) {
|
|
336
|
+
console.error(error.message); // The first validation error message
|
|
337
|
+
console.error(error.pathToError); // Where in the received value it happened
|
|
338
|
+
console.error(error.meta?.id); // The id() of the schema that failed, if it has one
|
|
339
|
+
}
|
|
317
340
|
}
|
|
318
341
|
```
|
|
319
342
|
|
|
@@ -327,7 +350,27 @@ Options:
|
|
|
327
350
|
|
|
328
351
|
Explanation
|
|
329
352
|
|
|
330
|
-
- **`parse` Method**:
|
|
353
|
+
- **`parse` Method**: Returns a tuple of `[errors, value]`. Exactly one of the two is present and the other is `null`:
|
|
354
|
+
|
|
355
|
+
- on success: `[null, parsedValue]`
|
|
356
|
+
- on failure: `[errors, null]`
|
|
357
|
+
|
|
358
|
+
So the first element is what you branch on:
|
|
359
|
+
|
|
360
|
+
```typeScript
|
|
361
|
+
const [errors, parsedValue] = parse(schema, receivedValue);
|
|
362
|
+
|
|
363
|
+
if (errors) {
|
|
364
|
+
// errors is ValidationErrorData[], parsedValue is null
|
|
365
|
+
return errors;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// parsedValue is typed as InferType<typeof schema> here
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Do not test the second element to decide whether validation passed: a schema may legitimately parse
|
|
372
|
+
to `null`, for example `string().nullable()`. Set `getAllErrors` to collect every error instead of
|
|
373
|
+
stopping at the first.
|
|
331
374
|
|
|
332
375
|
- **`parseOrFail` Method**: This method throws a `ValidationError` when the first validation rule fails, making it suitable for scenarios where early termination of validation is desired.
|
|
333
376
|
|
|
@@ -335,6 +378,28 @@ Explanation
|
|
|
335
378
|
|
|
336
379
|
### <a id="h3_chaining_methods"> Chaining Methods </a>
|
|
337
380
|
|
|
381
|
+
Schemas are immutable. Every method below returns a new schema rather than changing the one it was
|
|
382
|
+
called on, so a schema can be defined once and reused with different refinements:
|
|
383
|
+
|
|
384
|
+
```typeScript
|
|
385
|
+
const name = string().custom(minLength(2));
|
|
386
|
+
|
|
387
|
+
const schema = object({
|
|
388
|
+
firstName: name, // required
|
|
389
|
+
middleName: name.optional(), // optional, firstName is unaffected
|
|
390
|
+
lastName: name.custom(maxLength(50)), // extra rule, only here
|
|
391
|
+
});
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
This also means a refinement has no effect unless you keep its result:
|
|
395
|
+
|
|
396
|
+
```typeScript
|
|
397
|
+
const schema = string();
|
|
398
|
+
schema.custom(minLength(5)); // returns a new schema, which is then discarded
|
|
399
|
+
|
|
400
|
+
const schema = string().custom(minLength(5)); // keep the result instead
|
|
401
|
+
```
|
|
402
|
+
|
|
338
403
|
#### <a id="h4_chaining_nullable"> nullable() </a>
|
|
339
404
|
|
|
340
405
|
Allows the value to be `null`.
|
|
@@ -365,6 +430,20 @@ Sets a default value if the received value is `undefined`. The default value mus
|
|
|
365
430
|
|
|
366
431
|
> **Notice:** Additionally, `default()` must be the last method in the chain because it validates during schema build time that the default value is compatible with the rest of the schema. For example, if the schema is `number()`, the default value cannot be a `string`.
|
|
367
432
|
|
|
433
|
+
|
|
434
|
+
A default also applies to a property of an object schema, so the property may be omitted from the
|
|
435
|
+
received value:
|
|
436
|
+
|
|
437
|
+
```typeScript
|
|
438
|
+
const schema = object({ page: number().default(1), query: string() });
|
|
439
|
+
|
|
440
|
+
parseOrFail(schema, { query: 'shoes' }); // { page: 1, query: 'shoes' }
|
|
441
|
+
parseOrFail(schema, { page: 3, query: 'shoes' }); // { page: 3, query: 'shoes' }
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
Each parse receives its own copy of an object or array default, so mutating one result cannot affect
|
|
445
|
+
a later one.
|
|
446
|
+
|
|
368
447
|
_Example_:
|
|
369
448
|
|
|
370
449
|
```typeScript
|
|
@@ -429,6 +508,351 @@ parseOrFail(stringOrNullSchema, 'test');
|
|
|
429
508
|
parseOrFail(stringOrNullSchema, '');
|
|
430
509
|
```
|
|
431
510
|
|
|
511
|
+
### <a id="h3_union_and_record"> Composing Schemas </a>
|
|
512
|
+
|
|
513
|
+
#### <a id="h4_union"> union(schemas) </a>
|
|
514
|
+
|
|
515
|
+
Accepts a value matching any one of several schemas. Members are tried in order and the first that
|
|
516
|
+
validates cleanly wins, so its parsed value is the result.
|
|
517
|
+
|
|
518
|
+
Unlike `oneOfTypes`, which only compares `typeof`, each member is a full schema. Members carry their
|
|
519
|
+
own assertions and structure, which is what makes discriminating by shape possible.
|
|
520
|
+
|
|
521
|
+
```typeScript
|
|
522
|
+
import { union } from 'bguard/union';
|
|
523
|
+
import { object } from 'bguard/object';
|
|
524
|
+
import { string } from 'bguard/string';
|
|
525
|
+
import { number } from 'bguard/number';
|
|
526
|
+
|
|
527
|
+
const shapeSchema = union([
|
|
528
|
+
object({ kind: string().equalTo('circle'), radius: number() }),
|
|
529
|
+
object({ kind: string().equalTo('square'), side: number() }),
|
|
530
|
+
]);
|
|
531
|
+
|
|
532
|
+
// InferType: { kind: 'circle'; radius: number } | { kind: 'square'; side: number }
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
> **Notice:** A member whose `transformBeforeValidation` coerces the value will match everything, so
|
|
536
|
+
> nothing after it is ever reached. Order members from most to least specific.
|
|
537
|
+
|
|
538
|
+
#### <a id="h4_record"> record(keySchema, valueSchema) </a>
|
|
539
|
+
|
|
540
|
+
Validates an object whose keys are not known in advance. Every key is checked against `keySchema` and
|
|
541
|
+
every value against `valueSchema`.
|
|
542
|
+
|
|
543
|
+
```typeScript
|
|
544
|
+
import { record } from 'bguard/record';
|
|
545
|
+
import { string } from 'bguard/string';
|
|
546
|
+
import { number } from 'bguard/number';
|
|
547
|
+
|
|
548
|
+
const countsSchema = record(string(), number());
|
|
549
|
+
// InferType: Record<string, number>
|
|
550
|
+
|
|
551
|
+
const labelsSchema = record(string().oneOfValues(['en', 'sr']), string());
|
|
552
|
+
// InferType: Partial<Record<'en' | 'sr', string>>
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
A restricted key type infers as `Partial`, because validation checks the keys that are present rather
|
|
556
|
+
than requiring the whole set. Claiming `Record<'en' | 'sr', string>` would say both keys are always
|
|
557
|
+
there, which validation does not guarantee.
|
|
558
|
+
|
|
559
|
+
#### <a id="h4_tuple"> tuple(schemas) </a>
|
|
560
|
+
|
|
561
|
+
A fixed-length array where each position has its own schema. Unlike `array`, which applies one schema
|
|
562
|
+
to every element, the inferred type keeps the positions distinct.
|
|
563
|
+
|
|
564
|
+
```typeScript
|
|
565
|
+
import { tuple } from 'bguard/tuple';
|
|
566
|
+
import { string } from 'bguard/string';
|
|
567
|
+
import { number } from 'bguard/number';
|
|
568
|
+
import { boolean } from 'bguard/boolean';
|
|
569
|
+
|
|
570
|
+
const pointSchema = tuple([number(), number()]);
|
|
571
|
+
// InferType: [number, number]
|
|
572
|
+
|
|
573
|
+
const entrySchema = tuple([string(), boolean().optional()]);
|
|
574
|
+
// InferType: [string, boolean | undefined]
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
> **Notice:** `optional()` on a position describes the value at that position, not whether the
|
|
578
|
+
> position exists. The length must still match exactly.
|
|
579
|
+
|
|
580
|
+
#### <a id="h4_intersection"> intersection(schemas) </a>
|
|
581
|
+
|
|
582
|
+
Combines object schemas into one that requires all of them. The shapes are merged when the schema is
|
|
583
|
+
built, so the result is an ordinary object schema — a key declared by any member is recognised.
|
|
584
|
+
|
|
585
|
+
```typeScript
|
|
586
|
+
import { intersection } from 'bguard/intersection';
|
|
587
|
+
import { object } from 'bguard/object';
|
|
588
|
+
import { string } from 'bguard/string';
|
|
589
|
+
|
|
590
|
+
const withId = object({ id: string() });
|
|
591
|
+
const withTimestamps = object({ createdAt: string(), updatedAt: string() });
|
|
592
|
+
|
|
593
|
+
const entitySchema = intersection([withId, withTimestamps]);
|
|
594
|
+
// InferType: { id: string; createdAt: string; updatedAt: string }
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
Members must be object schemas, and a key may not be declared twice. Two members declaring the same
|
|
598
|
+
key would mean `A & B` for that property in the type while only one schema could run during
|
|
599
|
+
validation, so it throws a `BuildSchemaError` rather than resolving it one way silently. Member-level
|
|
600
|
+
`nullable()` and `optional()` are rejected for the same reason.
|
|
601
|
+
|
|
602
|
+
#### <a id="h4_lazy"> lazy(typeName, getSchema) </a>
|
|
603
|
+
|
|
604
|
+
Defers building a schema until it is first used, which is what allows a schema to refer to itself.
|
|
605
|
+
|
|
606
|
+
```typeScript
|
|
607
|
+
import { lazy } from 'bguard/lazy';
|
|
608
|
+
import { object } from 'bguard/object';
|
|
609
|
+
import { array } from 'bguard/array';
|
|
610
|
+
import { string } from 'bguard/string';
|
|
611
|
+
import type { CommonSchema } from 'bguard/core';
|
|
612
|
+
|
|
613
|
+
interface Category {
|
|
614
|
+
name: string;
|
|
615
|
+
children: Category[];
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
const categorySchema: CommonSchema = object({
|
|
619
|
+
name: string(),
|
|
620
|
+
children: array(lazy<Category>('Category', () => categorySchema)),
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
// codeGen: { name: string; children: Category[]; }
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
The inferred type is the one you supply, because TypeScript cannot infer a type through a
|
|
627
|
+
self-reference. `typeName` is what `codeGen` emits at the recursion point — without it, code
|
|
628
|
+
generation would descend into the schema again and never finish, which is why it is required.
|
|
629
|
+
|
|
630
|
+
> **Notice:** Recursive *schemas* are supported; cyclic *values* are not. Validation follows the data,
|
|
631
|
+
> so a value containing a cycle recurses until the call stack is exhausted.
|
|
632
|
+
|
|
633
|
+
### <a id="h3_standard_schema"> Standard Schema </a>
|
|
634
|
+
|
|
635
|
+
Every bguard schema implements [Standard Schema](https://github.com/standard-schema/standard-schema) v1,
|
|
636
|
+
so it can be handed to any library that accepts a validator — tRPC, TanStack Form and Router, Hono,
|
|
637
|
+
oRPC, React Hook Form — without either side knowing about the other.
|
|
638
|
+
|
|
639
|
+
```typeScript
|
|
640
|
+
import { object, string, number } from 'bguard';
|
|
641
|
+
|
|
642
|
+
const schema = object({ name: string(), age: number() });
|
|
643
|
+
|
|
644
|
+
const result = schema['~standard'].validate({ name: 'a', age: 3 });
|
|
645
|
+
// { value: { name: 'a', age: 3 } }
|
|
646
|
+
|
|
647
|
+
const failed = schema['~standard'].validate({ name: 'a', age: 'x' });
|
|
648
|
+
// { issues: [{ message: 'Invalid type of data', path: ['age'] }] }
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
`validate` collects every issue rather than stopping at the first, since a consumer rendering a form
|
|
652
|
+
needs them all at once. Issue paths are arrays of keys, with numbers for array and tuple positions.
|
|
653
|
+
|
|
654
|
+
### <a id="h3_error_shape"> Error Shape </a>
|
|
655
|
+
|
|
656
|
+
Each validation error carries:
|
|
657
|
+
|
|
658
|
+
| Field | Meaning |
|
|
659
|
+
| --- | --- |
|
|
660
|
+
| `message` | The translated, human-readable message. |
|
|
661
|
+
| `code` | The translation key of the failure, for example `'s:minLength'`. Stable across locales, so this is what to branch on. |
|
|
662
|
+
| `pathToError` | The location as a string, for display: `'.users[1].mail'`. |
|
|
663
|
+
| `path` | The same location as keys: `['users', 1, 'mail']`. A string path cannot be taken apart again reliably, because a key may itself contain a dot. |
|
|
664
|
+
| `expected` / `received` | What the assertion wanted and what it got. |
|
|
665
|
+
| `meta` | The `id()` and `description()` of the schema that failed, if it has any. |
|
|
666
|
+
|
|
667
|
+
### <a id="h3_object_utilities"> Deriving Object Schemas </a>
|
|
668
|
+
|
|
669
|
+
Schemas are immutable, so these return a new schema and leave the source alone.
|
|
670
|
+
|
|
671
|
+
```typeScript
|
|
672
|
+
import { pick } from 'bguard/object/pick';
|
|
673
|
+
import { omit } from 'bguard/object/omit';
|
|
674
|
+
import { partial } from 'bguard/object/partial';
|
|
675
|
+
import { extend } from 'bguard/object/extend';
|
|
676
|
+
import { required } from 'bguard/object/required';
|
|
677
|
+
import { object } from 'bguard/object';
|
|
678
|
+
import { string } from 'bguard/string';
|
|
679
|
+
import { number } from 'bguard/number';
|
|
680
|
+
|
|
681
|
+
const userSchema = object({ id: string(), name: string(), secret: string() });
|
|
682
|
+
|
|
683
|
+
pick(userSchema, ['id', 'name']); // { id: string; name: string }
|
|
684
|
+
omit(userSchema, ['secret']); // { id: string; name: string }
|
|
685
|
+
partial(userSchema); // { id?: string; name?: string; secret?: string }
|
|
686
|
+
extend(userSchema, { age: number() }); // adds age
|
|
687
|
+
required(partial(userSchema)); // back to all required
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
`extend` replaces a property that is already declared, which is the difference from `intersection`:
|
|
691
|
+
`intersection` rejects a duplicate key because it has no basis for choosing, while `extend` is an
|
|
692
|
+
explicit instruction to override. Each of these carries over the source's `allowUnrecognized`, object
|
|
693
|
+
assertions, `id` and `description`.
|
|
694
|
+
|
|
695
|
+
### <a id="h3_formatting_errors"> Formatting Errors </a>
|
|
696
|
+
|
|
697
|
+
Two helpers turn the errors array into the shapes a form usually wants. Both work off `path`.
|
|
698
|
+
|
|
699
|
+
```typeScript
|
|
700
|
+
import { flattenErrors, treeifyErrors, parse, object, string } from 'bguard';
|
|
701
|
+
|
|
702
|
+
const userSchema = object({ email: string(), address: object({ street: string() }) });
|
|
703
|
+
const received: unknown = { email: 1 };
|
|
704
|
+
|
|
705
|
+
const [errors] = parse(userSchema, received, { getAllErrors: true });
|
|
706
|
+
|
|
707
|
+
if (errors) {
|
|
708
|
+
const { formErrors, fieldErrors } = flattenErrors(errors);
|
|
709
|
+
// formErrors: messages belonging to no single field
|
|
710
|
+
// fieldErrors: { email: ['...'], password: ['...'] }
|
|
711
|
+
|
|
712
|
+
const tree = treeifyErrors(errors);
|
|
713
|
+
// tree.properties?.address?.properties?.street?.errors
|
|
714
|
+
}
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
`flattenErrors` attributes a failure to its top-level field, so a form bound to `address` still sees a
|
|
718
|
+
message that came from `address.street`. `treeifyErrors` keeps the full structure instead.
|
|
719
|
+
|
|
720
|
+
### <a id="h3_coercion"> Coercion </a>
|
|
721
|
+
|
|
722
|
+
For input that does not arrive already typed — query strings, form data, environment variables.
|
|
723
|
+
|
|
724
|
+
```typeScript
|
|
725
|
+
import { coerce } from 'bguard/coerce';
|
|
726
|
+
import { object } from 'bguard/object';
|
|
727
|
+
import { parseOrFail } from 'bguard';
|
|
728
|
+
|
|
729
|
+
const querySchema = object({
|
|
730
|
+
page: coerce.number().default(1),
|
|
731
|
+
limit: coerce.number(),
|
|
732
|
+
active: coerce.boolean(),
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
parseOrFail(querySchema, { limit: '20', active: 'true' });
|
|
736
|
+
// { page: 1, limit: 20, active: true }
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
`coerce.string()`, `coerce.number()`, `coerce.boolean()`, `coerce.bigint()` and `coerce.date()` convert
|
|
740
|
+
the value before validating it. Anything a helper cannot convert is left alone, so validation reports
|
|
741
|
+
the type problem rather than the conversion silently succeeding: `coerce.number()` on `'abc'` fails,
|
|
742
|
+
because `Number('abc')` is `NaN` and `number()` rejects that.
|
|
743
|
+
|
|
744
|
+
`null` is never coerced, so `nullable()` still decides whether it is allowed instead of it becoming the
|
|
745
|
+
string `'null'` or the number `0`.
|
|
746
|
+
|
|
747
|
+
> **Notice:** `coerce.boolean()` only converts what unambiguously means a boolean — the strings
|
|
748
|
+
> `'true'` and `'false'` in any case, and the numbers `1` and `0`. Everything else is rejected. This is
|
|
749
|
+
> deliberately narrower than passing the value through `Boolean`, which would accept every input and
|
|
750
|
+
> read `'false'` as `true`.
|
|
751
|
+
|
|
752
|
+
### <a id="h3_infer_input"> InferInput and InferOutput </a>
|
|
753
|
+
|
|
754
|
+
`InferType` is the type a schema *produces*, which is what `parse` returns. `InferInput` is the type it
|
|
755
|
+
*accepts*. The two differ wherever a schema converts or supplies something:
|
|
756
|
+
|
|
757
|
+
```typeScript
|
|
758
|
+
import { coerce } from 'bguard/coerce';
|
|
759
|
+
import { object } from 'bguard/object';
|
|
760
|
+
import { string } from 'bguard/string';
|
|
761
|
+
import type { InferType, InferInput } from 'bguard/InferType';
|
|
762
|
+
|
|
763
|
+
const schema = object({ page: coerce.number().default(1), q: string() });
|
|
764
|
+
|
|
765
|
+
type Output = InferType<typeof schema>; // { page: number; q: string }
|
|
766
|
+
type Input = InferInput<typeof schema>; // { q: string; page?: unknown }
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
A default makes a property optional on the input and present on the output. A coercing schema accepts
|
|
770
|
+
`unknown` and yields its target type. Everywhere else the two coincide, so `InferType` needs no
|
|
771
|
+
thought unless you are generating something from the input side — a form, or a client. `InferOutput` is
|
|
772
|
+
available as a name for symmetry and is the same type as `InferType`.
|
|
773
|
+
|
|
774
|
+
Both are reported through Standard Schema, so a consumer asks for what the schema takes rather than
|
|
775
|
+
what it returns.
|
|
776
|
+
|
|
777
|
+
### <a id="h3_async"> Async Validation </a>
|
|
778
|
+
|
|
779
|
+
For a check that has to wait — a uniqueness lookup, an HTTP call — use `customAsync` and one of the
|
|
780
|
+
async entry points.
|
|
781
|
+
|
|
782
|
+
```typeScript
|
|
783
|
+
import { object, string, parseAsync } from 'bguard';
|
|
784
|
+
import type { ExceptionContext } from 'bguard/core';
|
|
785
|
+
|
|
786
|
+
declare function isNameTaken(name: string): Promise<boolean>;
|
|
787
|
+
|
|
788
|
+
const signupSchema = object({
|
|
789
|
+
name: string().customAsync(async (received: string, ctx: ExceptionContext) => {
|
|
790
|
+
if (await isNameTaken(received)) ctx.addIssue('an unused name', received, 'u:taken');
|
|
791
|
+
}),
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
async function handleSignup(received: unknown) {
|
|
795
|
+
const [errors, value] = await parseAsync(signupSchema, received, { getAllErrors: true });
|
|
796
|
+
|
|
797
|
+
if (errors) return errors;
|
|
798
|
+
return value;
|
|
799
|
+
}
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
`parseAsync` and `parseOrFailAsync` mirror `parse` and `parseOrFail`. The structure is validated
|
|
803
|
+
synchronously first and the async validations are collected as they are reached, then awaited **all
|
|
804
|
+
together** — so several slow checks across one schema cost one round of waiting rather than one each.
|
|
805
|
+
|
|
806
|
+
A synchronous `parse` of a schema carrying an async validation throws a `BuildSchemaError` naming the
|
|
807
|
+
async entry points, rather than skipping the validation. A validation that never runs is worse than a
|
|
808
|
+
clear instruction.
|
|
809
|
+
|
|
810
|
+
Standard Schema handles this on its own: `~standard.validate` returns a promise for a schema that needs
|
|
811
|
+
awaiting and stays synchronous for one that does not. The spec allows either, chosen per call, so a
|
|
812
|
+
consumer that never awaits keeps working for every other schema.
|
|
813
|
+
|
|
814
|
+
> **Notice:** Because the async validations are awaited after the walk, their issues come after the
|
|
815
|
+
> synchronous ones. `parseOrFailAsync` therefore cannot stop at the first error the way `parseOrFail`
|
|
816
|
+
> does; it throws the first one found once everything has been awaited.
|
|
817
|
+
|
|
818
|
+
### <a id="h3_json_schema"> JSON Schema </a>
|
|
819
|
+
|
|
820
|
+
`toJSONSchema` renders a schema as a JSON Schema document, for OpenAPI, form generators and LLM tool
|
|
821
|
+
definitions.
|
|
822
|
+
|
|
823
|
+
```typeScript
|
|
824
|
+
import { object, string, number, toJSONSchema } from 'bguard';
|
|
825
|
+
import { minLength } from 'bguard/string/minLength';
|
|
826
|
+
|
|
827
|
+
const userSchema = object({ name: string().custom(minLength(2)), age: number().optional() });
|
|
828
|
+
|
|
829
|
+
toJSONSchema(userSchema, { dialect: null });
|
|
830
|
+
// {
|
|
831
|
+
// type: 'object',
|
|
832
|
+
// properties: { name: { type: 'string', minLength: 2 }, age: { type: 'number' } },
|
|
833
|
+
// required: ['name'],
|
|
834
|
+
// additionalProperties: false,
|
|
835
|
+
// }
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
Represented: types, object properties and which are required, arrays, tuples, records, unions, literals
|
|
839
|
+
and enums, nullability, defaults, `description()`, and recursive schemas through `$defs` and `$ref`.
|
|
840
|
+
Assertions that map onto a keyword are included — string lengths, patterns and formats, numeric bounds,
|
|
841
|
+
array lengths, `maxKeys`.
|
|
842
|
+
|
|
843
|
+
Assertions with no JSON Schema counterpart are **left out rather than approximated**. `contains('x')`
|
|
844
|
+
has no keyword, so it does not appear; a value the document accepts may still be rejected by bguard.
|
|
845
|
+
The document is a faithful description of what it can express, not a complete one.
|
|
846
|
+
|
|
847
|
+
`bigint` raises a `BuildSchemaError`, since it is not representable in JSON at all and emitting
|
|
848
|
+
`integer` would be a lie. A `date()` becomes `{ type: 'string', format: 'date-time' }`.
|
|
849
|
+
|
|
850
|
+
Pass `dialect: null` to leave out `$schema`, which is what you want when embedding the result in an
|
|
851
|
+
OpenAPI `components.schemas` entry.
|
|
852
|
+
|
|
853
|
+
> **Verified against a real validator:** the generated documents are cross-checked with `ajv` over 70
|
|
854
|
+
> values across 19 schemas, so a JSON Schema validator agrees with bguard about which values pass.
|
|
855
|
+
|
|
432
856
|
### <a id="h3_literals"> Literals </a>
|
|
433
857
|
|
|
434
858
|
- <b>String Literals</b>:
|
|
@@ -451,6 +875,7 @@ All built-in asserts are documented in the [Built-in Custom Assert Documentation
|
|
|
451
875
|
Example
|
|
452
876
|
|
|
453
877
|
```typeScript
|
|
878
|
+
import { number } from 'bguard/number';
|
|
454
879
|
import { min } from 'bguard/number/min';
|
|
455
880
|
import { max } from 'bguard/number/max';
|
|
456
881
|
|
|
@@ -466,7 +891,7 @@ Bguard allows developers to create custom validation functions that can be integ
|
|
|
466
891
|
Example: Creating a `minLength` Custom Validation
|
|
467
892
|
|
|
468
893
|
```typescript
|
|
469
|
-
import { ExceptionContext, RequiredValidation } from 'bguard/
|
|
894
|
+
import { ExceptionContext, RequiredValidation } from 'bguard/core';
|
|
470
895
|
import { setToDefaultLocale } from 'bguard/translationMap';
|
|
471
896
|
|
|
472
897
|
const minLengthErrorMessage = 'The received value {{r}} is shorter than the expected length {{e}}';
|
|
@@ -582,6 +1007,9 @@ We have two sets of translations: common errors and specific assertions.
|
|
|
582
1007
|
'c:invalidType': 'Invalid type of data',
|
|
583
1008
|
'c:isBoolean': 'The received value is not {{e}}',
|
|
584
1009
|
'c:date': 'The received value is not a valid instance of Date',
|
|
1010
|
+
'c:nan': 'The received number is not a valid number',
|
|
1011
|
+
'c:union': 'The received value does not match any of the expected types',
|
|
1012
|
+
'c:tupleLength': 'The received tuple has {{r}} entries but {{e}} were expected',
|
|
585
1013
|
```
|
|
586
1014
|
|
|
587
1015
|
<b>Custom Assertion Translations</b>:
|
|
@@ -661,6 +1089,9 @@ import { string } from 'bguard/string';
|
|
|
661
1089
|
```typescript
|
|
662
1090
|
string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'
|
|
663
1091
|
```
|
|
1092
|
+
|
|
1093
|
+
Reads the once-only flag without setting it. The flag belongs on the schema that `custom`
|
|
1094
|
+
returns, not on the one it was derived from.
|
|
664
1095
|
|
|
665
1096
|
|
|
666
1097
|
##### <a id="assert_atleastonedigit_string"> atLeastOneDigit </a>
|
|
@@ -1325,6 +1756,9 @@ import { bigint } from 'bguard/bigint';
|
|
|
1325
1756
|
```typescript
|
|
1326
1757
|
bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n
|
|
1327
1758
|
```
|
|
1759
|
+
|
|
1760
|
+
Reads the once-only flag without setting it. The flag belongs on the schema that `custom`
|
|
1761
|
+
returns, not on the one it was derived from.
|
|
1328
1762
|
|
|
1329
1763
|
|
|
1330
1764
|
##### <a id="assert_bigintmax_bigint"> bigintMax </a>
|
|
@@ -1464,6 +1898,10 @@ import { dateMin } from 'bguard/date/dateMin';
|
|
|
1464
1898
|
import { oneOfTypes } from 'bguard/mix';
|
|
1465
1899
|
```
|
|
1466
1900
|
|
|
1901
|
+
Listing `'undefined'` infers `| undefined`, so the schema has to accept a missing value as well,
|
|
1902
|
+
and an object property holding it has to be optional. Both follow from the `WithUndefined` brand
|
|
1903
|
+
plus `isOptional` on the context.
|
|
1904
|
+
|
|
1467
1905
|
* _Description_ Creates a new schema for validating values that can match any one of the specified primitive types.
|
|
1468
1906
|
|
|
1469
1907
|
* _Param_ {T} valueTypes - An array of primitive types that the value can match.
|
|
@@ -1552,6 +1990,30 @@ import { object } from 'bguard/object';
|
|
|
1552
1990
|
```
|
|
1553
1991
|
|
|
1554
1992
|
|
|
1993
|
+
##### <a id="assert_extend_object"> extend </a>
|
|
1994
|
+
|
|
1995
|
+
```typescript
|
|
1996
|
+
import { extend } from 'bguard/object/extend';
|
|
1997
|
+
```
|
|
1998
|
+
|
|
1999
|
+
* _Description_ Creates a new object schema with extra properties added.
|
|
2000
|
+
|
|
2001
|
+
A property already declared is replaced by the one given here, which is what distinguishes `extend`
|
|
2002
|
+
from `intersection`: `intersection` rejects a duplicate key because it has no basis for choosing,
|
|
2003
|
+
while `extend` is an explicit instruction to override.
|
|
2004
|
+
|
|
2005
|
+
|
|
2006
|
+
@template U
|
|
2007
|
+
* _Param_ {WithObject<CommonSchema, T>} schema - The object schema to build on.
|
|
2008
|
+
@param {U} shapeSchema - The properties to add or replace.
|
|
2009
|
+
* _Example_
|
|
2010
|
+
```typescript
|
|
2011
|
+
const baseSchema = object({ id: string() });
|
|
2012
|
+
const timestamped = extend(baseSchema, { createdAt: string() });
|
|
2013
|
+
parseOrFail(timestamped, { id: '1', createdAt: 'now' }); // Validates successfully
|
|
2014
|
+
```
|
|
2015
|
+
|
|
2016
|
+
|
|
1555
2017
|
##### <a id="assert_maxkeys_object"> maxKeys </a>
|
|
1556
2018
|
|
|
1557
2019
|
```typescript
|
|
@@ -1578,5 +2040,109 @@ import { maxKeys } from 'bguard/object/maxKeys';
|
|
|
1578
2040
|
```
|
|
1579
2041
|
* _See_ Error Translation Key = 'o:maxKeys'
|
|
1580
2042
|
|
|
2043
|
+
|
|
2044
|
+
##### <a id="assert_omit_object"> omit </a>
|
|
2045
|
+
|
|
2046
|
+
```typescript
|
|
2047
|
+
import { omit } from 'bguard/object/omit';
|
|
2048
|
+
```
|
|
2049
|
+
|
|
2050
|
+
* _Description_ Creates a new object schema without the named properties.
|
|
2051
|
+
|
|
2052
|
+
The original is untouched.
|
|
2053
|
+
|
|
2054
|
+
|
|
2055
|
+
@template K
|
|
2056
|
+
* _Param_ {WithObject<CommonSchema, T>} schema - The object schema to narrow.
|
|
2057
|
+
@param {readonly K[]} keys - The properties to drop.
|
|
2058
|
+
* _Example_
|
|
2059
|
+
```typescript
|
|
2060
|
+
const userSchema = object({ id: string(), name: string(), secret: string() });
|
|
2061
|
+
const publicSchema = omit(userSchema, ['secret']);
|
|
2062
|
+
parseOrFail(publicSchema, { id: '1', name: 'a' }); // Validates successfully
|
|
2063
|
+
```
|
|
2064
|
+
|
|
2065
|
+
|
|
2066
|
+
##### <a id="assert_partial_object"> partial </a>
|
|
2067
|
+
|
|
2068
|
+
```typescript
|
|
2069
|
+
import { partial } from 'bguard/object/partial';
|
|
2070
|
+
```
|
|
2071
|
+
|
|
2072
|
+
Named rather than written inline in both the signature and the cast: the two spellings of the same
|
|
2073
|
+
mapped type are not provably identical to the compiler once `~standard` puts a deferred
|
|
2074
|
+
`InferType<this>` inside them.
|
|
2075
|
+
|
|
2076
|
+
* _Description_ Creates a new object schema in which every property is optional.
|
|
2077
|
+
|
|
2078
|
+
Each property schema is made optional in its own right, so the original schema and the property
|
|
2079
|
+
schemas it holds are unchanged.
|
|
2080
|
+
|
|
2081
|
+
|
|
2082
|
+
* _Param_ {WithObject<CommonSchema, T>} schema - The object schema to relax.
|
|
2083
|
+
* _Example_
|
|
2084
|
+
```typescript
|
|
2085
|
+
const userSchema = object({ id: string(), name: string() });
|
|
2086
|
+
const patchSchema = partial(userSchema);
|
|
2087
|
+
parseOrFail(patchSchema, {}); // Validates successfully
|
|
2088
|
+
```
|
|
2089
|
+
|
|
2090
|
+
|
|
2091
|
+
##### <a id="assert_pick_object"> pick </a>
|
|
2092
|
+
|
|
2093
|
+
```typescript
|
|
2094
|
+
import { pick } from 'bguard/object/pick';
|
|
2095
|
+
```
|
|
2096
|
+
|
|
2097
|
+
* _Description_ Creates a new object schema keeping only the named properties.
|
|
2098
|
+
|
|
2099
|
+
The original is untouched, and the properties keep the schemas they had, including their assertions
|
|
2100
|
+
and metadata.
|
|
2101
|
+
|
|
2102
|
+
|
|
2103
|
+
@template K
|
|
2104
|
+
* _Param_ {WithObject<CommonSchema, T>} schema - The object schema to narrow.
|
|
2105
|
+
@param {readonly K[]} keys - The properties to keep.
|
|
2106
|
+
* _Example_
|
|
2107
|
+
```typescript
|
|
2108
|
+
const userSchema = object({ id: string(), name: string(), secret: string() });
|
|
2109
|
+
const publicSchema = pick(userSchema, ['id', 'name']);
|
|
2110
|
+
parseOrFail(publicSchema, { id: '1', name: 'a' }); // Validates successfully
|
|
2111
|
+
```
|
|
2112
|
+
|
|
2113
|
+
Reads the shape of a schema that must be an object schema. Shared by the object utilities.
|
|
2114
|
+
|
|
2115
|
+
Builds a new object schema from a shape, carrying over the source's own settings.
|
|
2116
|
+
|
|
2117
|
+
|
|
2118
|
+
##### <a id="assert_required_object"> required </a>
|
|
2119
|
+
|
|
2120
|
+
```typescript
|
|
2121
|
+
import { required } from 'bguard/object/required';
|
|
2122
|
+
```
|
|
2123
|
+
|
|
2124
|
+
Named rather than written inline in both the signature and the cast: the two spellings of the same
|
|
2125
|
+
mapped type are not provably identical to the compiler once `~standard` puts a deferred
|
|
2126
|
+
`InferType<this>` inside them.
|
|
2127
|
+
|
|
2128
|
+
Removing the brand rather than trying to recover the type it wraps, because an intersection cannot
|
|
2129
|
+
be taken apart again. What matters to `InferType` is that the result no longer carries the marker.
|
|
2130
|
+
|
|
2131
|
+
* _Description_ Creates a new object schema in which every property is required, the counterpart to
|
|
2132
|
+
`partial`.
|
|
2133
|
+
|
|
2134
|
+
A property that carried a default keeps it, so it may still be omitted — a default is what makes a
|
|
2135
|
+
property supply its own value rather than optional.
|
|
2136
|
+
|
|
2137
|
+
|
|
2138
|
+
* _Param_ {WithObject<CommonSchema, T>} schema - The object schema to tighten.
|
|
2139
|
+
* _Example_
|
|
2140
|
+
```typescript
|
|
2141
|
+
const patchSchema = partial(object({ id: string(), name: string() }));
|
|
2142
|
+
const fullSchema = required(patchSchema);
|
|
2143
|
+
parseOrFail(fullSchema, { id: '1', name: 'a' }); // Validates successfully
|
|
2144
|
+
parseOrFail(fullSchema, {}); // Throws a validation error
|
|
2145
|
+
```
|
|
2146
|
+
|
|
1581
2147
|
### Contributing
|
|
1582
2148
|
Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.
|