bguard 0.5.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 +643 -7
- package/lib/InferType.d.mts +37 -3
- package/lib/InferType.d.ts +37 -3
- package/lib/asserts/array/index.d.mts +8 -3
- package/lib/asserts/array/index.d.ts +8 -3
- package/lib/asserts/array/index.js +6 -12
- package/lib/asserts/array/index.js.map +1 -1
- package/lib/asserts/array/index.mjs +6 -12
- package/lib/asserts/array/index.mjs.map +1 -1
- package/lib/asserts/array/maxArrayLength.d.mts +5 -2
- package/lib/asserts/array/maxArrayLength.d.ts +5 -2
- package/lib/asserts/array/maxArrayLength.js +5 -13
- package/lib/asserts/array/maxArrayLength.js.map +1 -1
- package/lib/asserts/array/maxArrayLength.mjs +5 -13
- package/lib/asserts/array/maxArrayLength.mjs.map +1 -1
- package/lib/asserts/array/minArrayLength.d.mts +5 -2
- package/lib/asserts/array/minArrayLength.d.ts +5 -2
- package/lib/asserts/array/minArrayLength.js +5 -13
- package/lib/asserts/array/minArrayLength.js.map +1 -1
- package/lib/asserts/array/minArrayLength.mjs +5 -13
- package/lib/asserts/array/minArrayLength.mjs.map +1 -1
- package/lib/asserts/bigint/bigintMax.d.mts +5 -2
- package/lib/asserts/bigint/bigintMax.d.ts +5 -2
- package/lib/asserts/bigint/bigintMax.js +4 -13
- package/lib/asserts/bigint/bigintMax.js.map +1 -1
- package/lib/asserts/bigint/bigintMax.mjs +4 -13
- package/lib/asserts/bigint/bigintMax.mjs.map +1 -1
- package/lib/asserts/bigint/bigintMaxExcluded.d.mts +5 -2
- package/lib/asserts/bigint/bigintMaxExcluded.d.ts +5 -2
- package/lib/asserts/bigint/bigintMaxExcluded.js +4 -13
- package/lib/asserts/bigint/bigintMaxExcluded.js.map +1 -1
- package/lib/asserts/bigint/bigintMaxExcluded.mjs +4 -13
- package/lib/asserts/bigint/bigintMaxExcluded.mjs.map +1 -1
- package/lib/asserts/bigint/bigintMin.d.mts +5 -2
- package/lib/asserts/bigint/bigintMin.d.ts +5 -2
- package/lib/asserts/bigint/bigintMin.js +4 -13
- package/lib/asserts/bigint/bigintMin.js.map +1 -1
- package/lib/asserts/bigint/bigintMin.mjs +4 -13
- package/lib/asserts/bigint/bigintMin.mjs.map +1 -1
- package/lib/asserts/bigint/bigintMinExcluded.d.mts +5 -2
- package/lib/asserts/bigint/bigintMinExcluded.d.ts +5 -2
- package/lib/asserts/bigint/bigintMinExcluded.js +4 -13
- package/lib/asserts/bigint/bigintMinExcluded.js.map +1 -1
- package/lib/asserts/bigint/bigintMinExcluded.mjs +4 -13
- package/lib/asserts/bigint/bigintMinExcluded.mjs.map +1 -1
- package/lib/asserts/bigint/index.d.mts +35 -4
- package/lib/asserts/bigint/index.d.ts +35 -4
- package/lib/asserts/bigint/index.js +9 -16
- package/lib/asserts/bigint/index.js.map +1 -1
- package/lib/asserts/bigint/index.mjs +9 -16
- package/lib/asserts/bigint/index.mjs.map +1 -1
- package/lib/asserts/boolean/index.d.mts +32 -3
- package/lib/asserts/boolean/index.d.ts +32 -3
- package/lib/asserts/boolean/index.js +7 -13
- package/lib/asserts/boolean/index.js.map +1 -1
- package/lib/asserts/boolean/index.mjs +7 -13
- package/lib/asserts/boolean/index.mjs.map +1 -1
- package/lib/asserts/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/date/dateMax.d.mts +5 -2
- package/lib/asserts/date/dateMax.d.ts +5 -2
- package/lib/asserts/date/dateMax.js +5 -22
- package/lib/asserts/date/dateMax.js.map +1 -1
- package/lib/asserts/date/dateMax.mjs +5 -22
- package/lib/asserts/date/dateMax.mjs.map +1 -1
- package/lib/asserts/date/dateMin.d.mts +5 -2
- package/lib/asserts/date/dateMin.d.ts +5 -2
- package/lib/asserts/date/dateMin.js +5 -22
- package/lib/asserts/date/dateMin.js.map +1 -1
- package/lib/asserts/date/dateMin.mjs +5 -22
- package/lib/asserts/date/dateMin.mjs.map +1 -1
- package/lib/asserts/date/index.d.mts +7 -3
- package/lib/asserts/date/index.d.ts +7 -3
- package/lib/asserts/date/index.js +6 -12
- package/lib/asserts/date/index.js.map +1 -1
- package/lib/asserts/date/index.mjs +6 -12
- package/lib/asserts/date/index.mjs.map +1 -1
- package/lib/asserts/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/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/mix/equalTo.d.mts +5 -2
- package/lib/asserts/mix/equalTo.d.ts +5 -2
- package/lib/asserts/mix/equalTo.js +4 -4
- package/lib/asserts/mix/equalTo.mjs +3 -3
- package/lib/asserts/mix/index.d.mts +12 -6
- package/lib/asserts/mix/index.d.ts +12 -6
- package/lib/asserts/mix/index.js +6 -11
- package/lib/asserts/mix/index.js.map +1 -1
- package/lib/asserts/mix/index.mjs +6 -11
- package/lib/asserts/mix/index.mjs.map +1 -1
- package/lib/asserts/mix/oneOfValues.d.mts +5 -2
- package/lib/asserts/mix/oneOfValues.d.ts +5 -2
- package/lib/asserts/mix/oneOfValues.js +4 -4
- package/lib/asserts/mix/oneOfValues.mjs +3 -3
- package/lib/asserts/number/index.d.mts +29 -3
- package/lib/asserts/number/index.d.ts +29 -3
- package/lib/asserts/number/index.js +9 -16
- package/lib/asserts/number/index.js.map +1 -1
- package/lib/asserts/number/index.mjs +9 -16
- package/lib/asserts/number/index.mjs.map +1 -1
- package/lib/asserts/number/max.d.mts +5 -2
- package/lib/asserts/number/max.d.ts +5 -2
- package/lib/asserts/number/max.js +5 -13
- package/lib/asserts/number/max.js.map +1 -1
- package/lib/asserts/number/max.mjs +5 -13
- package/lib/asserts/number/max.mjs.map +1 -1
- package/lib/asserts/number/maxExcluded.d.mts +5 -2
- package/lib/asserts/number/maxExcluded.d.ts +5 -2
- package/lib/asserts/number/maxExcluded.js +5 -13
- package/lib/asserts/number/maxExcluded.js.map +1 -1
- package/lib/asserts/number/maxExcluded.mjs +5 -13
- package/lib/asserts/number/maxExcluded.mjs.map +1 -1
- package/lib/asserts/number/min.d.mts +5 -2
- package/lib/asserts/number/min.d.ts +5 -2
- package/lib/asserts/number/min.js +5 -13
- package/lib/asserts/number/min.js.map +1 -1
- package/lib/asserts/number/min.mjs +5 -13
- package/lib/asserts/number/min.mjs.map +1 -1
- package/lib/asserts/number/minExcluded.d.mts +5 -2
- package/lib/asserts/number/minExcluded.d.ts +5 -2
- package/lib/asserts/number/minExcluded.js +5 -13
- package/lib/asserts/number/minExcluded.js.map +1 -1
- package/lib/asserts/number/minExcluded.mjs +5 -13
- package/lib/asserts/number/minExcluded.mjs.map +1 -1
- package/lib/asserts/number/negative.d.mts +5 -2
- package/lib/asserts/number/negative.d.ts +5 -2
- package/lib/asserts/number/negative.js +5 -13
- package/lib/asserts/number/negative.js.map +1 -1
- package/lib/asserts/number/negative.mjs +5 -13
- package/lib/asserts/number/negative.mjs.map +1 -1
- package/lib/asserts/number/positive.d.mts +5 -2
- package/lib/asserts/number/positive.d.ts +5 -2
- package/lib/asserts/number/positive.js +5 -13
- package/lib/asserts/number/positive.js.map +1 -1
- package/lib/asserts/number/positive.mjs +5 -13
- package/lib/asserts/number/positive.mjs.map +1 -1
- 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/index.d.mts +28 -4
- package/lib/asserts/object/index.d.ts +28 -4
- package/lib/asserts/object/index.js +7 -11
- package/lib/asserts/object/index.js.map +1 -1
- package/lib/asserts/object/index.mjs +8 -12
- package/lib/asserts/object/index.mjs.map +1 -1
- package/lib/asserts/object/maxKeys.d.mts +5 -2
- package/lib/asserts/object/maxKeys.d.ts +5 -2
- package/lib/asserts/object/maxKeys.js +5 -16
- package/lib/asserts/object/maxKeys.js.map +1 -1
- package/lib/asserts/object/maxKeys.mjs +5 -16
- package/lib/asserts/object/maxKeys.mjs.map +1 -1
- 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/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/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/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/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/string/atLeastOneDigit.d.mts +5 -2
- package/lib/asserts/string/atLeastOneDigit.d.ts +5 -2
- package/lib/asserts/string/atLeastOneDigit.js +4 -14
- package/lib/asserts/string/atLeastOneDigit.js.map +1 -1
- package/lib/asserts/string/atLeastOneDigit.mjs +4 -14
- package/lib/asserts/string/atLeastOneDigit.mjs.map +1 -1
- package/lib/asserts/string/atLeastOneLowerChar.d.mts +5 -2
- package/lib/asserts/string/atLeastOneLowerChar.d.ts +5 -2
- package/lib/asserts/string/atLeastOneLowerChar.js +4 -15
- package/lib/asserts/string/atLeastOneLowerChar.js.map +1 -1
- package/lib/asserts/string/atLeastOneLowerChar.mjs +4 -15
- package/lib/asserts/string/atLeastOneLowerChar.mjs.map +1 -1
- package/lib/asserts/string/atLeastOneSpecialChar.d.mts +5 -2
- package/lib/asserts/string/atLeastOneSpecialChar.d.ts +5 -2
- package/lib/asserts/string/atLeastOneSpecialChar.js +5 -19
- package/lib/asserts/string/atLeastOneSpecialChar.js.map +1 -1
- package/lib/asserts/string/atLeastOneSpecialChar.mjs +4 -18
- package/lib/asserts/string/atLeastOneSpecialChar.mjs.map +1 -1
- package/lib/asserts/string/atLeastOneUpperChar.d.mts +5 -2
- package/lib/asserts/string/atLeastOneUpperChar.d.ts +5 -2
- package/lib/asserts/string/atLeastOneUpperChar.js +4 -15
- package/lib/asserts/string/atLeastOneUpperChar.js.map +1 -1
- package/lib/asserts/string/atLeastOneUpperChar.mjs +4 -15
- package/lib/asserts/string/atLeastOneUpperChar.mjs.map +1 -1
- package/lib/asserts/string/contains.d.mts +5 -2
- package/lib/asserts/string/contains.d.ts +5 -2
- package/lib/asserts/string/contains.js +4 -15
- package/lib/asserts/string/contains.js.map +1 -1
- package/lib/asserts/string/contains.mjs +4 -15
- package/lib/asserts/string/contains.mjs.map +1 -1
- package/lib/asserts/string/email.d.mts +5 -2
- package/lib/asserts/string/email.d.ts +5 -2
- package/lib/asserts/string/email.js +5 -14
- package/lib/asserts/string/email.js.map +1 -1
- package/lib/asserts/string/email.mjs +5 -14
- package/lib/asserts/string/email.mjs.map +1 -1
- package/lib/asserts/string/endsWith.d.mts +5 -2
- package/lib/asserts/string/endsWith.d.ts +5 -2
- package/lib/asserts/string/endsWith.js +4 -15
- package/lib/asserts/string/endsWith.js.map +1 -1
- package/lib/asserts/string/endsWith.mjs +4 -15
- package/lib/asserts/string/endsWith.mjs.map +1 -1
- package/lib/asserts/string/index.d.mts +34 -3
- package/lib/asserts/string/index.d.ts +34 -3
- package/lib/asserts/string/index.js +10 -16
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +10 -16
- package/lib/asserts/string/index.mjs.map +1 -1
- package/lib/asserts/string/isValidDate.d.mts +5 -2
- package/lib/asserts/string/isValidDate.d.ts +5 -2
- package/lib/asserts/string/isValidDate.js +5 -18
- package/lib/asserts/string/isValidDate.js.map +1 -1
- package/lib/asserts/string/isValidDate.mjs +5 -18
- package/lib/asserts/string/isValidDate.mjs.map +1 -1
- package/lib/asserts/string/isValidDateTime.d.mts +5 -2
- package/lib/asserts/string/isValidDateTime.d.ts +5 -2
- package/lib/asserts/string/isValidDateTime.js +5 -25
- package/lib/asserts/string/isValidDateTime.js.map +1 -1
- package/lib/asserts/string/isValidDateTime.mjs +5 -25
- package/lib/asserts/string/isValidDateTime.mjs.map +1 -1
- package/lib/asserts/string/isValidTime.d.mts +5 -2
- package/lib/asserts/string/isValidTime.d.ts +5 -2
- package/lib/asserts/string/isValidTime.js +5 -25
- package/lib/asserts/string/isValidTime.js.map +1 -1
- package/lib/asserts/string/isValidTime.mjs +5 -25
- package/lib/asserts/string/isValidTime.mjs.map +1 -1
- package/lib/asserts/string/lowerCase.d.mts +5 -2
- package/lib/asserts/string/lowerCase.d.ts +5 -2
- package/lib/asserts/string/lowerCase.js +4 -13
- package/lib/asserts/string/lowerCase.js.map +1 -1
- package/lib/asserts/string/lowerCase.mjs +4 -13
- package/lib/asserts/string/lowerCase.mjs.map +1 -1
- package/lib/asserts/string/maxLength.d.mts +5 -2
- package/lib/asserts/string/maxLength.d.ts +5 -2
- package/lib/asserts/string/maxLength.js +5 -13
- package/lib/asserts/string/maxLength.js.map +1 -1
- package/lib/asserts/string/maxLength.mjs +5 -13
- package/lib/asserts/string/maxLength.mjs.map +1 -1
- package/lib/asserts/string/minLength.d.mts +5 -2
- package/lib/asserts/string/minLength.d.ts +5 -2
- package/lib/asserts/string/minLength.js +5 -13
- package/lib/asserts/string/minLength.js.map +1 -1
- package/lib/asserts/string/minLength.mjs +5 -13
- package/lib/asserts/string/minLength.mjs.map +1 -1
- package/lib/asserts/string/regExp.d.mts +5 -2
- package/lib/asserts/string/regExp.d.ts +5 -2
- package/lib/asserts/string/regExp.js +5 -13
- package/lib/asserts/string/regExp.js.map +1 -1
- package/lib/asserts/string/regExp.mjs +5 -13
- package/lib/asserts/string/regExp.mjs.map +1 -1
- package/lib/asserts/string/startsWith.d.mts +5 -2
- package/lib/asserts/string/startsWith.d.ts +5 -2
- package/lib/asserts/string/startsWith.js +4 -15
- package/lib/asserts/string/startsWith.js.map +1 -1
- package/lib/asserts/string/startsWith.mjs +4 -15
- package/lib/asserts/string/startsWith.mjs.map +1 -1
- package/lib/asserts/string/upperCase.d.mts +5 -2
- package/lib/asserts/string/upperCase.d.ts +5 -2
- package/lib/asserts/string/upperCase.js +4 -15
- package/lib/asserts/string/upperCase.js.map +1 -1
- package/lib/asserts/string/upperCase.mjs +4 -15
- package/lib/asserts/string/upperCase.mjs.map +1 -1
- package/lib/asserts/string/uuid.d.mts +5 -2
- package/lib/asserts/string/uuid.d.ts +5 -2
- package/lib/asserts/string/uuid.js +5 -16
- package/lib/asserts/string/uuid.js.map +1 -1
- package/lib/asserts/string/uuid.mjs +5 -16
- package/lib/asserts/string/uuid.mjs.map +1 -1
- package/lib/asserts/string/uuidV1.d.mts +5 -2
- package/lib/asserts/string/uuidV1.d.ts +5 -2
- package/lib/asserts/string/uuidV1.js +4 -16
- package/lib/asserts/string/uuidV1.js.map +1 -1
- package/lib/asserts/string/uuidV1.mjs +4 -16
- package/lib/asserts/string/uuidV1.mjs.map +1 -1
- package/lib/asserts/string/uuidV2.d.mts +5 -2
- package/lib/asserts/string/uuidV2.d.ts +5 -2
- package/lib/asserts/string/uuidV2.js +4 -16
- package/lib/asserts/string/uuidV2.js.map +1 -1
- package/lib/asserts/string/uuidV2.mjs +4 -16
- package/lib/asserts/string/uuidV2.mjs.map +1 -1
- package/lib/asserts/string/uuidV3.d.mts +5 -2
- package/lib/asserts/string/uuidV3.d.ts +5 -2
- package/lib/asserts/string/uuidV3.js +4 -16
- package/lib/asserts/string/uuidV3.js.map +1 -1
- package/lib/asserts/string/uuidV3.mjs +4 -16
- package/lib/asserts/string/uuidV3.mjs.map +1 -1
- package/lib/asserts/string/uuidV4.d.mts +5 -2
- package/lib/asserts/string/uuidV4.d.ts +5 -2
- package/lib/asserts/string/uuidV4.js +4 -16
- package/lib/asserts/string/uuidV4.js.map +1 -1
- package/lib/asserts/string/uuidV4.mjs +4 -16
- package/lib/asserts/string/uuidV4.mjs.map +1 -1
- package/lib/asserts/string/uuidV5.d.mts +5 -2
- package/lib/asserts/string/uuidV5.d.ts +5 -2
- package/lib/asserts/string/uuidV5.js +4 -16
- package/lib/asserts/string/uuidV5.js.map +1 -1
- package/lib/asserts/string/uuidV5.mjs +4 -16
- package/lib/asserts/string/uuidV5.mjs.map +1 -1
- package/lib/asserts/string/validUrl.d.mts +5 -2
- package/lib/asserts/string/validUrl.d.ts +5 -2
- package/lib/asserts/string/validUrl.js +5 -20
- package/lib/asserts/string/validUrl.js.map +1 -1
- package/lib/asserts/string/validUrl.mjs +5 -20
- package/lib/asserts/string/validUrl.mjs.map +1 -1
- 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/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/chunk-2AYQ7GRP.js +33 -0
- package/lib/chunk-2AYQ7GRP.js.map +1 -0
- package/lib/chunk-2KLV3CHA.js +20 -0
- package/lib/chunk-2KLV3CHA.js.map +1 -0
- package/lib/chunk-2X6V3ODY.js +20 -0
- package/lib/chunk-2X6V3ODY.js.map +1 -0
- package/lib/chunk-346TIMNH.mjs +18 -0
- package/lib/chunk-346TIMNH.mjs.map +1 -0
- package/lib/{chunk-32MKEBKR.js → chunk-3D6TPN7F.js} +3 -3
- package/lib/chunk-3D6TPN7F.js.map +1 -0
- package/lib/chunk-3OAUE5VW.js +28 -0
- 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-3T5QKF7X.mjs +18 -0
- package/lib/chunk-3T5QKF7X.mjs.map +1 -0
- package/lib/chunk-45K4AUO3.js +22 -0
- package/lib/chunk-45K4AUO3.js.map +1 -0
- package/lib/chunk-4AZOGLHD.mjs +21 -0
- package/lib/chunk-4AZOGLHD.mjs.map +1 -0
- package/lib/chunk-54F462SS.mjs +21 -0
- package/lib/chunk-54F462SS.mjs.map +1 -0
- package/lib/chunk-55P4YTMX.mjs +20 -0
- package/lib/chunk-55P4YTMX.mjs.map +1 -0
- package/lib/chunk-5PIGAEGL.mjs +22 -0
- package/lib/chunk-5PIGAEGL.mjs.map +1 -0
- package/lib/chunk-5U5CYDRB.mjs +21 -0
- package/lib/chunk-5U5CYDRB.mjs.map +1 -0
- package/lib/chunk-5VZDHJKM.mjs +68 -0
- package/lib/chunk-5VZDHJKM.mjs.map +1 -0
- package/lib/chunk-5WLWZKC6.mjs +21 -0
- package/lib/chunk-5WLWZKC6.mjs.map +1 -0
- package/lib/chunk-5WV7FMW7.mjs +33 -0
- package/lib/chunk-5WV7FMW7.mjs.map +1 -0
- package/lib/{chunk-QWPHP26D.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-7A4RN5UD.js +21 -0
- package/lib/chunk-7A4RN5UD.js.map +1 -0
- package/lib/chunk-7CNZKYPM.js +21 -0
- package/lib/chunk-7CNZKYPM.js.map +1 -0
- package/lib/chunk-7F4P72SG.mjs +18 -0
- package/lib/chunk-7F4P72SG.mjs.map +1 -0
- package/lib/chunk-A36G62K5.mjs +49 -0
- package/lib/chunk-A36G62K5.mjs.map +1 -0
- package/lib/chunk-A5OEVSSV.js +21 -0
- package/lib/chunk-A5OEVSSV.js.map +1 -0
- package/lib/chunk-ABSZMCDX.mjs +21 -0
- package/lib/chunk-ABSZMCDX.mjs.map +1 -0
- package/lib/chunk-ALXDH7GS.js +23 -0
- package/lib/chunk-ALXDH7GS.js.map +1 -0
- package/lib/chunk-AO6DKPJZ.js +49 -0
- package/lib/chunk-AO6DKPJZ.js.map +1 -0
- package/lib/chunk-AYJCGPXI.mjs +20 -0
- package/lib/chunk-AYJCGPXI.mjs.map +1 -0
- package/lib/chunk-AYSJLD4S.mjs +28 -0
- package/lib/chunk-AYSJLD4S.mjs.map +1 -0
- package/lib/{chunk-XG6K6N3A.mjs → chunk-B2R5S6OH.mjs} +9 -6
- package/lib/chunk-B2R5S6OH.mjs.map +1 -0
- package/lib/chunk-B3IWQRZF.mjs +22 -0
- package/lib/chunk-B3IWQRZF.mjs.map +1 -0
- package/lib/chunk-B4WB3UB7.js +20 -0
- package/lib/chunk-B4WB3UB7.js.map +1 -0
- package/lib/chunk-BZ6R6RWE.mjs +19 -0
- package/lib/chunk-BZ6R6RWE.mjs.map +1 -0
- package/lib/chunk-C6ICGQEX.mjs +21 -0
- package/lib/chunk-C6ICGQEX.mjs.map +1 -0
- package/lib/{chunk-ASZW6XRM.mjs → chunk-C76DLZFD.mjs} +4 -2
- package/lib/{chunk-ASZW6XRM.mjs.map → chunk-C76DLZFD.mjs.map} +1 -1
- package/lib/chunk-CJCIOMS7.mjs +66 -0
- 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-CWYS6MUA.js +18 -0
- package/lib/chunk-CWYS6MUA.js.map +1 -0
- package/lib/{chunk-P54CF5QN.mjs → chunk-D42AL6CN.mjs} +2 -2
- package/lib/chunk-D42AL6CN.mjs.map +1 -0
- package/lib/chunk-D4YY45O2.mjs +21 -0
- package/lib/chunk-D4YY45O2.mjs.map +1 -0
- package/lib/chunk-DKGRAVID.js +70 -0
- package/lib/chunk-DKGRAVID.js.map +1 -0
- package/lib/chunk-DLEDKNPD.mjs +21 -0
- package/lib/chunk-DLEDKNPD.mjs.map +1 -0
- package/lib/chunk-DPXTSNEX.js +23 -0
- package/lib/chunk-DPXTSNEX.js.map +1 -0
- package/lib/chunk-ECLNZ233.js +26 -0
- 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-EJCCIGXH.js +31 -0
- package/lib/chunk-EJCCIGXH.js.map +1 -0
- package/lib/chunk-EN745GWN.js +33 -0
- package/lib/chunk-EN745GWN.js.map +1 -0
- package/lib/chunk-ETBJ4NF4.mjs +21 -0
- 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-FJEBPEGR.js +21 -0
- package/lib/chunk-FJEBPEGR.js.map +1 -0
- package/lib/chunk-FTHEF6SB.js +14 -0
- package/lib/chunk-FTHEF6SB.js.map +1 -0
- package/lib/chunk-G2VC3SQB.js +22 -0
- package/lib/chunk-G2VC3SQB.js.map +1 -0
- package/lib/chunk-G6YZVGWC.mjs +21 -0
- package/lib/chunk-G6YZVGWC.mjs.map +1 -0
- package/lib/chunk-GSLVYDXO.js +18 -0
- package/lib/chunk-GSLVYDXO.js.map +1 -0
- package/lib/chunk-GTGXSQKC.js +21 -0
- package/lib/chunk-GTGXSQKC.js.map +1 -0
- package/lib/chunk-GYLCPX6O.js +68 -0
- package/lib/chunk-GYLCPX6O.js.map +1 -0
- package/lib/chunk-H3FXZTYS.mjs +18 -0
- package/lib/chunk-H3FXZTYS.mjs.map +1 -0
- package/lib/chunk-HKDDJSN2.mjs +21 -0
- package/lib/chunk-HKDDJSN2.mjs.map +1 -0
- package/lib/{chunk-YSCVE4PJ.mjs → chunk-IIL6D2UL.mjs} +2 -2
- package/lib/chunk-IIL6D2UL.mjs.map +1 -0
- package/lib/chunk-IWNVHB2K.mjs +22 -0
- package/lib/chunk-IWNVHB2K.mjs.map +1 -0
- package/lib/chunk-JF7KZZ7R.js +21 -0
- 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-JLEQOYDW.js +59 -0
- package/lib/chunk-JLEQOYDW.js.map +1 -0
- package/lib/chunk-JND3VAPR.mjs +19 -0
- package/lib/chunk-JND3VAPR.mjs.map +1 -0
- package/lib/chunk-K4YXIN2V.mjs +33 -0
- package/lib/chunk-K4YXIN2V.mjs.map +1 -0
- package/lib/chunk-K6QYFFMX.mjs +21 -0
- package/lib/chunk-K6QYFFMX.mjs.map +1 -0
- package/lib/{chunk-CCNK27CX.mjs → chunk-KAFZGQ2W.mjs} +17 -11
- package/lib/chunk-KAFZGQ2W.mjs.map +1 -0
- package/lib/chunk-KDPYWGMJ.js +24 -0
- 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-KIVIWBIY.js +21 -0
- package/lib/chunk-KIVIWBIY.js.map +1 -0
- package/lib/chunk-KZBW5WCK.js +21 -0
- package/lib/chunk-KZBW5WCK.js.map +1 -0
- package/lib/chunk-L36PQXUB.js +21 -0
- 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-42J6CHIO.js → chunk-LHEU4XAC.js} +4 -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-M7EMQU7U.mjs +28 -0
- package/lib/chunk-M7EMQU7U.mjs.map +1 -0
- package/lib/chunk-MOHROZTD.mjs +20 -0
- package/lib/chunk-MOHROZTD.mjs.map +1 -0
- package/lib/chunk-MQGE7GIK.mjs +26 -0
- package/lib/chunk-MQGE7GIK.mjs.map +1 -0
- package/lib/chunk-NC7E2FQR.mjs +21 -0
- package/lib/chunk-NC7E2FQR.mjs.map +1 -0
- package/lib/chunk-NM3VRT77.mjs +120 -0
- package/lib/chunk-NM3VRT77.mjs.map +1 -0
- package/lib/chunk-NM4TCTZM.mjs +70 -0
- 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-NZOANK7A.js +18 -0
- package/lib/chunk-NZOANK7A.js.map +1 -0
- 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-O646PJXY.mjs +23 -0
- package/lib/chunk-O646PJXY.mjs.map +1 -0
- package/lib/chunk-OHJ2EB4T.js +20 -0
- package/lib/chunk-OHJ2EB4T.js.map +1 -0
- package/lib/{chunk-UTPG4GZB.js → chunk-OPA6AXSH.js} +3 -3
- package/lib/chunk-OPA6AXSH.js.map +1 -0
- package/lib/chunk-OQB5UGWG.mjs +24 -0
- package/lib/chunk-OQB5UGWG.mjs.map +1 -0
- package/lib/chunk-ORQBVFHY.js +18 -0
- package/lib/chunk-ORQBVFHY.js.map +1 -0
- package/lib/chunk-OW7RK5YW.js +21 -0
- package/lib/chunk-OW7RK5YW.js.map +1 -0
- package/lib/chunk-OY5DJBRV.mjs +21 -0
- package/lib/chunk-OY5DJBRV.mjs.map +1 -0
- 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-P6M6QZU5.mjs +24 -0
- package/lib/chunk-P6M6QZU5.mjs.map +1 -0
- package/lib/chunk-PFADKWMO.js +19 -0
- package/lib/chunk-PFADKWMO.js.map +1 -0
- package/lib/chunk-POPLWPM4.mjs +19 -0
- package/lib/chunk-POPLWPM4.mjs.map +1 -0
- package/lib/chunk-POQZCV3D.js +20 -0
- package/lib/chunk-POQZCV3D.js.map +1 -0
- package/lib/chunk-QM4MJTTD.mjs +24 -0
- package/lib/chunk-QM4MJTTD.mjs.map +1 -0
- package/lib/chunk-QNA4O6AU.js +21 -0
- package/lib/chunk-QNA4O6AU.js.map +1 -0
- package/lib/chunk-RCD6EO4Q.mjs +21 -0
- package/lib/chunk-RCD6EO4Q.mjs.map +1 -0
- package/lib/chunk-RDJK3X4J.mjs +21 -0
- package/lib/chunk-RDJK3X4J.mjs.map +1 -0
- package/lib/chunk-RXU74KSN.mjs +20 -0
- package/lib/chunk-RXU74KSN.mjs.map +1 -0
- package/lib/chunk-S6N4N4FT.js +21 -0
- package/lib/chunk-S6N4N4FT.js.map +1 -0
- package/lib/chunk-SGWF66HS.js +21 -0
- package/lib/chunk-SGWF66HS.js.map +1 -0
- package/lib/chunk-SKMDZ4S6.mjs +23 -0
- package/lib/chunk-SKMDZ4S6.mjs.map +1 -0
- package/lib/chunk-SVRCKC65.js +120 -0
- package/lib/chunk-SVRCKC65.js.map +1 -0
- package/lib/chunk-SY2V2V54.js +28 -0
- package/lib/chunk-SY2V2V54.js.map +1 -0
- package/lib/chunk-SZO4SUUG.js +21 -0
- 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-TJ7IQSHU.js +21 -0
- 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-TPSWNY5K.mjs +20 -0
- package/lib/chunk-TPSWNY5K.mjs.map +1 -0
- package/lib/chunk-UCHEFFWR.js +79 -0
- package/lib/chunk-UCHEFFWR.js.map +1 -0
- package/lib/chunk-UIJIIIOA.js +21 -0
- 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-UN5S46LE.mjs +28 -0
- package/lib/chunk-UN5S46LE.mjs.map +1 -0
- package/lib/chunk-UWONIZJZ.mjs +78 -0
- 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-VGOAXY26.js +24 -0
- 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-VWHKNZLG.js +18 -0
- package/lib/chunk-VWHKNZLG.js.map +1 -0
- package/lib/chunk-WL7BV4XV.mjs +33 -0
- 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-YETYTLAD.mjs +18 -0
- package/lib/chunk-YETYTLAD.mjs.map +1 -0
- package/lib/chunk-YJUYGFG2.mjs +26 -0
- package/lib/chunk-YJUYGFG2.mjs.map +1 -0
- package/lib/chunk-YJZXJKM4.mjs +79 -0
- 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-EMOOEIPZ.mjs → chunk-YQP44G45.mjs} +2 -2
- package/lib/chunk-YQP44G45.mjs.map +1 -0
- package/lib/chunk-Z7LBOQRQ.js +28 -0
- package/lib/chunk-Z7LBOQRQ.js.map +1 -0
- package/lib/chunk-ZIBHO6FI.js +20 -0
- package/lib/chunk-ZIBHO6FI.js.map +1 -0
- package/lib/{chunk-EXVTHIT5.js → chunk-ZJGY6EOE.js} +19 -10
- package/lib/chunk-ZJGY6EOE.js.map +1 -0
- package/lib/chunk-ZQKVVWD5.mjs +20 -0
- package/lib/chunk-ZQKVVWD5.mjs.map +1 -0
- package/lib/{chunk-FIDPCCCW.js → chunk-ZWFSAKQK.js} +8 -2
- package/lib/chunk-ZWFSAKQK.js.map +1 -0
- package/lib/codeGen.d.mts +3 -2
- package/lib/codeGen.d.ts +3 -2
- package/lib/codeGen.js +3 -45
- package/lib/codeGen.js.map +1 -1
- package/lib/codeGen.mjs +4 -46
- package/lib/codeGen.mjs.map +1 -1
- package/lib/commonTypes.d.mts +45 -1
- package/lib/commonTypes.d.ts +45 -1
- package/lib/core.d.mts +330 -0
- package/lib/core.d.ts +330 -0
- package/lib/core.js +21 -0
- package/lib/core.js.map +1 -0
- package/lib/core.mjs +21 -0
- 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.d.mts +2 -1
- package/lib/helpers/constants.d.ts +2 -1
- package/lib/helpers/constants.js +4 -2
- package/lib/helpers/constants.js.map +1 -1
- package/lib/helpers/constants.mjs +5 -3
- package/lib/helpers/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 +3 -2
- package/lib/helpers/setStrictType.d.ts +3 -2
- package/lib/helpers/setStrictType.js +3 -4
- package/lib/helpers/setStrictType.js.map +1 -1
- package/lib/helpers/setStrictType.mjs +2 -3
- package/lib/index.d.mts +66 -5
- package/lib/index.d.ts +66 -5
- package/lib/index.js +266 -5
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +267 -6
- 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 +10 -1
- package/lib/translationMap.d.ts +10 -1
- package/lib/translationMap.js +3 -3
- package/lib/translationMap.mjs +2 -2
- package/package.json +194 -52
- package/lib/CommonSchema-BIfYCtcQ.d.mts +0 -110
- package/lib/CommonSchema-DIDMH9R7.d.ts +0 -110
- package/lib/ExceptionContext.d.mts +0 -16
- package/lib/ExceptionContext.d.ts +0 -16
- package/lib/ExceptionContext.js +0 -11
- package/lib/ExceptionContext.js.map +0 -1
- package/lib/ExceptionContext.mjs +0 -11
- package/lib/chunk-32MKEBKR.js.map +0 -1
- package/lib/chunk-3ZQ4ORQH.js +0 -14
- package/lib/chunk-3ZQ4ORQH.js.map +0 -1
- package/lib/chunk-42J6CHIO.js.map +0 -1
- package/lib/chunk-BURPSYZ3.js +0 -53
- package/lib/chunk-BURPSYZ3.js.map +0 -1
- package/lib/chunk-CCNK27CX.mjs.map +0 -1
- package/lib/chunk-EMOOEIPZ.mjs.map +0 -1
- package/lib/chunk-EXVTHIT5.js.map +0 -1
- package/lib/chunk-FIDPCCCW.js.map +0 -1
- package/lib/chunk-FNBYM254.js +0 -41
- package/lib/chunk-FNBYM254.js.map +0 -1
- package/lib/chunk-IFQLPXCZ.mjs +0 -111
- package/lib/chunk-IFQLPXCZ.mjs.map +0 -1
- package/lib/chunk-MMWS3SXR.js +0 -136
- package/lib/chunk-MMWS3SXR.js.map +0 -1
- package/lib/chunk-MQRXWXHP.mjs +0 -83
- package/lib/chunk-MQRXWXHP.mjs.map +0 -1
- package/lib/chunk-MRRMV2GM.mjs +0 -63
- package/lib/chunk-MRRMV2GM.mjs.map +0 -1
- package/lib/chunk-P4Q22AZA.js +0 -28
- package/lib/chunk-P4Q22AZA.js.map +0 -1
- package/lib/chunk-P54CF5QN.mjs.map +0 -1
- package/lib/chunk-PE55R4KH.js +0 -83
- package/lib/chunk-PE55R4KH.js.map +0 -1
- package/lib/chunk-PGEXAFA5.js +0 -20
- package/lib/chunk-PGEXAFA5.js.map +0 -1
- package/lib/chunk-PQ4GCO3Q.js +0 -111
- package/lib/chunk-PQ4GCO3Q.js.map +0 -1
- package/lib/chunk-QWPHP26D.mjs.map +0 -1
- package/lib/chunk-RAJF6LMF.js +0 -63
- package/lib/chunk-RAJF6LMF.js.map +0 -1
- package/lib/chunk-RG5NYH2I.js +0 -65
- package/lib/chunk-RG5NYH2I.js.map +0 -1
- package/lib/chunk-U3DJ354I.mjs +0 -65
- package/lib/chunk-U3DJ354I.mjs.map +0 -1
- package/lib/chunk-UEYMBPZN.mjs +0 -136
- package/lib/chunk-UEYMBPZN.mjs.map +0 -1
- package/lib/chunk-UTPG4GZB.js.map +0 -1
- package/lib/chunk-VIFJBTQO.mjs +0 -20
- package/lib/chunk-VIFJBTQO.mjs.map +0 -1
- package/lib/chunk-W2SQHSOS.mjs +0 -58
- package/lib/chunk-W2SQHSOS.mjs.map +0 -1
- package/lib/chunk-XG6K6N3A.mjs.map +0 -1
- package/lib/chunk-XT5E3MPI.mjs +0 -41
- package/lib/chunk-XT5E3MPI.mjs.map +0 -1
- package/lib/chunk-YSCVE4PJ.mjs.map +0 -1
- package/lib/chunk-ZG373PNB.js +0 -58
- package/lib/chunk-ZG373PNB.js.map +0 -1
- package/lib/chunk-ZTCXXAKD.mjs.map +0 -1
- package/lib/helpers/core.d.mts +0 -4
- package/lib/helpers/core.d.ts +0 -4
- package/lib/helpers/core.js +0 -10
- package/lib/helpers/core.js.map +0 -1
- package/lib/helpers/core.mjs +0 -10
- package/lib/parse.d.mts +0 -62
- package/lib/parse.d.ts +0 -62
- package/lib/parse.js +0 -11
- package/lib/parse.js.map +0 -1
- package/lib/parse.mjs +0 -11
- package/lib/parseOrFail.d.mts +0 -44
- package/lib/parseOrFail.d.ts +0 -44
- package/lib/parseOrFail.js +0 -11
- package/lib/parseOrFail.js.map +0 -1
- package/lib/parseOrFail.mjs +0 -11
- package/lib/schemas/ArraySchema.d.mts +0 -12
- package/lib/schemas/ArraySchema.d.ts +0 -12
- package/lib/schemas/ArraySchema.js +0 -13
- package/lib/schemas/ArraySchema.js.map +0 -1
- package/lib/schemas/ArraySchema.mjs +0 -13
- package/lib/schemas/BigIntSchema.d.mts +0 -31
- package/lib/schemas/BigIntSchema.d.ts +0 -31
- package/lib/schemas/BigIntSchema.js +0 -17
- package/lib/schemas/BigIntSchema.js.map +0 -1
- package/lib/schemas/BigIntSchema.mjs +0 -17
- package/lib/schemas/BooleanSchema.d.mts +0 -26
- package/lib/schemas/BooleanSchema.d.ts +0 -26
- package/lib/schemas/BooleanSchema.js +0 -14
- package/lib/schemas/BooleanSchema.js.map +0 -1
- package/lib/schemas/BooleanSchema.mjs +0 -14
- package/lib/schemas/CommonSchema.d.mts +0 -4
- package/lib/schemas/CommonSchema.d.ts +0 -4
- package/lib/schemas/CommonSchema.js +0 -12
- package/lib/schemas/CommonSchema.js.map +0 -1
- package/lib/schemas/CommonSchema.mjs +0 -12
- package/lib/schemas/DateSchema.d.mts +0 -11
- package/lib/schemas/DateSchema.d.ts +0 -11
- package/lib/schemas/DateSchema.js +0 -13
- package/lib/schemas/DateSchema.js.map +0 -1
- package/lib/schemas/DateSchema.mjs +0 -13
- package/lib/schemas/NumberSchema.d.mts +0 -30
- package/lib/schemas/NumberSchema.d.ts +0 -30
- package/lib/schemas/NumberSchema.js +0 -17
- package/lib/schemas/NumberSchema.js.map +0 -1
- package/lib/schemas/NumberSchema.mjs +0 -17
- package/lib/schemas/ObjectSchema.d.mts +0 -30
- package/lib/schemas/ObjectSchema.d.ts +0 -30
- package/lib/schemas/ObjectSchema.js +0 -13
- package/lib/schemas/ObjectSchema.js.map +0 -1
- package/lib/schemas/ObjectSchema.mjs +0 -13
- package/lib/schemas/StringSchema.d.mts +0 -31
- package/lib/schemas/StringSchema.d.ts +0 -31
- package/lib/schemas/StringSchema.js +0 -17
- package/lib/schemas/StringSchema.js.map +0 -1
- package/lib/schemas/StringSchema.mjs +0 -17
- /package/lib/{ExceptionContext.mjs.map → asserts/coerce/index.mjs.map} +0 -0
- /package/lib/{helpers/core.mjs.map → asserts/intersection/index.mjs.map} +0 -0
- /package/lib/{parse.mjs.map → asserts/lazy/index.mjs.map} +0 -0
- /package/lib/{parseOrFail.mjs.map → asserts/object/extend.mjs.map} +0 -0
- /package/lib/{schemas/ArraySchema.mjs.map → asserts/object/omit.mjs.map} +0 -0
- /package/lib/{schemas/BigIntSchema.mjs.map → asserts/object/partial.mjs.map} +0 -0
- /package/lib/{schemas/BooleanSchema.mjs.map → asserts/object/pick.mjs.map} +0 -0
- /package/lib/{schemas/CommonSchema.mjs.map → asserts/object/required.mjs.map} +0 -0
- /package/lib/{schemas/DateSchema.mjs.map → asserts/record/index.mjs.map} +0 -0
- /package/lib/{schemas/NumberSchema.mjs.map → asserts/tuple/index.mjs.map} +0 -0
- /package/lib/{schemas/ObjectSchema.mjs.map → asserts/union/index.mjs.map} +0 -0
- /package/lib/{schemas/StringSchema.mjs.map → core.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)
|
|
@@ -32,6 +46,8 @@ Table of contents
|
|
|
32
46
|
* [Built-in Custom Assert Documentation](#builtin_custom_assert_documentation)
|
|
33
47
|
|
|
34
48
|
* [string](#assertdir_string)
|
|
49
|
+
* [equalTo](#assert_string_method_equalto)
|
|
50
|
+
* [oneOfValues](#assert_string_method_oneofvalues)
|
|
35
51
|
* [atLeastOneDigit](#assert_atleastonedigit_string)
|
|
36
52
|
* [atLeastOneLowerChar](#assert_atleastonelowerchar_string)
|
|
37
53
|
* [atLeastOneSpecialChar](#assert_atleastonespecialchar_string)
|
|
@@ -56,6 +72,8 @@ Table of contents
|
|
|
56
72
|
* [uuidV5](#assert_uuidv5_string)
|
|
57
73
|
* [validUrl](#assert_validurl_string)
|
|
58
74
|
* [number](#assertdir_number)
|
|
75
|
+
* [equalTo](#assert_number_method_equalto)
|
|
76
|
+
* [oneOfValues](#assert_number_method_oneofvalues)
|
|
59
77
|
* [max](#assert_max_number)
|
|
60
78
|
* [maxExcluded](#assert_maxexcluded_number)
|
|
61
79
|
* [min](#assert_min_number)
|
|
@@ -66,6 +84,8 @@ Table of contents
|
|
|
66
84
|
* [maxArrayLength](#assert_maxarraylength_array)
|
|
67
85
|
* [minArrayLength](#assert_minarraylength_array)
|
|
68
86
|
* [bigint](#assertdir_bigint)
|
|
87
|
+
* [equalTo](#assert_bigint_method_equalto)
|
|
88
|
+
* [oneOfValues](#assert_bigint_method_oneofvalues)
|
|
69
89
|
* [bigintMax](#assert_bigintmax_bigint)
|
|
70
90
|
* [bigintMaxExcluded](#assert_bigintmaxexcluded_bigint)
|
|
71
91
|
* [bigintMin](#assert_bigintmin_bigint)
|
|
@@ -77,7 +97,13 @@ Table of contents
|
|
|
77
97
|
* [equalTo](#assert_equalto_mix)
|
|
78
98
|
* [oneOfValues](#assert_oneofvalues_mix)
|
|
79
99
|
* [object](#assertdir_object)
|
|
100
|
+
* [allowUnrecognized](#assert_object_method_allowunrecognized)
|
|
101
|
+
* [extend](#assert_extend_object)
|
|
80
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)
|
|
81
107
|
|
|
82
108
|
### <a id="h3_features"> Features </a>
|
|
83
109
|
|
|
@@ -297,7 +323,7 @@ The `parseOrFail` method validates the data and throws an error on the first val
|
|
|
297
323
|
**Syntax:**
|
|
298
324
|
|
|
299
325
|
```typeScript
|
|
300
|
-
import { parseOrFail } from 'bguard';
|
|
326
|
+
import { parseOrFail, ValidationError } from 'bguard';
|
|
301
327
|
// import other dependencies
|
|
302
328
|
|
|
303
329
|
try {
|
|
@@ -305,8 +331,12 @@ try {
|
|
|
305
331
|
const validatedData = parseOrFail(studentSchema, validStudentData);
|
|
306
332
|
// If the data is valid, validatedData will contain the parsed value with inferred TypeScript types
|
|
307
333
|
} catch (error) {
|
|
308
|
-
// If the data does not conform to the schema,
|
|
309
|
-
|
|
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
|
+
}
|
|
310
340
|
}
|
|
311
341
|
```
|
|
312
342
|
|
|
@@ -320,7 +350,27 @@ Options:
|
|
|
320
350
|
|
|
321
351
|
Explanation
|
|
322
352
|
|
|
323
|
-
- **`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.
|
|
324
374
|
|
|
325
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.
|
|
326
376
|
|
|
@@ -328,6 +378,28 @@ Explanation
|
|
|
328
378
|
|
|
329
379
|
### <a id="h3_chaining_methods"> Chaining Methods </a>
|
|
330
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
|
+
|
|
331
403
|
#### <a id="h4_chaining_nullable"> nullable() </a>
|
|
332
404
|
|
|
333
405
|
Allows the value to be `null`.
|
|
@@ -358,6 +430,20 @@ Sets a default value if the received value is `undefined`. The default value mus
|
|
|
358
430
|
|
|
359
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`.
|
|
360
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
|
+
|
|
361
447
|
_Example_:
|
|
362
448
|
|
|
363
449
|
```typeScript
|
|
@@ -422,6 +508,351 @@ parseOrFail(stringOrNullSchema, 'test');
|
|
|
422
508
|
parseOrFail(stringOrNullSchema, '');
|
|
423
509
|
```
|
|
424
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
|
+
|
|
425
856
|
### <a id="h3_literals"> Literals </a>
|
|
426
857
|
|
|
427
858
|
- <b>String Literals</b>:
|
|
@@ -444,6 +875,7 @@ All built-in asserts are documented in the [Built-in Custom Assert Documentation
|
|
|
444
875
|
Example
|
|
445
876
|
|
|
446
877
|
```typeScript
|
|
878
|
+
import { number } from 'bguard/number';
|
|
447
879
|
import { min } from 'bguard/number/min';
|
|
448
880
|
import { max } from 'bguard/number/max';
|
|
449
881
|
|
|
@@ -459,7 +891,7 @@ Bguard allows developers to create custom validation functions that can be integ
|
|
|
459
891
|
Example: Creating a `minLength` Custom Validation
|
|
460
892
|
|
|
461
893
|
```typescript
|
|
462
|
-
import { ExceptionContext, RequiredValidation } from 'bguard/
|
|
894
|
+
import { ExceptionContext, RequiredValidation } from 'bguard/core';
|
|
463
895
|
import { setToDefaultLocale } from 'bguard/translationMap';
|
|
464
896
|
|
|
465
897
|
const minLengthErrorMessage = 'The received value {{r}} is shorter than the expected length {{e}}';
|
|
@@ -575,6 +1007,9 @@ We have two sets of translations: common errors and specific assertions.
|
|
|
575
1007
|
'c:invalidType': 'Invalid type of data',
|
|
576
1008
|
'c:isBoolean': 'The received value is not {{e}}',
|
|
577
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',
|
|
578
1013
|
```
|
|
579
1014
|
|
|
580
1015
|
<b>Custom Assertion Translations</b>:
|
|
@@ -638,6 +1073,25 @@ import { string } from 'bguard/string';
|
|
|
638
1073
|
parseOrFail(schema, 'hello'); // Validates successfully
|
|
639
1074
|
parseOrFail(schema, 123); // Throws a validation error
|
|
640
1075
|
```
|
|
1076
|
+
|
|
1077
|
+
##### <a id="assert_string_method_equalto"> equalTo </a>
|
|
1078
|
+
* _Description_ Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
1079
|
+
* _Param_ expectedValue - The value that the schema must exactly match.
|
|
1080
|
+
* _Example_
|
|
1081
|
+
```typescript
|
|
1082
|
+
string().equalTo('hello'); // Infers the type 'hello'
|
|
1083
|
+
```
|
|
1084
|
+
|
|
1085
|
+
##### <a id="assert_string_method_oneofvalues"> oneOfValues </a>
|
|
1086
|
+
* _Description_ Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
|
|
1087
|
+
* _Param_ expectedValues - An array of values that the schema can match.
|
|
1088
|
+
* _Example_
|
|
1089
|
+
```typescript
|
|
1090
|
+
string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'
|
|
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.
|
|
641
1095
|
|
|
642
1096
|
|
|
643
1097
|
##### <a id="assert_atleastonedigit_string"> atLeastOneDigit </a>
|
|
@@ -1085,6 +1539,22 @@ import { number } from 'bguard/number';
|
|
|
1085
1539
|
parseOrFail(schema, 42); // Validates successfully
|
|
1086
1540
|
parseOrFail(schema, '42'); // Throws a validation error
|
|
1087
1541
|
```
|
|
1542
|
+
|
|
1543
|
+
##### <a id="assert_number_method_equalto"> equalTo </a>
|
|
1544
|
+
* _Description_ Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
1545
|
+
* _Param_ expectedValue - The value that the schema must exactly match.
|
|
1546
|
+
* _Example_
|
|
1547
|
+
```typescript
|
|
1548
|
+
number().equalTo(42); // Infers the type 42
|
|
1549
|
+
```
|
|
1550
|
+
|
|
1551
|
+
##### <a id="assert_number_method_oneofvalues"> oneOfValues </a>
|
|
1552
|
+
* _Description_ Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
|
|
1553
|
+
* _Param_ expectedValues - An array of values that the schema can match.
|
|
1554
|
+
* _Example_
|
|
1555
|
+
```typescript
|
|
1556
|
+
number().oneOfValues([5, 7]); // Infers the type 5 | 7
|
|
1557
|
+
```
|
|
1088
1558
|
|
|
1089
1559
|
|
|
1090
1560
|
##### <a id="assert_max_number"> max </a>
|
|
@@ -1262,7 +1732,7 @@ import { minArrayLength } from 'bguard/array/minArrayLength';
|
|
|
1262
1732
|
import { bigint } from 'bguard/bigint';
|
|
1263
1733
|
```
|
|
1264
1734
|
|
|
1265
|
-
* _Description_ Creates a new schema for validating bigint values.
|
|
1735
|
+
* _Description_ - Creates a new schema for validating bigint values.
|
|
1266
1736
|
* _Example_
|
|
1267
1737
|
```typescript
|
|
1268
1738
|
const schema = bigint();
|
|
@@ -1270,6 +1740,25 @@ import { bigint } from 'bguard/bigint';
|
|
|
1270
1740
|
parseOrFail(schema, 42); // Throws a validation error
|
|
1271
1741
|
parseOrFail(schema, '42'); // Throws a validation error
|
|
1272
1742
|
```
|
|
1743
|
+
|
|
1744
|
+
##### <a id="assert_bigint_method_equalto"> equalTo </a>
|
|
1745
|
+
* _Description_ Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
1746
|
+
* _Param_ expectedValue - The value that the schema must exactly match.
|
|
1747
|
+
* _Example_
|
|
1748
|
+
```typescript
|
|
1749
|
+
bigint().equalTo(42n); // Infers the type 42n
|
|
1750
|
+
```
|
|
1751
|
+
|
|
1752
|
+
##### <a id="assert_bigint_method_oneofvalues"> oneOfValues </a>
|
|
1753
|
+
* _Description_ Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
|
|
1754
|
+
* _Param_ expectedValues - An array of values that the schema can match.
|
|
1755
|
+
* _Example_
|
|
1756
|
+
```typescript
|
|
1757
|
+
bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n
|
|
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.
|
|
1273
1762
|
|
|
1274
1763
|
|
|
1275
1764
|
##### <a id="assert_bigintmax_bigint"> bigintMax </a>
|
|
@@ -1409,8 +1898,11 @@ import { dateMin } from 'bguard/date/dateMin';
|
|
|
1409
1898
|
import { oneOfTypes } from 'bguard/mix';
|
|
1410
1899
|
```
|
|
1411
1900
|
|
|
1412
|
-
|
|
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.
|
|
1413
1904
|
|
|
1905
|
+
* _Description_ Creates a new schema for validating values that can match any one of the specified primitive types.
|
|
1414
1906
|
|
|
1415
1907
|
* _Param_ {T} valueTypes - An array of primitive types that the value can match.
|
|
1416
1908
|
* _Example_
|
|
@@ -1468,6 +1960,22 @@ import { oneOfValues } from 'bguard/mix/oneOfValues';
|
|
|
1468
1960
|
import { object } from 'bguard/object';
|
|
1469
1961
|
```
|
|
1470
1962
|
|
|
1963
|
+
##### <a id="assert_object_method_allowunrecognized"> allowUnrecognized </a>
|
|
1964
|
+
* _Description_ Allows unrecognized properties in the validated object.
|
|
1965
|
+
When this method is called, the validation will not fail
|
|
1966
|
+
if the received object contains properties not specified
|
|
1967
|
+
in the validation schema.
|
|
1968
|
+
* _Example_
|
|
1969
|
+
```typescript
|
|
1970
|
+
const userSchema = object({
|
|
1971
|
+
name: string(),
|
|
1972
|
+
age: number(),
|
|
1973
|
+
}).allowUnrecognized();
|
|
1974
|
+
|
|
1975
|
+
parseOrFail(userSchema, ({ name: 'John', age: 30, extra: 'value' }););
|
|
1976
|
+
// No error thrown
|
|
1977
|
+
```
|
|
1978
|
+
|
|
1471
1979
|
* _Description_ Creates a new schema for validating objects where each property must match the specified schema.
|
|
1472
1980
|
|
|
1473
1981
|
* _Param_ {T} shapeSchema - The schema that each property of the object must match.
|
|
@@ -1482,6 +1990,30 @@ import { object } from 'bguard/object';
|
|
|
1482
1990
|
```
|
|
1483
1991
|
|
|
1484
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
|
+
|
|
1485
2017
|
##### <a id="assert_maxkeys_object"> maxKeys </a>
|
|
1486
2018
|
|
|
1487
2019
|
```typescript
|
|
@@ -1508,5 +2040,109 @@ import { maxKeys } from 'bguard/object/maxKeys';
|
|
|
1508
2040
|
```
|
|
1509
2041
|
* _See_ Error Translation Key = 'o:maxKeys'
|
|
1510
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
|
+
|
|
1511
2147
|
### Contributing
|
|
1512
2148
|
Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.
|