bguard 0.1.0 → 0.2.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 +567 -29
- package/lib/{CommonSchema-BbGNki0L.d.ts → CommonSchema-9RtxTxdX.d.ts} +3 -2
- package/lib/{CommonSchema-CjsYE4dC.d.mts → CommonSchema-DJmQ3F_9.d.mts} +3 -2
- package/lib/InferType.d.mts +5 -2
- package/lib/InferType.d.ts +5 -2
- package/lib/asserts/array/index.d.mts +4 -4
- package/lib/asserts/array/index.d.ts +4 -4
- package/lib/asserts/array/index.js +10 -5
- package/lib/asserts/array/index.js.map +1 -1
- package/lib/asserts/array/index.mjs +10 -5
- package/lib/asserts/array/index.mjs.map +1 -1
- package/lib/asserts/bigint/bigintMax.d.mts +22 -0
- package/lib/asserts/bigint/bigintMax.d.ts +22 -0
- package/lib/asserts/bigint/bigintMax.js +20 -0
- package/lib/asserts/bigint/bigintMax.js.map +1 -0
- package/lib/asserts/bigint/bigintMax.mjs +20 -0
- package/lib/asserts/bigint/bigintMax.mjs.map +1 -0
- package/lib/asserts/bigint/bigintMaxExcluded.d.mts +22 -0
- package/lib/asserts/bigint/bigintMaxExcluded.d.ts +22 -0
- package/lib/asserts/bigint/bigintMaxExcluded.js +20 -0
- package/lib/asserts/bigint/bigintMaxExcluded.js.map +1 -0
- package/lib/asserts/bigint/bigintMaxExcluded.mjs +20 -0
- package/lib/asserts/bigint/bigintMaxExcluded.mjs.map +1 -0
- package/lib/asserts/bigint/bigintMin.d.mts +22 -0
- package/lib/asserts/bigint/bigintMin.d.ts +22 -0
- package/lib/asserts/bigint/bigintMin.js +20 -0
- package/lib/asserts/bigint/bigintMin.js.map +1 -0
- package/lib/asserts/bigint/bigintMin.mjs +20 -0
- package/lib/asserts/bigint/bigintMin.mjs.map +1 -0
- package/lib/asserts/bigint/bigintMinExcluded.d.mts +22 -0
- package/lib/asserts/bigint/bigintMinExcluded.d.ts +22 -0
- package/lib/asserts/bigint/bigintMinExcluded.js +20 -0
- package/lib/asserts/bigint/bigintMinExcluded.js.map +1 -0
- package/lib/asserts/bigint/bigintMinExcluded.mjs +20 -0
- package/lib/asserts/bigint/bigintMinExcluded.mjs.map +1 -0
- package/lib/asserts/bigint/index.d.mts +18 -0
- package/lib/asserts/bigint/index.d.ts +18 -0
- package/lib/asserts/bigint/index.js +21 -0
- package/lib/asserts/bigint/index.js.map +1 -0
- package/lib/asserts/bigint/index.mjs +21 -0
- package/lib/asserts/bigint/index.mjs.map +1 -0
- package/lib/asserts/boolean/index.d.mts +4 -4
- package/lib/asserts/boolean/index.d.ts +4 -4
- package/lib/asserts/boolean/index.js +11 -6
- package/lib/asserts/boolean/index.js.map +1 -1
- package/lib/asserts/boolean/index.mjs +11 -6
- package/lib/asserts/boolean/index.mjs.map +1 -1
- package/lib/asserts/date/dateMax.d.mts +22 -0
- package/lib/asserts/date/dateMax.d.ts +22 -0
- package/lib/asserts/date/dateMax.js +28 -0
- package/lib/asserts/date/dateMax.js.map +1 -0
- package/lib/asserts/date/dateMax.mjs +28 -0
- package/lib/asserts/date/dateMax.mjs.map +1 -0
- package/lib/asserts/date/dateMin.d.mts +22 -0
- package/lib/asserts/date/dateMin.d.ts +22 -0
- package/lib/asserts/date/dateMin.js +28 -0
- package/lib/asserts/date/dateMin.js.map +1 -0
- package/lib/asserts/date/dateMin.mjs +28 -0
- package/lib/asserts/date/dateMin.mjs.map +1 -0
- package/lib/asserts/date/index.d.mts +17 -0
- package/lib/asserts/date/index.d.ts +17 -0
- package/lib/asserts/date/index.js +16 -0
- package/lib/asserts/date/index.js.map +1 -0
- package/lib/asserts/date/index.mjs +16 -0
- package/lib/asserts/date/index.mjs.map +1 -0
- package/lib/asserts/mix/equalTo.d.mts +1 -1
- package/lib/asserts/mix/equalTo.d.ts +1 -1
- package/lib/asserts/mix/equalTo.js +3 -3
- package/lib/asserts/mix/equalTo.mjs +2 -2
- package/lib/asserts/mix/index.d.mts +4 -3
- package/lib/asserts/mix/index.d.ts +4 -3
- package/lib/asserts/mix/index.js +9 -4
- package/lib/asserts/mix/index.js.map +1 -1
- package/lib/asserts/mix/index.mjs +9 -4
- package/lib/asserts/mix/index.mjs.map +1 -1
- package/lib/asserts/mix/oneOfValues.d.mts +1 -1
- package/lib/asserts/mix/oneOfValues.d.ts +1 -1
- package/lib/asserts/mix/oneOfValues.js +3 -3
- package/lib/asserts/mix/oneOfValues.mjs +2 -2
- package/lib/asserts/number/index.d.mts +4 -4
- package/lib/asserts/number/index.d.ts +4 -4
- package/lib/asserts/number/index.js +15 -9
- package/lib/asserts/number/index.js.map +1 -1
- package/lib/asserts/number/index.mjs +15 -9
- package/lib/asserts/number/index.mjs.map +1 -1
- package/lib/asserts/number/max.js +2 -2
- package/lib/asserts/number/max.mjs +1 -1
- package/lib/asserts/number/maxExcluded.js +2 -2
- package/lib/asserts/number/maxExcluded.mjs +1 -1
- package/lib/asserts/number/min.js +2 -2
- package/lib/asserts/number/min.mjs +1 -1
- package/lib/asserts/number/minExcluded.js +2 -2
- package/lib/asserts/number/minExcluded.mjs +1 -1
- package/lib/asserts/number/negative.js +2 -2
- package/lib/asserts/number/negative.mjs +1 -1
- package/lib/asserts/number/positive.js +2 -2
- package/lib/asserts/number/positive.mjs +1 -1
- package/lib/asserts/object/index.d.mts +4 -4
- package/lib/asserts/object/index.d.ts +4 -4
- package/lib/asserts/object/index.js +10 -5
- package/lib/asserts/object/index.js.map +1 -1
- package/lib/asserts/object/index.mjs +10 -5
- package/lib/asserts/object/index.mjs.map +1 -1
- package/lib/asserts/string/atLeastOneDigit.d.mts +20 -0
- package/lib/asserts/string/atLeastOneDigit.d.ts +20 -0
- package/lib/asserts/string/atLeastOneDigit.js +21 -0
- package/lib/asserts/string/atLeastOneDigit.js.map +1 -0
- package/lib/asserts/string/atLeastOneDigit.mjs +21 -0
- package/lib/asserts/string/atLeastOneDigit.mjs.map +1 -0
- package/lib/asserts/string/atLeastOneLowerChar.d.mts +20 -0
- package/lib/asserts/string/atLeastOneLowerChar.d.ts +20 -0
- package/lib/asserts/string/atLeastOneLowerChar.js +22 -0
- package/lib/asserts/string/atLeastOneLowerChar.js.map +1 -0
- package/lib/asserts/string/atLeastOneLowerChar.mjs +22 -0
- package/lib/asserts/string/atLeastOneLowerChar.mjs.map +1 -0
- package/lib/asserts/string/atLeastOneSpecialChar.d.mts +25 -0
- package/lib/asserts/string/atLeastOneSpecialChar.d.ts +25 -0
- package/lib/asserts/string/atLeastOneSpecialChar.js +26 -0
- package/lib/asserts/string/atLeastOneSpecialChar.js.map +1 -0
- package/lib/asserts/string/atLeastOneSpecialChar.mjs +26 -0
- package/lib/asserts/string/atLeastOneSpecialChar.mjs.map +1 -0
- package/lib/asserts/string/atLeastOneUpperChar.d.mts +20 -0
- package/lib/asserts/string/atLeastOneUpperChar.d.ts +20 -0
- package/lib/asserts/string/atLeastOneUpperChar.js +22 -0
- package/lib/asserts/string/atLeastOneUpperChar.js.map +1 -0
- package/lib/asserts/string/atLeastOneUpperChar.mjs +22 -0
- package/lib/asserts/string/atLeastOneUpperChar.mjs.map +1 -0
- package/lib/asserts/string/contains.d.mts +21 -0
- package/lib/asserts/string/contains.d.ts +21 -0
- package/lib/asserts/string/contains.js +22 -0
- package/lib/asserts/string/contains.js.map +1 -0
- package/lib/asserts/string/contains.mjs +22 -0
- package/lib/asserts/string/contains.mjs.map +1 -0
- package/lib/asserts/string/email.js +2 -2
- package/lib/asserts/string/email.mjs +1 -1
- package/lib/asserts/string/endsWith.d.mts +21 -0
- package/lib/asserts/string/endsWith.d.ts +21 -0
- package/lib/asserts/string/endsWith.js +22 -0
- package/lib/asserts/string/endsWith.js.map +1 -0
- package/lib/asserts/string/endsWith.mjs +22 -0
- package/lib/asserts/string/endsWith.mjs.map +1 -0
- package/lib/asserts/string/index.d.mts +4 -4
- package/lib/asserts/string/index.d.ts +4 -4
- package/lib/asserts/string/index.js +15 -9
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +15 -9
- package/lib/asserts/string/index.mjs.map +1 -1
- package/lib/asserts/string/lowerCase.d.mts +20 -0
- package/lib/asserts/string/lowerCase.d.ts +20 -0
- package/lib/asserts/string/lowerCase.js +20 -0
- package/lib/asserts/string/lowerCase.js.map +1 -0
- package/lib/asserts/string/lowerCase.mjs +20 -0
- package/lib/asserts/string/lowerCase.mjs.map +1 -0
- package/lib/asserts/string/maxLength.d.mts +1 -1
- package/lib/asserts/string/maxLength.d.ts +1 -1
- package/lib/asserts/string/maxLength.js +2 -2
- package/lib/asserts/string/maxLength.js.map +1 -1
- package/lib/asserts/string/maxLength.mjs +1 -1
- package/lib/asserts/string/maxLength.mjs.map +1 -1
- package/lib/asserts/string/minLength.d.mts +1 -1
- package/lib/asserts/string/minLength.d.ts +1 -1
- package/lib/asserts/string/minLength.js +2 -2
- package/lib/asserts/string/minLength.js.map +1 -1
- package/lib/asserts/string/minLength.mjs +1 -1
- package/lib/asserts/string/minLength.mjs.map +1 -1
- package/lib/asserts/string/regExp.d.mts +1 -1
- package/lib/asserts/string/regExp.d.ts +1 -1
- package/lib/asserts/string/regExp.js +2 -2
- package/lib/asserts/string/regExp.js.map +1 -1
- package/lib/asserts/string/regExp.mjs +1 -1
- package/lib/asserts/string/regExp.mjs.map +1 -1
- package/lib/asserts/string/startsWith.d.mts +21 -0
- package/lib/asserts/string/startsWith.d.ts +21 -0
- package/lib/asserts/string/startsWith.js +22 -0
- package/lib/asserts/string/startsWith.js.map +1 -0
- package/lib/asserts/string/startsWith.mjs +22 -0
- package/lib/asserts/string/startsWith.mjs.map +1 -0
- package/lib/asserts/string/upperCase.d.mts +21 -0
- package/lib/asserts/string/upperCase.d.ts +21 -0
- package/lib/asserts/string/upperCase.js +22 -0
- package/lib/asserts/string/upperCase.js.map +1 -0
- package/lib/asserts/string/upperCase.mjs +22 -0
- package/lib/asserts/string/upperCase.mjs.map +1 -0
- package/lib/asserts/string/uuid.d.mts +20 -0
- package/lib/asserts/string/uuid.d.ts +20 -0
- package/lib/asserts/string/uuid.js +23 -0
- package/lib/asserts/string/uuid.js.map +1 -0
- package/lib/asserts/string/uuid.mjs +23 -0
- package/lib/asserts/string/uuid.mjs.map +1 -0
- package/lib/asserts/string/uuidV1.d.mts +21 -0
- package/lib/asserts/string/uuidV1.d.ts +21 -0
- package/lib/asserts/string/uuidV1.js +23 -0
- package/lib/asserts/string/uuidV1.js.map +1 -0
- package/lib/asserts/string/uuidV1.mjs +23 -0
- package/lib/asserts/string/uuidV1.mjs.map +1 -0
- package/lib/asserts/string/uuidV2.d.mts +21 -0
- package/lib/asserts/string/uuidV2.d.ts +21 -0
- package/lib/asserts/string/uuidV2.js +23 -0
- package/lib/asserts/string/uuidV2.js.map +1 -0
- package/lib/asserts/string/uuidV2.mjs +23 -0
- package/lib/asserts/string/uuidV2.mjs.map +1 -0
- package/lib/asserts/string/uuidV3.d.mts +21 -0
- package/lib/asserts/string/uuidV3.d.ts +21 -0
- package/lib/asserts/string/uuidV3.js +23 -0
- package/lib/asserts/string/uuidV3.js.map +1 -0
- package/lib/asserts/string/uuidV3.mjs +23 -0
- package/lib/asserts/string/uuidV3.mjs.map +1 -0
- package/lib/asserts/string/uuidV4.d.mts +23 -0
- package/lib/asserts/string/uuidV4.d.ts +23 -0
- package/lib/asserts/string/uuidV4.js +23 -0
- package/lib/asserts/string/uuidV4.js.map +1 -0
- package/lib/asserts/string/uuidV4.mjs +23 -0
- package/lib/asserts/string/uuidV4.mjs.map +1 -0
- package/lib/asserts/string/uuidV5.d.mts +21 -0
- package/lib/asserts/string/uuidV5.d.ts +21 -0
- package/lib/asserts/string/uuidV5.js +23 -0
- package/lib/asserts/string/uuidV5.js.map +1 -0
- package/lib/asserts/string/uuidV5.mjs +23 -0
- package/lib/asserts/string/uuidV5.mjs.map +1 -0
- package/lib/asserts/string/validUrl.d.mts +23 -0
- package/lib/asserts/string/validUrl.d.ts +23 -0
- package/lib/asserts/string/validUrl.js +32 -0
- package/lib/asserts/string/validUrl.js.map +1 -0
- package/lib/asserts/string/validUrl.mjs +32 -0
- package/lib/asserts/string/validUrl.mjs.map +1 -0
- package/lib/{chunk-RRQOET3X.js → chunk-2OINKFOA.js} +6 -6
- package/lib/{chunk-RRQOET3X.js.map → chunk-2OINKFOA.js.map} +1 -1
- package/lib/{chunk-F5MSBL33.js → chunk-32J4WVLE.js} +21 -10
- package/lib/chunk-32J4WVLE.js.map +1 -0
- package/lib/chunk-356HMXOP.js +12 -0
- package/lib/chunk-356HMXOP.js.map +1 -0
- package/lib/chunk-42J6CHIO.js +7 -0
- package/lib/chunk-42J6CHIO.js.map +1 -0
- package/lib/{chunk-4CYIMDP2.js → chunk-4SPM2CSQ.js} +3 -3
- package/lib/chunk-4SPM2CSQ.js.map +1 -0
- package/lib/{chunk-WBERBAL4.js → chunk-4SR7J2I4.js} +6 -6
- package/lib/{chunk-WBERBAL4.js.map → chunk-4SR7J2I4.js.map} +1 -1
- package/lib/{chunk-DPBE7TAQ.mjs → chunk-4UF67IQ2.mjs} +3 -3
- package/lib/chunk-4UF67IQ2.mjs.map +1 -0
- package/lib/{chunk-RYVUYVEE.mjs → chunk-54RHVQFA.mjs} +2 -2
- package/lib/{chunk-YUESB2WV.mjs → chunk-5AO66YV5.mjs} +3 -3
- package/lib/{chunk-RQH4LXBW.js → chunk-5EIBKBYS.js} +21 -10
- package/lib/chunk-5EIBKBYS.js.map +1 -0
- package/lib/{chunk-IRG4OQAB.js → chunk-7GIRQ5EA.js} +7 -1
- package/lib/chunk-7GIRQ5EA.js.map +1 -0
- package/lib/chunk-ASZW6XRM.mjs +7 -0
- package/lib/chunk-ASZW6XRM.mjs.map +1 -0
- package/lib/{chunk-5BVJ6YMH.js → chunk-CQWI6YRI.js} +3 -2
- package/lib/chunk-CQWI6YRI.js.map +1 -0
- package/lib/{chunk-EGEHSELT.js → chunk-EQNVYAKS.js} +7 -7
- package/lib/chunk-EQNVYAKS.js.map +1 -0
- package/lib/chunk-GDSB7CDN.mjs +12 -0
- package/lib/chunk-GDSB7CDN.mjs.map +1 -0
- package/lib/chunk-LWAEUS2F.js +14 -0
- package/lib/{chunk-JSGZ7DKT.js.map → chunk-LWAEUS2F.js.map} +1 -1
- package/lib/{chunk-NNFYXHLU.mjs → chunk-M6OCVAUD.mjs} +2 -2
- package/lib/chunk-M6OCVAUD.mjs.map +1 -0
- package/lib/{chunk-PG2R7P7G.mjs → chunk-MRWZVTNH.mjs} +3 -3
- package/lib/{chunk-DJSLA2ZV.js → chunk-MTJJKWTP.js} +5 -5
- package/lib/{chunk-DJSLA2ZV.js.map → chunk-MTJJKWTP.js.map} +1 -1
- package/lib/{chunk-6TH3DBDK.js → chunk-N6YMNLXG.js} +8 -8
- package/lib/{chunk-6TH3DBDK.js.map → chunk-N6YMNLXG.js.map} +1 -1
- package/lib/{chunk-NDQM5OL4.mjs → chunk-PEWNA24X.mjs} +3 -3
- package/lib/{chunk-CCBCDJXS.mjs → chunk-PJI3DRGP.mjs} +3 -3
- package/lib/{chunk-TCQY2R3U.mjs → chunk-PVOHKGBW.mjs} +3 -3
- package/lib/chunk-QLVLZRHT.js +20 -0
- package/lib/chunk-QLVLZRHT.js.map +1 -0
- package/lib/{chunk-3HTYHE2X.mjs → chunk-QV4JDW3T.mjs} +3 -2
- package/lib/chunk-QV4JDW3T.mjs.map +1 -0
- package/lib/chunk-SEIKS6G7.js +61 -0
- package/lib/chunk-SEIKS6G7.js.map +1 -0
- package/lib/{chunk-FTLRX2XG.mjs → chunk-TP5I237J.mjs} +17 -6
- package/lib/chunk-TP5I237J.mjs.map +1 -0
- package/lib/chunk-UV4I7JZR.mjs +61 -0
- package/lib/chunk-UV4I7JZR.mjs.map +1 -0
- package/lib/{chunk-H7CPKW53.js → chunk-VGF3Y2EK.js} +5 -5
- package/lib/{chunk-H7CPKW53.js.map → chunk-VGF3Y2EK.js.map} +1 -1
- package/lib/{chunk-J4VKFJQK.js → chunk-WPHJ4QTB.js} +3 -3
- package/lib/chunk-WPHJ4QTB.js.map +1 -0
- package/lib/chunk-XFR7Y4XX.mjs +20 -0
- package/lib/chunk-XFR7Y4XX.mjs.map +1 -0
- package/lib/{chunk-PH2PMUZP.mjs → chunk-XZTZC73V.mjs} +7 -1
- package/lib/chunk-XZTZC73V.mjs.map +1 -0
- package/lib/{chunk-3O4WCRC2.mjs → chunk-YPAUFM3S.mjs} +2 -2
- package/lib/chunk-YPAUFM3S.mjs.map +1 -0
- package/lib/{chunk-CLG3QRZC.mjs → chunk-Z7OEFOAD.mjs} +17 -6
- package/lib/chunk-Z7OEFOAD.mjs.map +1 -0
- package/lib/codeGen.d.mts +1 -1
- package/lib/codeGen.d.ts +1 -1
- package/lib/codeGen.js +4 -2
- package/lib/codeGen.js.map +1 -1
- package/lib/codeGen.mjs +3 -1
- package/lib/codeGen.mjs.map +1 -1
- package/lib/commonTypes.d.mts +1 -0
- package/lib/commonTypes.d.ts +1 -0
- package/lib/helpers/constants.d.mts +3 -0
- package/lib/helpers/constants.d.ts +3 -0
- package/lib/helpers/constants.js +7 -0
- package/lib/helpers/constants.js.map +1 -0
- package/lib/helpers/constants.mjs +7 -0
- package/lib/helpers/constants.mjs.map +1 -0
- package/lib/helpers/core.d.mts +1 -1
- package/lib/helpers/core.d.ts +1 -1
- package/lib/helpers/core.js +3 -2
- package/lib/helpers/core.js.map +1 -1
- package/lib/helpers/core.mjs +2 -1
- package/lib/helpers/isValidDate.d.mts +3 -0
- package/lib/helpers/isValidDate.d.ts +3 -0
- package/lib/helpers/isValidDate.js +7 -0
- package/lib/helpers/isValidDate.js.map +1 -0
- package/lib/helpers/isValidDate.mjs +7 -0
- package/lib/helpers/isValidDate.mjs.map +1 -0
- package/lib/helpers/setStrictType.d.mts +1 -1
- package/lib/helpers/setStrictType.d.ts +1 -1
- package/lib/helpers/setStrictType.js +4 -3
- package/lib/helpers/setStrictType.js.map +1 -1
- package/lib/helpers/setStrictType.mjs +3 -2
- package/lib/index.d.mts +3 -7
- package/lib/index.d.ts +3 -7
- package/lib/index.js +6 -38
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +6 -38
- package/lib/parse.d.mts +3 -1
- package/lib/parse.d.ts +3 -1
- package/lib/parse.js +5 -4
- package/lib/parse.js.map +1 -1
- package/lib/parse.mjs +4 -3
- package/lib/parseOrFail.d.mts +3 -1
- package/lib/parseOrFail.d.ts +3 -1
- package/lib/parseOrFail.js +5 -4
- package/lib/parseOrFail.js.map +1 -1
- package/lib/parseOrFail.mjs +4 -3
- package/lib/schemas/ArraySchema.d.mts +1 -1
- package/lib/schemas/ArraySchema.d.ts +1 -1
- package/lib/schemas/ArraySchema.js +5 -4
- package/lib/schemas/ArraySchema.js.map +1 -1
- package/lib/schemas/ArraySchema.mjs +4 -3
- package/lib/schemas/BigIntSchema.d.mts +32 -0
- package/lib/schemas/BigIntSchema.d.ts +32 -0
- package/lib/schemas/BigIntSchema.js +16 -0
- package/lib/schemas/BigIntSchema.js.map +1 -0
- package/lib/schemas/BigIntSchema.mjs +16 -0
- package/lib/schemas/BigIntSchema.mjs.map +1 -0
- package/lib/schemas/BooleanSchema.d.mts +1 -1
- package/lib/schemas/BooleanSchema.d.ts +1 -1
- package/lib/schemas/BooleanSchema.js +6 -5
- package/lib/schemas/BooleanSchema.js.map +1 -1
- package/lib/schemas/BooleanSchema.mjs +5 -4
- package/lib/schemas/CommonSchema.d.mts +1 -1
- package/lib/schemas/CommonSchema.d.ts +1 -1
- package/lib/schemas/CommonSchema.js +4 -3
- package/lib/schemas/CommonSchema.js.map +1 -1
- package/lib/schemas/CommonSchema.mjs +3 -2
- package/lib/schemas/DateSchema.d.mts +9 -0
- package/lib/schemas/DateSchema.d.ts +9 -0
- package/lib/schemas/DateSchema.js +11 -0
- package/lib/schemas/DateSchema.js.map +1 -0
- package/lib/schemas/DateSchema.mjs +11 -0
- package/lib/schemas/DateSchema.mjs.map +1 -0
- package/lib/schemas/NumberSchema.d.mts +2 -1
- package/lib/schemas/NumberSchema.d.ts +2 -1
- package/lib/schemas/NumberSchema.js +10 -8
- package/lib/schemas/NumberSchema.js.map +1 -1
- package/lib/schemas/NumberSchema.mjs +9 -7
- package/lib/schemas/ObjectSchema.d.mts +1 -1
- package/lib/schemas/ObjectSchema.d.ts +1 -1
- package/lib/schemas/ObjectSchema.js +5 -4
- package/lib/schemas/ObjectSchema.js.map +1 -1
- package/lib/schemas/ObjectSchema.mjs +4 -3
- package/lib/schemas/StringSchema.d.mts +2 -1
- package/lib/schemas/StringSchema.d.ts +2 -1
- package/lib/schemas/StringSchema.js +10 -8
- package/lib/schemas/StringSchema.js.map +1 -1
- package/lib/schemas/StringSchema.mjs +9 -7
- package/lib/translationMap.js +2 -2
- package/lib/translationMap.mjs +1 -1
- package/package.json +6 -1
- package/lib/chunk-2PM3K3OE.mjs +0 -13
- package/lib/chunk-2PM3K3OE.mjs.map +0 -1
- package/lib/chunk-3HTYHE2X.mjs.map +0 -1
- package/lib/chunk-3O4WCRC2.mjs.map +0 -1
- package/lib/chunk-4CYIMDP2.js.map +0 -1
- package/lib/chunk-4RNK3I74.js +0 -13
- package/lib/chunk-4RNK3I74.js.map +0 -1
- package/lib/chunk-5BVJ6YMH.js.map +0 -1
- package/lib/chunk-B6TFELXR.mjs +0 -13
- package/lib/chunk-B6TFELXR.mjs.map +0 -1
- package/lib/chunk-CLG3QRZC.mjs.map +0 -1
- package/lib/chunk-DPBE7TAQ.mjs.map +0 -1
- package/lib/chunk-EGEHSELT.js.map +0 -1
- package/lib/chunk-F5MSBL33.js.map +0 -1
- package/lib/chunk-FTLRX2XG.mjs.map +0 -1
- package/lib/chunk-HDSGCAHH.js +0 -13
- package/lib/chunk-HDSGCAHH.js.map +0 -1
- package/lib/chunk-IEUXIOL6.js +0 -13
- package/lib/chunk-IEUXIOL6.js.map +0 -1
- package/lib/chunk-IRG4OQAB.js.map +0 -1
- package/lib/chunk-J4VKFJQK.js.map +0 -1
- package/lib/chunk-JDGZCBXF.mjs +0 -13
- package/lib/chunk-JDGZCBXF.mjs.map +0 -1
- package/lib/chunk-JSGZ7DKT.js +0 -14
- package/lib/chunk-MRISXZQ4.mjs +0 -13
- package/lib/chunk-MRISXZQ4.mjs.map +0 -1
- package/lib/chunk-NNFYXHLU.mjs.map +0 -1
- package/lib/chunk-NTC2XQ36.mjs +0 -13
- package/lib/chunk-NTC2XQ36.mjs.map +0 -1
- package/lib/chunk-PH2PMUZP.mjs.map +0 -1
- package/lib/chunk-QQNQ4IDN.js +0 -13
- package/lib/chunk-QQNQ4IDN.js.map +0 -1
- package/lib/chunk-RL4MSI7R.js +0 -13
- package/lib/chunk-RL4MSI7R.js.map +0 -1
- package/lib/chunk-RQH4LXBW.js.map +0 -1
- package/lib/chunk-VHEA4JZ5.js +0 -13
- package/lib/chunk-VHEA4JZ5.js.map +0 -1
- package/lib/chunk-YML32TPA.mjs +0 -13
- package/lib/chunk-YML32TPA.mjs.map +0 -1
- /package/lib/{chunk-RYVUYVEE.mjs.map → chunk-54RHVQFA.mjs.map} +0 -0
- /package/lib/{chunk-YUESB2WV.mjs.map → chunk-5AO66YV5.mjs.map} +0 -0
- /package/lib/{chunk-PG2R7P7G.mjs.map → chunk-MRWZVTNH.mjs.map} +0 -0
- /package/lib/{chunk-NDQM5OL4.mjs.map → chunk-PEWNA24X.mjs.map} +0 -0
- /package/lib/{chunk-CCBCDJXS.mjs.map → chunk-PJI3DRGP.mjs.map} +0 -0
- /package/lib/{chunk-TCQY2R3U.mjs.map → chunk-PVOHKGBW.mjs.map} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RequiredValidation } from '../../commonTypes.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description Asserts that the string value is a valid URL with optional protocol validation.
|
|
5
|
+
* @param {string} [protocol] The protocol that the URL must start with (e.g., 'http'). If not provided, any URL starting with 'http://' or 'https://' is considered valid.
|
|
6
|
+
* @returns {RequiredValidation} A validation function that takes a received string and an exception context.
|
|
7
|
+
* @throws {ValidationError} if the received value does not match the expected URL pattern.
|
|
8
|
+
* @example
|
|
9
|
+
* const schema = string().custom(validUrl()); // Validates any URL starting with 'http://' or 'https://'
|
|
10
|
+
* parseOrFail(schema, 'http://example.com'); // Valid
|
|
11
|
+
* parseOrFail(schema, 'https://example.com'); // Valid
|
|
12
|
+
* parseOrFail(schema, 'ftp://example.com'); // Throws an error
|
|
13
|
+
* parseOrFail(schema, 'http:example.com'); // Throws an error
|
|
14
|
+
*
|
|
15
|
+
* @translation Error Translation Key = 's:url'
|
|
16
|
+
*/
|
|
17
|
+
declare const validUrl: {
|
|
18
|
+
(protocol?: string): RequiredValidation;
|
|
19
|
+
key: string;
|
|
20
|
+
message: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { validUrl };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkCQWI6YRIjs = require('../../chunk-CQWI6YRI.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkWK4O3HH4js = require('../../chunk-WK4O3HH4.js');
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/validUrl.ts
|
|
9
|
+
var validUrlErrorMessage = "The received value is not a valid URL";
|
|
10
|
+
var validUrlErrorKey = "s:validUrl";
|
|
11
|
+
var urlRegex = /^(http:\/\/|https:\/\/)([a-zA-Z0-9\-.]+)(:\d+)?(\/[^\s]*)?$/;
|
|
12
|
+
var validUrl = (protocol) => (received, ctx) => {
|
|
13
|
+
let regex = urlRegex;
|
|
14
|
+
if (protocol) {
|
|
15
|
+
regex = new RegExp(`^${protocol}:\\/\\/([a-zA-Z0-9\\-\\.]+)(:[0-9]+)?(\\/[^\\s]*)?$`);
|
|
16
|
+
}
|
|
17
|
+
if (!regex.test(received)) {
|
|
18
|
+
_chunkWK4O3HH4js.guardException.call(void 0,
|
|
19
|
+
`URL must start with '${protocol ? protocol + "://" : "http:// or https://"}'`,
|
|
20
|
+
received,
|
|
21
|
+
ctx,
|
|
22
|
+
validUrlErrorKey
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
validUrl.key = validUrlErrorKey;
|
|
27
|
+
validUrl.message = validUrlErrorMessage;
|
|
28
|
+
_chunkCQWI6YRIjs.setToDefaultLocale.call(void 0, validUrl);
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
exports.validUrl = validUrl;
|
|
32
|
+
//# sourceMappingURL=validUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/validUrl.js","../../../src/asserts/string/validUrl.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,qBAAA,EAAuB,uCAAA;AAC7B,IAAM,iBAAA,EAAmB,YAAA;AAEzB,IAAM,SAAA,EAAW,6DAAA;AAgBV,IAAM,SAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,IAAI,MAAA,EAAQ,QAAA;AACZ,EAAA,GAAA,CAAI,QAAA,EAAU;AACZ,IAAA,MAAA,EAAQ,IAAI,MAAA,CAAO,CAAA,CAAA,EAAI,QAAQ,CAAA,mDAAA,CAAqD,CAAA;AAAA,EACtF;AAEA,EAAA,GAAA,CAAI,CAAC,KAAA,CAAM,IAAA,CAAK,QAAQ,CAAA,EAAG;AACzB,IAAA,6CAAA;AAAA,MACE,CAAA,qBAAA,EAAwB,SAAA,EAAW,SAAA,EAAW,MAAA,EAAQ,qBAAqB,CAAA,CAAA,CAAA;AAAA,MAC3E,QAAA;AAAA,MACA,GAAA;AAAA,MACA;AAAA,IACF,CAAA;AAAA,EACF;AACF,CAAA;AAEF,QAAA,CAAS,IAAA,EAAM,gBAAA;AACf,QAAA,CAAS,QAAA,EAAU,oBAAA;AACnB,iDAAA,QAA2B,CAAA;ADf3B;AACE;AACF,4BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/validUrl.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst validUrlErrorMessage = 'The received value is not a valid URL';\nconst validUrlErrorKey = 's:validUrl';\n\nconst urlRegex = /^(http:\\/\\/|https:\\/\\/)([a-zA-Z0-9\\-.]+)(:\\d+)?(\\/[^\\s]*)?$/;\n\n/**\n * @description Asserts that the string value is a valid URL with optional protocol validation.\n * @param {string} [protocol] The protocol that the URL must start with (e.g., 'http'). If not provided, any URL starting with 'http://' or 'https://' is considered valid.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value does not match the expected URL pattern.\n * @example\n * const schema = string().custom(validUrl()); // Validates any URL starting with 'http://' or 'https://'\n * parseOrFail(schema, 'http://example.com'); // Valid\n * parseOrFail(schema, 'https://example.com'); // Valid\n * parseOrFail(schema, 'ftp://example.com'); // Throws an error\n * parseOrFail(schema, 'http:example.com'); // Throws an error\n *\n * @translation Error Translation Key = 's:url'\n */\nexport const validUrl =\n (protocol?: string): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n let regex = urlRegex;\n if (protocol) {\n regex = new RegExp(`^${protocol}:\\\\/\\\\/([a-zA-Z0-9\\\\-\\\\.]+)(:[0-9]+)?(\\\\/[^\\\\s]*)?$`);\n }\n\n if (!regex.test(received)) {\n guardException(\n `URL must start with '${protocol ? protocol + '://' : 'http:// or https://'}'`,\n received,\n ctx,\n validUrlErrorKey,\n );\n }\n };\n\nvalidUrl.key = validUrlErrorKey;\nvalidUrl.message = validUrlErrorMessage;\nsetToDefaultLocale(validUrl);\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setToDefaultLocale
|
|
3
|
+
} from "../../chunk-QV4JDW3T.mjs";
|
|
4
|
+
import {
|
|
5
|
+
guardException
|
|
6
|
+
} from "../../chunk-7XFLH6R2.mjs";
|
|
7
|
+
|
|
8
|
+
// src/asserts/string/validUrl.ts
|
|
9
|
+
var validUrlErrorMessage = "The received value is not a valid URL";
|
|
10
|
+
var validUrlErrorKey = "s:validUrl";
|
|
11
|
+
var urlRegex = /^(http:\/\/|https:\/\/)([a-zA-Z0-9\-.]+)(:\d+)?(\/[^\s]*)?$/;
|
|
12
|
+
var validUrl = (protocol) => (received, ctx) => {
|
|
13
|
+
let regex = urlRegex;
|
|
14
|
+
if (protocol) {
|
|
15
|
+
regex = new RegExp(`^${protocol}:\\/\\/([a-zA-Z0-9\\-\\.]+)(:[0-9]+)?(\\/[^\\s]*)?$`);
|
|
16
|
+
}
|
|
17
|
+
if (!regex.test(received)) {
|
|
18
|
+
guardException(
|
|
19
|
+
`URL must start with '${protocol ? protocol + "://" : "http:// or https://"}'`,
|
|
20
|
+
received,
|
|
21
|
+
ctx,
|
|
22
|
+
validUrlErrorKey
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
validUrl.key = validUrlErrorKey;
|
|
27
|
+
validUrl.message = validUrlErrorMessage;
|
|
28
|
+
setToDefaultLocale(validUrl);
|
|
29
|
+
export {
|
|
30
|
+
validUrl
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=validUrl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/asserts/string/validUrl.ts"],"sourcesContent":["import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst validUrlErrorMessage = 'The received value is not a valid URL';\nconst validUrlErrorKey = 's:validUrl';\n\nconst urlRegex = /^(http:\\/\\/|https:\\/\\/)([a-zA-Z0-9\\-.]+)(:\\d+)?(\\/[^\\s]*)?$/;\n\n/**\n * @description Asserts that the string value is a valid URL with optional protocol validation.\n * @param {string} [protocol] The protocol that the URL must start with (e.g., 'http'). If not provided, any URL starting with 'http://' or 'https://' is considered valid.\n * @returns {RequiredValidation} A validation function that takes a received string and an exception context.\n * @throws {ValidationError} if the received value does not match the expected URL pattern.\n * @example\n * const schema = string().custom(validUrl()); // Validates any URL starting with 'http://' or 'https://'\n * parseOrFail(schema, 'http://example.com'); // Valid\n * parseOrFail(schema, 'https://example.com'); // Valid\n * parseOrFail(schema, 'ftp://example.com'); // Throws an error\n * parseOrFail(schema, 'http:example.com'); // Throws an error\n *\n * @translation Error Translation Key = 's:url'\n */\nexport const validUrl =\n (protocol?: string): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n let regex = urlRegex;\n if (protocol) {\n regex = new RegExp(`^${protocol}:\\\\/\\\\/([a-zA-Z0-9\\\\-\\\\.]+)(:[0-9]+)?(\\\\/[^\\\\s]*)?$`);\n }\n\n if (!regex.test(received)) {\n guardException(\n `URL must start with '${protocol ? protocol + '://' : 'http:// or https://'}'`,\n received,\n ctx,\n validUrlErrorKey,\n );\n }\n };\n\nvalidUrl.key = validUrlErrorKey;\nvalidUrl.message = validUrlErrorMessage;\nsetToDefaultLocale(validUrl);\n"],"mappings":";;;;;;;;AAIA,IAAM,uBAAuB;AAC7B,IAAM,mBAAmB;AAEzB,IAAM,WAAW;AAgBV,IAAM,WACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,QAAQ;AACZ,MAAI,UAAU;AACZ,YAAQ,IAAI,OAAO,IAAI,QAAQ,qDAAqD;AAAA,EACtF;AAEA,MAAI,CAAC,MAAM,KAAK,QAAQ,GAAG;AACzB;AAAA,MACE,wBAAwB,WAAW,WAAW,QAAQ,qBAAqB;AAAA,MAC3E;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEF,SAAS,MAAM;AACf,SAAS,UAAU;AACnB,mBAAmB,QAAQ;","names":[]}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkEQNVYAKSjs = require('./chunk-EQNVYAKS.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk7GIRQ5EAjs = require('./chunk-7GIRQ5EA.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
|
|
10
10
|
|
|
11
11
|
// src/schemas/ArraySchema.ts
|
|
12
|
-
var ArraySchema = (_class = class extends
|
|
12
|
+
var ArraySchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {
|
|
13
13
|
__init() {this._array = 1}
|
|
14
14
|
constructor(ctx, arraySchema) {
|
|
15
15
|
super(ctx);_class.prototype.__init.call(this);;
|
|
16
16
|
this.validateArrayEntry(arraySchema);
|
|
17
|
-
this[
|
|
17
|
+
this[_chunk7GIRQ5EAjs.ctxSymbol].array = arraySchema;
|
|
18
18
|
}
|
|
19
19
|
validateArrayEntry(arraySchema) {
|
|
20
20
|
if (!arraySchema) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Missing schema in array method");
|
|
21
|
-
if (!(arraySchema instanceof
|
|
21
|
+
if (!(arraySchema instanceof _chunkEQNVYAKSjs.CommonSchema)) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Invalid schema in array method");
|
|
22
22
|
}
|
|
23
23
|
}, _class);
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
exports.ArraySchema = ArraySchema;
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-2OINKFOA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-2OINKFOA.js","../src/schemas/ArraySchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNO,IAAM,YAAA,YAAN,MAAA,QAA0B,8BAAa;AAAA,iBAC5C,OAAA,EAAS,EAAA;AAAA,EACT,WAAA,CAAY,GAAA,EAAuB,WAAA,EAA2B;AAC5D,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,kBAAA,CAAmB,WAAW,CAAA;AACnC,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,MAAA,EAAQ,WAAA;AAAA,EAC1B;AAAA,EAEQ,kBAAA,CAAmB,WAAA,EAA2B;AACpD,IAAA,GAAA,CAAI,CAAC,WAAA,EAAa,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAC7E,IAAA,GAAA,CAAI,CAAA,CAAE,YAAA,WAAuB,6BAAA,CAAA,EAAe,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAAA,EACzG;AACF,UAAA;ADOA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-2OINKFOA.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class ArraySchema extends CommonSchema {\n _array = 1;\n constructor(ctx: ValidatorContext, arraySchema: CommonSchema) {\n super(ctx);\n this.validateArrayEntry(arraySchema);\n this[ctxSymbol].array = arraySchema;\n }\n\n private validateArrayEntry(arraySchema: CommonSchema) {\n if (!arraySchema) throw new BuildSchemaError('Missing schema in array method');\n if (!(arraySchema instanceof CommonSchema)) throw new BuildSchemaError('Invalid schema in array method');\n }\n}\n\nexport type WithArray<Y extends CommonSchema> = ArraySchema & { validation_array: Y };\nexport type ExtractFromArray<T> = T extends WithArray<infer X> ? X : never;\n"]}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk4SPM2CSQjs = require('./chunk-4SPM2CSQ.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkWPHJ4QTBjs = require('./chunk-WPHJ4QTB.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkLWAEUS2Fjs = require('./chunk-LWAEUS2F.js');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunkEQNVYAKSjs = require('./chunk-EQNVYAKS.js');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
|
|
13
19
|
|
|
14
20
|
// src/schemas/StringSchema.ts
|
|
15
|
-
var StringSchema = (_class = class extends
|
|
21
|
+
var StringSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
16
22
|
__init() {this._string = 1}
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
* Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
19
26
|
*
|
|
@@ -23,8 +30,10 @@ var StringSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
|
|
|
23
30
|
* @example - string().equalTo('hello'); // Infers the type 'hello'
|
|
24
31
|
*/
|
|
25
32
|
equalTo(expectedValue) {
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
34
|
+
this.limit = true;
|
|
35
|
+
_chunkLWAEUS2Fjs._setStrictType.call(void 0, this, `'${expectedValue}'`);
|
|
36
|
+
return this.custom(_chunkWPHJ4QTBjs.equalTo.call(void 0, expectedValue));
|
|
28
37
|
}
|
|
29
38
|
/**
|
|
30
39
|
* Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
|
|
@@ -36,15 +45,17 @@ var StringSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
|
|
|
36
45
|
* string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'
|
|
37
46
|
*/
|
|
38
47
|
oneOfValues(expectedValue) {
|
|
39
|
-
|
|
48
|
+
if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
49
|
+
this.limit = true;
|
|
50
|
+
_chunkLWAEUS2Fjs._setStrictType.call(void 0,
|
|
40
51
|
this,
|
|
41
52
|
expectedValue.map((el) => `'${el}'`)
|
|
42
53
|
);
|
|
43
|
-
return this.custom(
|
|
54
|
+
return this.custom(_chunk4SPM2CSQjs.oneOfValues.call(void 0, expectedValue));
|
|
44
55
|
}
|
|
45
56
|
}, _class);
|
|
46
57
|
|
|
47
58
|
|
|
48
59
|
|
|
49
60
|
exports.StringSchema = StringSchema;
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-32J4WVLE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-32J4WVLE.js","../src/schemas/StringSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACZO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,CAAG,CAAA;AAEzC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA;AAAA,MACE,IAAA;AAAA,MACA,aAAA,CAAc,GAAA,CAAI,CAAC,EAAA,EAAA,GAAO,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA,CAAG;AAAA,IACrC,CAAA;AACA,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADWA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-32J4WVLE.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, `'${expectedValue}'`);\n\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithString<this, Y>;\n }\n}\n\nexport type WithString<T extends StringSchema, Y = string> = T & { validation_string: Y };\nexport type ExtractFromString<T> = T extends WithString<StringSchema, infer Y> ? Y : never;\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/helpers/isValidDate.ts
|
|
2
|
+
function isValidDate(d) {
|
|
3
|
+
return (
|
|
4
|
+
// @ts-expect-error we expect d to have getTime method
|
|
5
|
+
Object.prototype.toString.call(d) === "[object Date]" && !isNaN(typeof _optionalChain([d, 'optionalAccess', _ => _.getTime]) === "function" && d.getTime())
|
|
6
|
+
);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.isValidDate = isValidDate;
|
|
12
|
+
//# sourceMappingURL=chunk-356HMXOP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-356HMXOP.js","../src/helpers/isValidDate.ts"],"names":[],"mappings":"AAAA;ACAO,SAAS,WAAA,CAAY,CAAA,EAAY;AACtC,EAAA,OAAA;AAAA;AAAA,IAEE,MAAA,CAAO,SAAA,CAAU,QAAA,CAAS,IAAA,CAAK,CAAC,EAAA,IAAM,gBAAA,GAAmB,CAAC,KAAA,CAAM,uBAAO,CAAA,2BAAG,UAAA,IAAY,WAAA,GAAc,CAAA,CAAE,OAAA,CAAQ,CAAC;AAAA,EAAA,CAAA;AAEnH;ADEA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-356HMXOP.js","sourcesContent":[null,"export function isValidDate(d: unknown) {\n return (\n // @ts-expect-error we expect d to have getTime method\n Object.prototype.toString.call(d) === '[object Date]' && !isNaN(typeof d?.getTime === 'function' && d.getTime())\n );\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/helpers/constants.ts
|
|
2
|
+
var ONLY_ONCE = "It is allowed to call either 'equalTo' or 'oneOfValues,' but only one of them, and only once.";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
exports.ONLY_ONCE = ONLY_ONCE;
|
|
7
|
+
//# sourceMappingURL=chunk-42J6CHIO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-42J6CHIO.js","../src/helpers/constants.ts"],"names":[],"mappings":"AAAA;ACAO,IAAM,UAAA,EACX,+FAAA;ADCF;AACA;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-42J6CHIO.js","sourcesContent":[null,"export const ONLY_ONCE =\n \"It is allowed to call either 'equalTo' or 'oneOfValues,' but only one of them, and only once.\";\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkCQWI6YRIjs = require('./chunk-CQWI6YRI.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
|
|
@@ -13,9 +13,9 @@ var oneOfValues = (expected) => (received, ctx) => {
|
|
|
13
13
|
};
|
|
14
14
|
oneOfValues.key = oneOfValuesErrorKey;
|
|
15
15
|
oneOfValues.message = oneOfValuesErrorMessage;
|
|
16
|
-
|
|
16
|
+
_chunkCQWI6YRIjs.setToDefaultLocale.call(void 0, oneOfValues);
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
exports.oneOfValues = oneOfValues;
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-4SPM2CSQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-4SPM2CSQ.js","../src/asserts/mix/oneOfValues.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACHA,IAAM,wBAAA,EAA0B,6CAAA;AAChC,IAAM,oBAAA,EAAsB,eAAA;AAgBrB,IAAM,YAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AAC5C,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,QAAA,CAAS,QAAQ,CAAA,EAAG,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,mBAAmB,CAAA;AAC/F,CAAA;AAEF,WAAA,CAAY,IAAA,EAAM,mBAAA;AAClB,WAAA,CAAY,QAAA,EAAU,uBAAA;AACtB,iDAAA,WAA8B,CAAA;ADb9B;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-4SPM2CSQ.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst oneOfValuesErrorMessage = 'The received value is not equal to expected';\nconst oneOfValuesErrorKey = 'm:oneOfValues';\n\n/**\n * @description Creates a custom assertion that checks if a value is equal to the one of expected values.\n * @notice It has already been implemented in the number, bigint and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match at least one of the expected values.\n * @example\n * const schema = number().custom(oneOfValues([5, 4])); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 4); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:oneOfValues'\n */\nexport const oneOfValues =\n (expected: unknown[]): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (!expected.includes(received)) guardException(expected, received, ctx, oneOfValuesErrorKey);\n };\n\noneOfValues.key = oneOfValuesErrorKey;\noneOfValues.message = oneOfValuesErrorMessage;\nsetToDefaultLocale(oneOfValues);\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkLWAEUS2Fjs = require('./chunk-LWAEUS2F.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkEQNVYAKSjs = require('./chunk-EQNVYAKS.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
|
|
@@ -12,7 +12,7 @@ var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
|
|
|
12
12
|
var isBoolean = (expected) => (received, ctx) => {
|
|
13
13
|
if (received !== expected) _chunkWK4O3HH4js.guardException.call(void 0, expected, received, ctx, "c:isBoolean");
|
|
14
14
|
};
|
|
15
|
-
var BooleanSchema = (_class = class extends
|
|
15
|
+
var BooleanSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
16
16
|
__init() {this._boolean = 1}
|
|
17
17
|
/**
|
|
18
18
|
* Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.
|
|
@@ -22,7 +22,7 @@ var BooleanSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {const
|
|
|
22
22
|
* @example - boolean().onlyTrue(); // Infers the type true
|
|
23
23
|
*/
|
|
24
24
|
onlyTrue() {
|
|
25
|
-
|
|
25
|
+
_chunkLWAEUS2Fjs._setStrictType.call(void 0, this, true);
|
|
26
26
|
return this.custom(isBoolean(true));
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -33,7 +33,7 @@ var BooleanSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {const
|
|
|
33
33
|
* @example - boolean().onlyFalse(); // Infers the type false
|
|
34
34
|
*/
|
|
35
35
|
onlyFalse() {
|
|
36
|
-
|
|
36
|
+
_chunkLWAEUS2Fjs._setStrictType.call(void 0, this, false);
|
|
37
37
|
return this.custom(isBoolean(false));
|
|
38
38
|
}
|
|
39
39
|
}, _class);
|
|
@@ -41,4 +41,4 @@ var BooleanSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {const
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
exports.BooleanSchema = BooleanSchema;
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-4SR7J2I4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-4SR7J2I4.js","../src/schemas/BooleanSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACLA,IAAM,UAAA,EAAY,CAAC,QAAA,EAAA,GAAsB,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AACrF,EAAA,GAAA,CAAI,SAAA,IAAa,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,aAAa,CAAA;AAClF,CAAA;AAEO,IAAM,cAAA,YAAN,MAAA,QAA4B,8BAAa;AAAA,iBAC9C,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASX,QAAA,CAAA,EAAoC;AAClC,IAAA,6CAAA,IAAe,EAAM,IAAI,CAAA;AACzB,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,IAAI,CAAC,CAAA;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,SAAA,CAAA,EAAsC;AACpC,IAAA,6CAAA,IAAe,EAAM,KAAK,CAAA;AAC1B,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,KAAK,CAAC,CAAA;AAAA,EACrC;AACF,UAAA;ADIA;AACA;AACE;AACF,sCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-4SR7J2I4.js","sourcesContent":[null,"import { CommonSchema } from './CommonSchema';\nimport { guardException } from '../exceptions';\nimport { ExceptionContext } from '../commonTypes';\nimport { _setStrictType } from '../helpers/setStrictType';\n\nconst isBoolean = (expected: boolean) => (received: boolean, ctx: ExceptionContext) => {\n if (received !== expected) guardException(expected, received, ctx, 'c:isBoolean');\n};\n\nexport class BooleanSchema extends CommonSchema {\n _boolean = 1;\n\n /**\n * Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value true, with the true value inferred as the TypeScript type\n *\n * @example - boolean().onlyTrue(); // Infers the type true\n */\n onlyTrue(): WithBoolean<this, true> {\n _setStrictType(this, true);\n return this.custom(isBoolean(true)) as WithBoolean<this, true>;\n }\n\n /**\n * Restricts the schema to exactly match the boolean value false and infers the false value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value false, with the false value inferred as the TypeScript type\n *\n * @example - boolean().onlyFalse(); // Infers the type false\n */\n onlyFalse(): WithBoolean<this, false> {\n _setStrictType(this, false);\n return this.custom(isBoolean(false)) as WithBoolean<this, false>;\n }\n}\n\nexport type WithBoolean<T extends BooleanSchema, Y = boolean> = T & { validation_boolean: Y };\nexport type ExtractFromBoolean<T> = T extends WithBoolean<BooleanSchema, infer Y> ? Y : never;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ctxSymbol
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XZTZC73V.mjs";
|
|
4
4
|
|
|
5
5
|
// src/schemas/CommonSchema.ts
|
|
6
6
|
var CommonSchema = class {
|
|
@@ -28,7 +28,7 @@ var CommonSchema = class {
|
|
|
28
28
|
/**
|
|
29
29
|
* Marks the schema as optional, allowing the value to be `undefined`.
|
|
30
30
|
*
|
|
31
|
-
* @returns {WithUndefined<this>}
|
|
31
|
+
* @returns {WithUndefined<this>} The schema instance marked as optional.
|
|
32
32
|
*/
|
|
33
33
|
optional() {
|
|
34
34
|
this[ctxSymbol].isOptional = true;
|
|
@@ -39,4 +39,4 @@ var CommonSchema = class {
|
|
|
39
39
|
export {
|
|
40
40
|
CommonSchema
|
|
41
41
|
};
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
42
|
+
//# sourceMappingURL=chunk-4UF67IQ2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/CommonSchema.ts"],"sourcesContent":["import { PrimitiveType, RequiredValidation } from '../commonTypes';\nimport { ctxSymbol } from '../helpers/core';\n\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport interface ValidatorContext {\n type: PrimitiveType[];\n isNullable?: boolean;\n isOptional?: boolean;\n requiredValidations: RequiredValidation[];\n array?: CommonSchema;\n object?: ObjectShapeSchemaType;\n allowUnrecognizedObjectProps?: boolean;\n strictType?: boolean;\n strictTypeValue?: unknown;\n date?: boolean;\n}\n\nexport class CommonSchema {\n [ctxSymbol]: ValidatorContext;\n constructor(ctx: ValidatorContext) {\n this[ctxSymbol] = ctx;\n }\n\n /**\n * @param validators - One or more custom validation functions.\n * @returns {this} The schema instance with the added custom validation.\n */\n custom(...validators: RequiredValidation[]): this {\n this[ctxSymbol].requiredValidations.push(...validators);\n return this;\n }\n\n /**\n * Marks the schema as nullable, allowing the value to be `null`.\n *\n * @returns {WithNull<this>} The schema instance marked as nullable.\n */\n nullable(): WithNull<this> {\n this[ctxSymbol].isNullable = true;\n return this as WithNull<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {WithUndefined<this>} The schema instance marked as optional.\n */\n optional(): WithUndefined<this> {\n this[ctxSymbol].isOptional = true;\n return this as WithUndefined<this>;\n }\n}\n\nexport type WithNull<T extends CommonSchema> = T & { validation_null: true };\nexport type WithUndefined<T extends CommonSchema> = T & { validation_undefined: true };\n\ntype TypeMapping = {\n number: number;\n string: string;\n boolean: boolean;\n undefined: undefined;\n object: object;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n function: Function;\n symbol: symbol;\n bigint: bigint;\n};\n\nexport type WithMix<Y = unknown> = CommonSchema & { validation_mix: Y };\nexport type ExtractFromMix<T> = T extends WithMix<infer X> ? X : never;\n\nexport type MapMixTypes<T extends PrimitiveType[]> = T extends (infer U)[]\n ? U extends keyof TypeMapping\n ? TypeMapping[U]\n : never\n : never;\n"],"mappings":";;;;;AAkBO,IAAM,eAAN,MAAmB;AAAA,EACxB,CAAC,SAAS;AAAA,EACV,YAAY,KAAuB;AACjC,SAAK,SAAS,IAAI;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,YAAwC;AAChD,SAAK,SAAS,EAAE,oBAAoB,KAAK,GAAG,UAAU;AACtD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAA2B;AACzB,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAgC;AAC9B,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ctxSymbol
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XZTZC73V.mjs";
|
|
4
4
|
|
|
5
5
|
// src/helpers/setStrictType.ts
|
|
6
6
|
function _setStrictType(that, val) {
|
|
@@ -11,4 +11,4 @@ function _setStrictType(that, val) {
|
|
|
11
11
|
export {
|
|
12
12
|
_setStrictType
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=chunk-
|
|
14
|
+
//# sourceMappingURL=chunk-54RHVQFA.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
innerCheck
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XZTZC73V.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getTranslationByLocale
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QV4JDW3T.mjs";
|
|
7
7
|
import {
|
|
8
8
|
ValidationError
|
|
9
9
|
} from "./chunk-7XFLH6R2.mjs";
|
|
@@ -44,4 +44,4 @@ function parse(schema, receivedValue, options) {
|
|
|
44
44
|
export {
|
|
45
45
|
parse
|
|
46
46
|
};
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-5AO66YV5.mjs.map
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk4SPM2CSQjs = require('./chunk-4SPM2CSQ.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkWPHJ4QTBjs = require('./chunk-WPHJ4QTB.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkLWAEUS2Fjs = require('./chunk-LWAEUS2F.js');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _chunkEQNVYAKSjs = require('./chunk-EQNVYAKS.js');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
|
|
13
19
|
|
|
14
20
|
// src/schemas/NumberSchema.ts
|
|
15
|
-
var NumberSchema = (_class = class extends
|
|
21
|
+
var NumberSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
|
|
16
22
|
__init() {this._number = 1}
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
* Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
|
|
19
26
|
*
|
|
@@ -23,8 +30,10 @@ var NumberSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
|
|
|
23
30
|
* @example - number().equalTo(42); // Infers the type 42
|
|
24
31
|
*/
|
|
25
32
|
equalTo(expectedValue) {
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
34
|
+
this.limit = true;
|
|
35
|
+
_chunkLWAEUS2Fjs._setStrictType.call(void 0, this, expectedValue);
|
|
36
|
+
return this.custom(_chunkWPHJ4QTBjs.equalTo.call(void 0, expectedValue));
|
|
28
37
|
}
|
|
29
38
|
/**
|
|
30
39
|
* Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
|
|
@@ -36,12 +45,14 @@ var NumberSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constr
|
|
|
36
45
|
* number().oneOfValues([5, 7]); // Infers the type 5 | 7
|
|
37
46
|
*/
|
|
38
47
|
oneOfValues(expectedValue) {
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
|
|
49
|
+
this.limit = true;
|
|
50
|
+
_chunkLWAEUS2Fjs._setStrictType.call(void 0, this, expectedValue);
|
|
51
|
+
return this.custom(_chunk4SPM2CSQjs.oneOfValues.call(void 0, expectedValue));
|
|
41
52
|
}
|
|
42
53
|
}, _class);
|
|
43
54
|
|
|
44
55
|
|
|
45
56
|
|
|
46
57
|
exports.NumberSchema = NumberSchema;
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-5EIBKBYS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-5EIBKBYS.js","../src/schemas/NumberSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACZO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADYA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-5EIBKBYS.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
+
var _chunk356HMXOPjs = require('./chunk-356HMXOP.js');
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
|
|
4
7
|
|
|
5
8
|
// src/helpers/core.ts
|
|
@@ -15,6 +18,9 @@ function innerCheck(schema, receivedValue, exCtx) {
|
|
|
15
18
|
if (!schemaData.isNullable) _chunkWK4O3HH4js.guardException.call(void 0, "Not null", receivedValue, exCtx, commonTmap["c:nullable"]);
|
|
16
19
|
return receivedValue;
|
|
17
20
|
}
|
|
21
|
+
if (schemaData.date) {
|
|
22
|
+
if (!_chunk356HMXOPjs.isValidDate.call(void 0, receivedValue)) _chunkWK4O3HH4js.guardException.call(void 0, "Date", receivedValue, exCtx, commonTmap["c:date"]);
|
|
23
|
+
}
|
|
18
24
|
if (schemaData.array) {
|
|
19
25
|
if (!Array.isArray(receivedValue)) return _chunkWK4O3HH4js.guardException.call(void 0, "Array", receivedValue, exCtx, commonTmap["c:array"]);
|
|
20
26
|
const schema2 = schemaData.array;
|
|
@@ -60,4 +66,4 @@ function innerCheck(schema, receivedValue, exCtx) {
|
|
|
60
66
|
|
|
61
67
|
|
|
62
68
|
exports.ctxSymbol = ctxSymbol; exports.innerCheck = innerCheck;
|
|
63
|
-
//# sourceMappingURL=chunk-
|
|
69
|
+
//# sourceMappingURL=chunk-7GIRQ5EA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-7GIRQ5EA.js","../src/helpers/core.ts"],"names":["schema"],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACPO,IAAM,UAAA,EAAY,MAAA,CAAO,eAAe,CAAA;AAOxC,SAAS,UAAA,CAAW,MAAA,EAAsB,aAAA,EAAwB,KAAA,EAAyB;AAChG,EAAA,MAAM,WAAA,EAAa,KAAA,CAAM,CAAA;AACzB,EAAA,MAAM,WAAA,EAAa,MAAA,CAAO,SAAS,CAAA;AACnC,EAAA,GAAA,CAAI,cAAA,IAAkB,KAAA,CAAA,EAAW;AAC/B,IAAA,GAAA,CAAI,CAAC,UAAA,CAAW,UAAA,EAAY,6CAAA,UAAe,EAAY,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,YAAY,CAAC,CAAA;AACrG,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,cAAA,IAAkB,IAAA,EAAM;AAC1B,IAAA,GAAA,CAAI,CAAC,UAAA,CAAW,UAAA,EAAY,6CAAA,UAAe,EAAY,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,YAAY,CAAC,CAAA;AACrG,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,UAAA,CAAW,IAAA,EAAM;AACnB,IAAA,GAAA,CAAI,CAAC,0CAAA,aAAyB,CAAA,EAAG,6CAAA,MAAe,EAAQ,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,QAAQ,CAAC,CAAA;AAAA,EACpG;AAEA,EAAA,GAAA,CAAI,UAAA,CAAW,KAAA,EAAO;AACpB,IAAA,GAAA,CAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,aAAa,CAAA,EAAG,OAAO,6CAAA,OAAe,EAAS,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,SAAS,CAAC,CAAA;AAC7G,IAAA,MAAMA,QAAAA,EAAS,UAAA,CAAW,KAAA;AAC1B,IAAA,MAAM,YAAA,EAAc,KAAA,CAAM,WAAA;AAC1B,IAAA,aAAA,CAAc,OAAA,CAAQ,CAAC,IAAA,EAAM,CAAA,EAAA,GAAM;AACjC,MAAA,UAAA,CAAWA,OAAAA,EAAQ,IAAA,EAAM,EAAE,GAAG,KAAA,EAAO,WAAA,EAAa,CAAA,EAAA;AACnD,IAAA;AAEM,IAAA;AACT,EAAA;AAEyB,EAAA;AAEF,EAAA;AACgC,IAAA;AACJ,IAAA;AAClB,IAAA;AAEe,IAAA;AACE,MAAA;AACH,QAAA;AACC,UAAA;AAC5C,MAAA;AACF,IAAA;AAE0B,IAAA;AACwB,IAAA;AAC8B,MAAA;AAChC,MAAA;AACd,QAAA;AACD,UAAA;AAC/B,MAAA;AAE0B,MAAA;AAC5B,IAAA;AAEO,IAAA;AACT,EAAA;AAE4B,EAAA;AACa,IAAA;AACa,MAAA;AACtD,EAAA;AAEwC,EAAA;AACC,IAAA;AACxC,EAAA;AAEM,EAAA;AACT;ADV0D;AACA;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-7GIRQ5EA.js","sourcesContent":[null,"export const ctxSymbol = Symbol('contextSymbol');\n\nimport { ExceptionContext } from '../commonTypes';\nimport { guardException } from '../exceptions';\nimport type { CommonSchema } from '../schemas/CommonSchema';\nimport { isValidDate } from './isValidDate';\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, exCtx: ExceptionContext) {\n const commonTmap = exCtx.t;\n const schemaData = schema[ctxSymbol];\n if (receivedValue === undefined) {\n if (!schemaData.isOptional) guardException('Required', receivedValue, exCtx, commonTmap['c:optional']);\n return receivedValue;\n }\n\n if (receivedValue === null) {\n if (!schemaData.isNullable) guardException('Not null', receivedValue, exCtx, commonTmap['c:nullable']);\n return receivedValue;\n }\n\n if (schemaData.date) {\n if (!isValidDate(receivedValue)) guardException('Date', receivedValue, exCtx, commonTmap['c:date']);\n }\n\n if (schemaData.array) {\n if (!Array.isArray(receivedValue)) return guardException('Array', receivedValue, exCtx, commonTmap['c:array']);\n const schema = schemaData.array;\n const pathToError = exCtx.pathToError;\n receivedValue.forEach((elem, i) => {\n innerCheck(schema, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });\n });\n\n return receivedValue;\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (schemaData.object) {\n if (typeOfVal !== 'object') guardException('Object', receivedValue, exCtx, commonTmap['c:objectType']);\n if (Array.isArray(receivedValue)) guardException('Object', receivedValue, exCtx, commonTmap['c:objectTypeAsArray']);\n const shapeSchema = schemaData.object;\n\n if (!schemaData.allowUnrecognizedObjectProps) {\n for (const keyPerReceivedValue of Object.keys(receivedValue)) {\n if (shapeSchema[keyPerReceivedValue] === undefined)\n guardException('Unrecognized property', keyPerReceivedValue, exCtx, commonTmap['c:unrecognizedProperty']);\n }\n }\n\n const pathToError = exCtx.pathToError;\n for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {\n const receivedObjectValuePropery = (receivedValue as Record<string, unknown>)[keyOfSchema];\n if (receivedObjectValuePropery === undefined) {\n if (!valueOfSchema[ctxSymbol].isOptional)\n guardException('Required', receivedObjectValuePropery, exCtx, commonTmap['c:requiredProperty']);\n }\n\n innerCheck(valueOfSchema, receivedObjectValuePropery, { ...exCtx, pathToError: `${pathToError}.${keyOfSchema}` });\n }\n\n return receivedValue;\n }\n\n if (schemaData.type.length) {\n if (!schemaData.type.includes(typeOfVal))\n guardException(schemaData.type, typeOfVal, exCtx, commonTmap['c:invalidType']);\n }\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\n return receivedValue;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/constants.ts"],"sourcesContent":["export const ONLY_ONCE =\n \"It is allowed to call either 'equalTo' or 'oneOfValues,' but only one of them, and only once.\";\n"],"mappings":";AAAO,IAAM,YACX;","names":[]}
|
|
@@ -13,7 +13,8 @@ var defaultErrorMap = {
|
|
|
13
13
|
"c:unrecognizedProperty": "This property is not allowed in the object",
|
|
14
14
|
"c:requiredProperty": "Missing required property in the object",
|
|
15
15
|
"c:invalidType": "Invalid type of data",
|
|
16
|
-
"c:isBoolean": "The received value is not {{e}}"
|
|
16
|
+
"c:isBoolean": "The received value is not {{e}}",
|
|
17
|
+
"c:date": "The received value is not a valid instance of Date"
|
|
17
18
|
//@@end
|
|
18
19
|
};
|
|
19
20
|
var data = {
|
|
@@ -51,4 +52,4 @@ function getTranslationByLocale(lng) {
|
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
exports.setToDefaultLocale = setToDefaultLocale; exports.setLocale = setLocale; exports.clearLocales = clearLocales; exports.getTranslationByLocale = getTranslationByLocale;
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-CQWI6YRI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-CQWI6YRI.js","../src/translationMap.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACAA,IAAM,gBAAA,EAAuC;AAAA;AAAA,EAE3C,YAAA,EAAc,+BAAA;AAAA,EACd,YAAA,EAAc,0BAAA;AAAA,EACd,SAAA,EAAW,iDAAA;AAAA,EACX,cAAA,EAAgB,kDAAA;AAAA,EAChB,qBAAA,EAAuB,gEAAA;AAAA,EACvB,wBAAA,EAA0B,4CAAA;AAAA,EAC1B,oBAAA,EAAsB,yCAAA;AAAA,EACtB,eAAA,EAAiB,sBAAA;AAAA,EACjB,aAAA,EAAe,iCAAA;AAAA,EACf,QAAA,EAAU;AAAA;AAEZ,CAAA;AAEA,IAAI,KAAA,EAA+C;AAAA,EACjD,OAAA,EAAS,EAAE,GAAG,gBAAgB;AAChC,CAAA;AAEO,SAAS,kBAAA,CAAmB;AAAA,EACjC,GAAA;AAAA,EACA;AACF,CAAA,EAKG;AACD,EAAA,MAAM,cAAA,EAAgB,IAAA,CAAK,OAAA;AAC3B,EAAA,GAAA,CAAI,aAAA,CAAc,GAAG,CAAA,EAAG,MAAM,IAAI,sCAAA,CAAiB,+BAA+B,CAAA;AAClF,EAAA,aAAA,CAAc,GAAG,EAAA,EAAI,OAAA;AACvB;AAEO,SAAS,SAAA,CAAU,GAAA,EAAa,MAAA,EAAsC;AAC3E,EAAA,GAAA,CAAI,IAAA,IAAQ,SAAA,EAAW,MAAM,IAAI,sCAAA,CAAiB,kBAAkB,CAAA;AACpE,EAAA,GAAA,CAAI,CAAC,IAAA,CAAK,GAAG,CAAA,EAAG,IAAA,CAAK,GAAG,EAAA,EAAI,EAAE,GAAG,gBAAgB,CAAA;AACjD,EAAA,MAAM,OAAA,EAAS,IAAA,CAAK,GAAG,CAAA;AACvB,EAAA,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAC,UAAA,EAAY,YAAY,CAAA,EAAA,GAAM;AAC7D,IAAA,MAAA,CAAO,UAAU,EAAA,EAAI,YAAA;AAAA,EACvB,CAAC,CAAA;AACH;AAEO,SAAS,YAAA,CAAA,EAAe;AAC7B,EAAA,KAAA,EAAO;AAAA,IACL,OAAA,EAAS,EAAE,GAAG,gBAAgB;AAAA,EAChC,CAAA;AACF;AAEO,SAAS,sBAAA,CAAuB,GAAA,EAAmC;AACxE,EAAA,GAAA,CAAI,CAAC,GAAA,EAAK,OAAO,IAAA,CAAK,SAAS,CAAA;AAC/B,EAAA,wBAAQ,IAAA,CAAK,GAAG,CAAA,UAAK,IAAA,CAAK,SAAS,GAAA;AACrC;ADRA;AACA;AACE;AACA;AACA;AACA;AACF,6KAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-CQWI6YRI.js","sourcesContent":[null,"import { BuildSchemaError } from './exceptions';\nimport { RequiredValidation, TranslationErrorMap } from './commonTypes';\n\n// c: stands for common\nconst defaultErrorMap: TranslationErrorMap = {\n //@@start\n 'c:optional': 'The required value is missing',\n 'c:nullable': 'Value should not be null',\n 'c:array': 'Expected an array but received a different type',\n 'c:objectType': 'Expected an object but received a different type',\n 'c:objectTypeAsArray': 'Expected an object but received an array. Invalid type of data',\n 'c:unrecognizedProperty': 'This property is not allowed in the object',\n 'c:requiredProperty': 'Missing required property in the object',\n 'c:invalidType': 'Invalid type of data',\n 'c:isBoolean': 'The received value is not {{e}}',\n 'c:date': 'The received value is not a valid instance of Date',\n //@@end\n};\n\nlet data: Record<string, Record<string, string>> = {\n default: { ...defaultErrorMap },\n};\n\nexport function setToDefaultLocale({\n key,\n message,\n}: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (expected: any): RequiredValidation;\n key: string;\n message: string;\n}) {\n const defaultLocale = data.default!;\n if (defaultLocale[key]) throw new BuildSchemaError('Duplicate default message key');\n defaultLocale[key] = message;\n}\n\nexport function setLocale(lng: string, custom: Partial<TranslationErrorMap>) {\n if (lng === 'default') throw new BuildSchemaError('Invalid language');\n if (!data[lng]) data[lng] = { ...defaultErrorMap };\n const locale = data[lng]!;\n Object.entries(custom).forEach(([messageKey, messageValue]) => {\n locale[messageKey] = messageValue!;\n });\n}\n\nexport function clearLocales() {\n data = {\n default: { ...defaultErrorMap },\n };\n}\n\nexport function getTranslationByLocale(lng?: string): TranslationErrorMap {\n if (!lng) return data['default'] as TranslationErrorMap;\n return (data[lng] ?? data['default']) as TranslationErrorMap;\n}\n"]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk7GIRQ5EAjs = require('./chunk-7GIRQ5EA.js');
|
|
4
4
|
|
|
5
5
|
// src/schemas/CommonSchema.ts
|
|
6
6
|
var CommonSchema = class {
|
|
7
7
|
|
|
8
8
|
constructor(ctx) {
|
|
9
|
-
this[
|
|
9
|
+
this[_chunk7GIRQ5EAjs.ctxSymbol] = ctx;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* @param validators - One or more custom validation functions.
|
|
13
13
|
* @returns {this} The schema instance with the added custom validation.
|
|
14
14
|
*/
|
|
15
15
|
custom(...validators) {
|
|
16
|
-
this[
|
|
16
|
+
this[_chunk7GIRQ5EAjs.ctxSymbol].requiredValidations.push(...validators);
|
|
17
17
|
return this;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
@@ -22,16 +22,16 @@ var CommonSchema = class {
|
|
|
22
22
|
* @returns {WithNull<this>} The schema instance marked as nullable.
|
|
23
23
|
*/
|
|
24
24
|
nullable() {
|
|
25
|
-
this[
|
|
25
|
+
this[_chunk7GIRQ5EAjs.ctxSymbol].isNullable = true;
|
|
26
26
|
return this;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Marks the schema as optional, allowing the value to be `undefined`.
|
|
30
30
|
*
|
|
31
|
-
* @returns {WithUndefined<this>}
|
|
31
|
+
* @returns {WithUndefined<this>} The schema instance marked as optional.
|
|
32
32
|
*/
|
|
33
33
|
optional() {
|
|
34
|
-
this[
|
|
34
|
+
this[_chunk7GIRQ5EAjs.ctxSymbol].isOptional = true;
|
|
35
35
|
return this;
|
|
36
36
|
}
|
|
37
37
|
};
|
|
@@ -39,4 +39,4 @@ var CommonSchema = class {
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
exports.CommonSchema = CommonSchema;
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
42
|
+
//# sourceMappingURL=chunk-EQNVYAKS.js.map
|