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
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,369 @@ 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 { coerceNumber } from 'bguard/coerce/number';
|
|
726
|
+
import { coerceBoolean } from 'bguard/coerce/boolean';
|
|
727
|
+
import { object } from 'bguard/object';
|
|
728
|
+
import { parseOrFail } from 'bguard';
|
|
729
|
+
|
|
730
|
+
const querySchema = object({
|
|
731
|
+
page: coerceNumber().default(1),
|
|
732
|
+
limit: coerceNumber(),
|
|
733
|
+
active: coerceBoolean(),
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
parseOrFail(querySchema, { limit: '20', active: 'true' });
|
|
737
|
+
// { page: 1, limit: 20, active: true }
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
`coerceString`, `coerceNumber`, `coerceBoolean`, `coerceBigInt` and `coerceDate` convert the value
|
|
741
|
+
before validating it. Each lives in its own module — `bguard/coerce/number` and so on — like every other
|
|
742
|
+
assertion in the package.
|
|
743
|
+
|
|
744
|
+
They are also gathered on a `coerce` object for when several read better together:
|
|
745
|
+
|
|
746
|
+
```typeScript
|
|
747
|
+
import { coerce } from 'bguard/coerce';
|
|
748
|
+
import { object } from 'bguard/object';
|
|
749
|
+
|
|
750
|
+
object({ page: coerce.number(), q: coerce.string() });
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
> **Notice:** that object references all five, so a bundler has to keep all five wherever it is used.
|
|
754
|
+
> Reaching for `coerce.number()` alone still pulls in the string, boolean, bigint and date schemas —
|
|
755
|
+
> measured at 2033 bytes against 87 for importing `coerceNumber` from its own module. Import the one you
|
|
756
|
+
> need when bundle size matters.
|
|
757
|
+
|
|
758
|
+
Anything a helper cannot convert is left alone, so validation reports the type problem rather than the conversion silently
|
|
759
|
+
succeeding: `coerceNumber()` on `'abc'` fails, because `Number('abc')` is `NaN` and `number()` rejects
|
|
760
|
+
that.
|
|
761
|
+
|
|
762
|
+
`null` is never coerced, so `nullable()` still decides whether it is allowed instead of it becoming the
|
|
763
|
+
string `'null'` or the number `0`.
|
|
764
|
+
|
|
765
|
+
> **Notice:** `coerceBoolean()` only converts what unambiguously means a boolean — the strings
|
|
766
|
+
> `'true'` and `'false'` in any case, and the numbers `1` and `0`. Everything else is rejected. This is
|
|
767
|
+
> deliberately narrower than passing the value through `Boolean`, which would accept every input and
|
|
768
|
+
> read `'false'` as `true`.
|
|
769
|
+
|
|
770
|
+
### <a id="h3_infer_input"> InferInput and InferOutput </a>
|
|
771
|
+
|
|
772
|
+
`InferType` is the type a schema *produces*, which is what `parse` returns. `InferInput` is the type it
|
|
773
|
+
*accepts*. The two differ wherever a schema converts or supplies something:
|
|
774
|
+
|
|
775
|
+
```typeScript
|
|
776
|
+
import { coerceNumber } from 'bguard/coerce/number';
|
|
777
|
+
import { object } from 'bguard/object';
|
|
778
|
+
import { string } from 'bguard/string';
|
|
779
|
+
import type { InferType, InferInput } from 'bguard/InferType';
|
|
780
|
+
|
|
781
|
+
const schema = object({ page: coerceNumber().default(1), q: string() });
|
|
782
|
+
|
|
783
|
+
type Output = InferType<typeof schema>; // { page: number; q: string }
|
|
784
|
+
type Input = InferInput<typeof schema>; // { q: string; page?: unknown }
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
A default makes a property optional on the input and present on the output. A coercing schema accepts
|
|
788
|
+
`unknown` and yields its target type. Everywhere else the two coincide, so `InferType` needs no
|
|
789
|
+
thought unless you are generating something from the input side — a form, or a client. `InferOutput` is
|
|
790
|
+
available as a name for symmetry and is the same type as `InferType`.
|
|
791
|
+
|
|
792
|
+
Both are reported through Standard Schema, so a consumer asks for what the schema takes rather than
|
|
793
|
+
what it returns.
|
|
794
|
+
|
|
795
|
+
### <a id="h3_async"> Async Validation </a>
|
|
796
|
+
|
|
797
|
+
For a check that has to wait — a uniqueness lookup, an HTTP call — use `customAsync` and one of the
|
|
798
|
+
async entry points.
|
|
799
|
+
|
|
800
|
+
```typeScript
|
|
801
|
+
import { object, string, parseAsync } from 'bguard';
|
|
802
|
+
import type { ExceptionContext } from 'bguard/core';
|
|
803
|
+
|
|
804
|
+
declare function isNameTaken(name: string): Promise<boolean>;
|
|
805
|
+
|
|
806
|
+
const signupSchema = object({
|
|
807
|
+
name: string().customAsync(async (received: string, ctx: ExceptionContext) => {
|
|
808
|
+
if (await isNameTaken(received)) ctx.addIssue('an unused name', received, 'u:taken');
|
|
809
|
+
}),
|
|
810
|
+
});
|
|
811
|
+
|
|
812
|
+
async function handleSignup(received: unknown) {
|
|
813
|
+
const [errors, value] = await parseAsync(signupSchema, received, { getAllErrors: true });
|
|
814
|
+
|
|
815
|
+
if (errors) return errors;
|
|
816
|
+
return value;
|
|
817
|
+
}
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
`parseAsync` and `parseOrFailAsync` mirror `parse` and `parseOrFail`. The structure is validated
|
|
821
|
+
synchronously first and the async validations are collected as they are reached, then awaited **all
|
|
822
|
+
together** — so several slow checks across one schema cost one round of waiting rather than one each.
|
|
823
|
+
|
|
824
|
+
A synchronous `parse` of a schema carrying an async validation throws a `BuildSchemaError` naming the
|
|
825
|
+
async entry points, rather than skipping the validation. A validation that never runs is worse than a
|
|
826
|
+
clear instruction.
|
|
827
|
+
|
|
828
|
+
Standard Schema handles this on its own: `~standard.validate` returns a promise for a schema that needs
|
|
829
|
+
awaiting and stays synchronous for one that does not. The spec allows either, chosen per call, so a
|
|
830
|
+
consumer that never awaits keeps working for every other schema.
|
|
831
|
+
|
|
832
|
+
> **Notice:** Because the async validations are awaited after the walk, their issues come after the
|
|
833
|
+
> synchronous ones. `parseOrFailAsync` therefore cannot stop at the first error the way `parseOrFail`
|
|
834
|
+
> does; it throws the first one found once everything has been awaited.
|
|
835
|
+
|
|
836
|
+
### <a id="h3_json_schema"> JSON Schema </a>
|
|
837
|
+
|
|
838
|
+
`toJSONSchema` renders a schema as a JSON Schema document, for OpenAPI, form generators and LLM tool
|
|
839
|
+
definitions.
|
|
840
|
+
|
|
841
|
+
```typeScript
|
|
842
|
+
import { object, string, number, toJSONSchema } from 'bguard';
|
|
843
|
+
import { minLength } from 'bguard/string/minLength';
|
|
844
|
+
|
|
845
|
+
const userSchema = object({ name: string().custom(minLength(2)), age: number().optional() });
|
|
846
|
+
|
|
847
|
+
toJSONSchema(userSchema, { dialect: null });
|
|
848
|
+
// {
|
|
849
|
+
// type: 'object',
|
|
850
|
+
// properties: { name: { type: 'string', minLength: 2 }, age: { type: 'number' } },
|
|
851
|
+
// required: ['name'],
|
|
852
|
+
// additionalProperties: false,
|
|
853
|
+
// }
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
Represented: types, object properties and which are required, arrays, tuples, records, unions, literals
|
|
857
|
+
and enums, nullability, defaults, `description()`, and recursive schemas through `$defs` and `$ref`.
|
|
858
|
+
Assertions that map onto a keyword are included — string lengths, patterns and formats, numeric bounds,
|
|
859
|
+
array lengths, `maxKeys`.
|
|
860
|
+
|
|
861
|
+
Assertions with no JSON Schema counterpart are **left out rather than approximated**. `contains('x')`
|
|
862
|
+
has no keyword, so it does not appear; a value the document accepts may still be rejected by bguard.
|
|
863
|
+
The document is a faithful description of what it can express, not a complete one.
|
|
864
|
+
|
|
865
|
+
`bigint` raises a `BuildSchemaError`, since it is not representable in JSON at all and emitting
|
|
866
|
+
`integer` would be a lie. A `date()` becomes `{ type: 'string', format: 'date-time' }`.
|
|
867
|
+
|
|
868
|
+
Pass `dialect: null` to leave out `$schema`, which is what you want when embedding the result in an
|
|
869
|
+
OpenAPI `components.schemas` entry.
|
|
870
|
+
|
|
871
|
+
> **Verified against a real validator:** the generated documents are cross-checked with `ajv` over 70
|
|
872
|
+
> values across 19 schemas, so a JSON Schema validator agrees with bguard about which values pass.
|
|
873
|
+
|
|
432
874
|
### <a id="h3_literals"> Literals </a>
|
|
433
875
|
|
|
434
876
|
- <b>String Literals</b>:
|
|
@@ -451,6 +893,7 @@ All built-in asserts are documented in the [Built-in Custom Assert Documentation
|
|
|
451
893
|
Example
|
|
452
894
|
|
|
453
895
|
```typeScript
|
|
896
|
+
import { number } from 'bguard/number';
|
|
454
897
|
import { min } from 'bguard/number/min';
|
|
455
898
|
import { max } from 'bguard/number/max';
|
|
456
899
|
|
|
@@ -466,7 +909,7 @@ Bguard allows developers to create custom validation functions that can be integ
|
|
|
466
909
|
Example: Creating a `minLength` Custom Validation
|
|
467
910
|
|
|
468
911
|
```typescript
|
|
469
|
-
import { ExceptionContext, RequiredValidation } from 'bguard/
|
|
912
|
+
import { ExceptionContext, RequiredValidation } from 'bguard/core';
|
|
470
913
|
import { setToDefaultLocale } from 'bguard/translationMap';
|
|
471
914
|
|
|
472
915
|
const minLengthErrorMessage = 'The received value {{r}} is shorter than the expected length {{e}}';
|
|
@@ -582,6 +1025,9 @@ We have two sets of translations: common errors and specific assertions.
|
|
|
582
1025
|
'c:invalidType': 'Invalid type of data',
|
|
583
1026
|
'c:isBoolean': 'The received value is not {{e}}',
|
|
584
1027
|
'c:date': 'The received value is not a valid instance of Date',
|
|
1028
|
+
'c:nan': 'The received number is not a valid number',
|
|
1029
|
+
'c:union': 'The received value does not match any of the expected types',
|
|
1030
|
+
'c:tupleLength': 'The received tuple has {{r}} entries but {{e}} were expected',
|
|
585
1031
|
```
|
|
586
1032
|
|
|
587
1033
|
<b>Custom Assertion Translations</b>:
|
|
@@ -661,6 +1107,9 @@ import { string } from 'bguard/string';
|
|
|
661
1107
|
```typescript
|
|
662
1108
|
string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'
|
|
663
1109
|
```
|
|
1110
|
+
|
|
1111
|
+
Reads the once-only flag without setting it. The flag belongs on the schema that `custom`
|
|
1112
|
+
returns, not on the one it was derived from.
|
|
664
1113
|
|
|
665
1114
|
|
|
666
1115
|
##### <a id="assert_atleastonedigit_string"> atLeastOneDigit </a>
|
|
@@ -1325,6 +1774,9 @@ import { bigint } from 'bguard/bigint';
|
|
|
1325
1774
|
```typescript
|
|
1326
1775
|
bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n
|
|
1327
1776
|
```
|
|
1777
|
+
|
|
1778
|
+
Reads the once-only flag without setting it. The flag belongs on the schema that `custom`
|
|
1779
|
+
returns, not on the one it was derived from.
|
|
1328
1780
|
|
|
1329
1781
|
|
|
1330
1782
|
##### <a id="assert_bigintmax_bigint"> bigintMax </a>
|
|
@@ -1464,6 +1916,10 @@ import { dateMin } from 'bguard/date/dateMin';
|
|
|
1464
1916
|
import { oneOfTypes } from 'bguard/mix';
|
|
1465
1917
|
```
|
|
1466
1918
|
|
|
1919
|
+
Listing `'undefined'` infers `| undefined`, so the schema has to accept a missing value as well,
|
|
1920
|
+
and an object property holding it has to be optional. Both follow from the `WithUndefined` brand
|
|
1921
|
+
plus `isOptional` on the context.
|
|
1922
|
+
|
|
1467
1923
|
* _Description_ Creates a new schema for validating values that can match any one of the specified primitive types.
|
|
1468
1924
|
|
|
1469
1925
|
* _Param_ {T} valueTypes - An array of primitive types that the value can match.
|
|
@@ -1552,6 +2008,30 @@ import { object } from 'bguard/object';
|
|
|
1552
2008
|
```
|
|
1553
2009
|
|
|
1554
2010
|
|
|
2011
|
+
##### <a id="assert_extend_object"> extend </a>
|
|
2012
|
+
|
|
2013
|
+
```typescript
|
|
2014
|
+
import { extend } from 'bguard/object/extend';
|
|
2015
|
+
```
|
|
2016
|
+
|
|
2017
|
+
* _Description_ Creates a new object schema with extra properties added.
|
|
2018
|
+
|
|
2019
|
+
A property already declared is replaced by the one given here, which is what distinguishes `extend`
|
|
2020
|
+
from `intersection`: `intersection` rejects a duplicate key because it has no basis for choosing,
|
|
2021
|
+
while `extend` is an explicit instruction to override.
|
|
2022
|
+
|
|
2023
|
+
|
|
2024
|
+
@template U
|
|
2025
|
+
* _Param_ {WithObject<CommonSchema, T>} schema - The object schema to build on.
|
|
2026
|
+
@param {U} shapeSchema - The properties to add or replace.
|
|
2027
|
+
* _Example_
|
|
2028
|
+
```typescript
|
|
2029
|
+
const baseSchema = object({ id: string() });
|
|
2030
|
+
const timestamped = extend(baseSchema, { createdAt: string() });
|
|
2031
|
+
parseOrFail(timestamped, { id: '1', createdAt: 'now' }); // Validates successfully
|
|
2032
|
+
```
|
|
2033
|
+
|
|
2034
|
+
|
|
1555
2035
|
##### <a id="assert_maxkeys_object"> maxKeys </a>
|
|
1556
2036
|
|
|
1557
2037
|
```typescript
|
|
@@ -1578,5 +2058,109 @@ import { maxKeys } from 'bguard/object/maxKeys';
|
|
|
1578
2058
|
```
|
|
1579
2059
|
* _See_ Error Translation Key = 'o:maxKeys'
|
|
1580
2060
|
|
|
2061
|
+
|
|
2062
|
+
##### <a id="assert_omit_object"> omit </a>
|
|
2063
|
+
|
|
2064
|
+
```typescript
|
|
2065
|
+
import { omit } from 'bguard/object/omit';
|
|
2066
|
+
```
|
|
2067
|
+
|
|
2068
|
+
* _Description_ Creates a new object schema without the named properties.
|
|
2069
|
+
|
|
2070
|
+
The original is untouched.
|
|
2071
|
+
|
|
2072
|
+
|
|
2073
|
+
@template K
|
|
2074
|
+
* _Param_ {WithObject<CommonSchema, T>} schema - The object schema to narrow.
|
|
2075
|
+
@param {readonly K[]} keys - The properties to drop.
|
|
2076
|
+
* _Example_
|
|
2077
|
+
```typescript
|
|
2078
|
+
const userSchema = object({ id: string(), name: string(), secret: string() });
|
|
2079
|
+
const publicSchema = omit(userSchema, ['secret']);
|
|
2080
|
+
parseOrFail(publicSchema, { id: '1', name: 'a' }); // Validates successfully
|
|
2081
|
+
```
|
|
2082
|
+
|
|
2083
|
+
|
|
2084
|
+
##### <a id="assert_partial_object"> partial </a>
|
|
2085
|
+
|
|
2086
|
+
```typescript
|
|
2087
|
+
import { partial } from 'bguard/object/partial';
|
|
2088
|
+
```
|
|
2089
|
+
|
|
2090
|
+
Named rather than written inline in both the signature and the cast: the two spellings of the same
|
|
2091
|
+
mapped type are not provably identical to the compiler once `~standard` puts a deferred
|
|
2092
|
+
`InferType<this>` inside them.
|
|
2093
|
+
|
|
2094
|
+
* _Description_ Creates a new object schema in which every property is optional.
|
|
2095
|
+
|
|
2096
|
+
Each property schema is made optional in its own right, so the original schema and the property
|
|
2097
|
+
schemas it holds are unchanged.
|
|
2098
|
+
|
|
2099
|
+
|
|
2100
|
+
* _Param_ {WithObject<CommonSchema, T>} schema - The object schema to relax.
|
|
2101
|
+
* _Example_
|
|
2102
|
+
```typescript
|
|
2103
|
+
const userSchema = object({ id: string(), name: string() });
|
|
2104
|
+
const patchSchema = partial(userSchema);
|
|
2105
|
+
parseOrFail(patchSchema, {}); // Validates successfully
|
|
2106
|
+
```
|
|
2107
|
+
|
|
2108
|
+
|
|
2109
|
+
##### <a id="assert_pick_object"> pick </a>
|
|
2110
|
+
|
|
2111
|
+
```typescript
|
|
2112
|
+
import { pick } from 'bguard/object/pick';
|
|
2113
|
+
```
|
|
2114
|
+
|
|
2115
|
+
* _Description_ Creates a new object schema keeping only the named properties.
|
|
2116
|
+
|
|
2117
|
+
The original is untouched, and the properties keep the schemas they had, including their assertions
|
|
2118
|
+
and metadata.
|
|
2119
|
+
|
|
2120
|
+
|
|
2121
|
+
@template K
|
|
2122
|
+
* _Param_ {WithObject<CommonSchema, T>} schema - The object schema to narrow.
|
|
2123
|
+
@param {readonly K[]} keys - The properties to keep.
|
|
2124
|
+
* _Example_
|
|
2125
|
+
```typescript
|
|
2126
|
+
const userSchema = object({ id: string(), name: string(), secret: string() });
|
|
2127
|
+
const publicSchema = pick(userSchema, ['id', 'name']);
|
|
2128
|
+
parseOrFail(publicSchema, { id: '1', name: 'a' }); // Validates successfully
|
|
2129
|
+
```
|
|
2130
|
+
|
|
2131
|
+
Reads the shape of a schema that must be an object schema. Shared by the object utilities.
|
|
2132
|
+
|
|
2133
|
+
Builds a new object schema from a shape, carrying over the source's own settings.
|
|
2134
|
+
|
|
2135
|
+
|
|
2136
|
+
##### <a id="assert_required_object"> required </a>
|
|
2137
|
+
|
|
2138
|
+
```typescript
|
|
2139
|
+
import { required } from 'bguard/object/required';
|
|
2140
|
+
```
|
|
2141
|
+
|
|
2142
|
+
Named rather than written inline in both the signature and the cast: the two spellings of the same
|
|
2143
|
+
mapped type are not provably identical to the compiler once `~standard` puts a deferred
|
|
2144
|
+
`InferType<this>` inside them.
|
|
2145
|
+
|
|
2146
|
+
Removing the brand rather than trying to recover the type it wraps, because an intersection cannot
|
|
2147
|
+
be taken apart again. What matters to `InferType` is that the result no longer carries the marker.
|
|
2148
|
+
|
|
2149
|
+
* _Description_ Creates a new object schema in which every property is required, the counterpart to
|
|
2150
|
+
`partial`.
|
|
2151
|
+
|
|
2152
|
+
A property that carried a default keeps it, so it may still be omitted — a default is what makes a
|
|
2153
|
+
property supply its own value rather than optional.
|
|
2154
|
+
|
|
2155
|
+
|
|
2156
|
+
* _Param_ {WithObject<CommonSchema, T>} schema - The object schema to tighten.
|
|
2157
|
+
* _Example_
|
|
2158
|
+
```typescript
|
|
2159
|
+
const patchSchema = partial(object({ id: string(), name: string() }));
|
|
2160
|
+
const fullSchema = required(patchSchema);
|
|
2161
|
+
parseOrFail(fullSchema, { id: '1', name: 'a' }); // Validates successfully
|
|
2162
|
+
parseOrFail(fullSchema, {}); // Throws a validation error
|
|
2163
|
+
```
|
|
2164
|
+
|
|
1581
2165
|
### Contributing
|
|
1582
2166
|
Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.
|