bguard 0.2.0 → 0.3.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 +562 -380
- package/lib/{CommonSchema-DJmQ3F_9.d.mts → CommonSchema-CiY7spmg.d.mts} +9 -1
- package/lib/{CommonSchema-9RtxTxdX.d.ts → CommonSchema-D9QVJBJe.d.ts} +9 -1
- package/lib/InferType.d.mts +1 -1
- package/lib/InferType.d.ts +1 -1
- package/lib/asserts/array/index.d.mts +1 -1
- package/lib/asserts/array/index.d.ts +1 -1
- package/lib/asserts/array/index.js +8 -6
- package/lib/asserts/array/index.js.map +1 -1
- package/lib/asserts/array/index.mjs +7 -5
- package/lib/asserts/array/index.mjs.map +1 -1
- package/lib/asserts/array/maxArrayLength.d.mts +22 -0
- package/lib/asserts/array/maxArrayLength.d.ts +22 -0
- package/lib/asserts/array/maxArrayLength.js +20 -0
- package/lib/asserts/array/maxArrayLength.js.map +1 -0
- package/lib/asserts/array/maxArrayLength.mjs +20 -0
- package/lib/asserts/array/maxArrayLength.mjs.map +1 -0
- package/lib/asserts/array/minArrayLength.d.mts +22 -0
- package/lib/asserts/array/minArrayLength.d.ts +22 -0
- package/lib/asserts/array/minArrayLength.js +20 -0
- package/lib/asserts/array/minArrayLength.js.map +1 -0
- package/lib/asserts/array/minArrayLength.mjs +20 -0
- package/lib/asserts/array/minArrayLength.mjs.map +1 -0
- package/lib/asserts/bigint/bigintMax.js +4 -4
- package/lib/asserts/bigint/bigintMax.mjs +2 -2
- package/lib/asserts/bigint/bigintMaxExcluded.js +4 -4
- package/lib/asserts/bigint/bigintMaxExcluded.mjs +2 -2
- package/lib/asserts/bigint/bigintMin.js +4 -4
- package/lib/asserts/bigint/bigintMin.mjs +2 -2
- package/lib/asserts/bigint/bigintMinExcluded.js +4 -4
- package/lib/asserts/bigint/bigintMinExcluded.mjs +2 -2
- package/lib/asserts/bigint/index.d.mts +1 -1
- package/lib/asserts/bigint/index.d.ts +1 -1
- package/lib/asserts/bigint/index.js +11 -10
- package/lib/asserts/bigint/index.js.map +1 -1
- package/lib/asserts/bigint/index.mjs +10 -9
- package/lib/asserts/bigint/index.mjs.map +1 -1
- package/lib/asserts/boolean/index.d.mts +1 -1
- package/lib/asserts/boolean/index.d.ts +1 -1
- package/lib/asserts/boolean/index.js +9 -7
- package/lib/asserts/boolean/index.js.map +1 -1
- package/lib/asserts/boolean/index.mjs +8 -6
- package/lib/asserts/boolean/index.mjs.map +1 -1
- package/lib/asserts/date/dateMax.js +6 -6
- package/lib/asserts/date/dateMax.js.map +1 -1
- package/lib/asserts/date/dateMax.mjs +5 -5
- package/lib/asserts/date/dateMax.mjs.map +1 -1
- package/lib/asserts/date/dateMin.js +6 -6
- package/lib/asserts/date/dateMin.js.map +1 -1
- package/lib/asserts/date/dateMin.mjs +5 -5
- package/lib/asserts/date/dateMin.mjs.map +1 -1
- package/lib/asserts/date/index.d.mts +1 -1
- package/lib/asserts/date/index.d.ts +1 -1
- package/lib/asserts/date/index.js +8 -6
- package/lib/asserts/date/index.js.map +1 -1
- package/lib/asserts/date/index.mjs +7 -5
- package/lib/asserts/date/index.mjs.map +1 -1
- package/lib/asserts/mix/equalTo.js +4 -4
- package/lib/asserts/mix/equalTo.mjs +3 -3
- package/lib/asserts/mix/index.d.mts +1 -1
- package/lib/asserts/mix/index.d.ts +1 -1
- package/lib/asserts/mix/index.js +7 -5
- package/lib/asserts/mix/index.js.map +1 -1
- package/lib/asserts/mix/index.mjs +6 -4
- package/lib/asserts/mix/index.mjs.map +1 -1
- package/lib/asserts/mix/oneOfValues.js +4 -4
- package/lib/asserts/mix/oneOfValues.mjs +3 -3
- package/lib/asserts/number/index.d.mts +1 -1
- package/lib/asserts/number/index.d.ts +1 -1
- package/lib/asserts/number/index.js +11 -10
- package/lib/asserts/number/index.js.map +1 -1
- package/lib/asserts/number/index.mjs +10 -9
- package/lib/asserts/number/index.mjs.map +1 -1
- package/lib/asserts/number/max.js +4 -4
- package/lib/asserts/number/max.mjs +2 -2
- package/lib/asserts/number/maxExcluded.js +4 -4
- package/lib/asserts/number/maxExcluded.mjs +2 -2
- package/lib/asserts/number/min.js +4 -4
- package/lib/asserts/number/min.mjs +2 -2
- package/lib/asserts/number/minExcluded.js +4 -4
- package/lib/asserts/number/minExcluded.mjs +2 -2
- package/lib/asserts/number/negative.js +4 -4
- package/lib/asserts/number/negative.mjs +2 -2
- package/lib/asserts/number/positive.js +4 -4
- package/lib/asserts/number/positive.mjs +2 -2
- package/lib/asserts/object/index.d.mts +1 -1
- package/lib/asserts/object/index.d.ts +1 -1
- package/lib/asserts/object/index.js +8 -6
- package/lib/asserts/object/index.js.map +1 -1
- package/lib/asserts/object/index.mjs +7 -5
- package/lib/asserts/object/index.mjs.map +1 -1
- package/lib/asserts/string/atLeastOneDigit.js +4 -4
- package/lib/asserts/string/atLeastOneDigit.mjs +2 -2
- package/lib/asserts/string/atLeastOneLowerChar.js +4 -4
- package/lib/asserts/string/atLeastOneLowerChar.mjs +2 -2
- package/lib/asserts/string/atLeastOneSpecialChar.js +4 -4
- package/lib/asserts/string/atLeastOneSpecialChar.mjs +2 -2
- package/lib/asserts/string/atLeastOneUpperChar.js +4 -4
- package/lib/asserts/string/atLeastOneUpperChar.mjs +2 -2
- package/lib/asserts/string/contains.js +4 -4
- package/lib/asserts/string/contains.mjs +2 -2
- package/lib/asserts/string/email.js +4 -4
- package/lib/asserts/string/email.mjs +2 -2
- package/lib/asserts/string/endsWith.js +4 -4
- package/lib/asserts/string/endsWith.mjs +2 -2
- package/lib/asserts/string/index.d.mts +1 -1
- package/lib/asserts/string/index.d.ts +1 -1
- package/lib/asserts/string/index.js +11 -10
- package/lib/asserts/string/index.js.map +1 -1
- package/lib/asserts/string/index.mjs +10 -9
- package/lib/asserts/string/index.mjs.map +1 -1
- package/lib/asserts/string/isValidDate.d.mts +21 -0
- package/lib/asserts/string/isValidDate.d.ts +21 -0
- package/lib/asserts/string/isValidDate.js +25 -0
- package/lib/asserts/string/isValidDate.js.map +1 -0
- package/lib/asserts/string/isValidDate.mjs +25 -0
- package/lib/asserts/string/isValidDate.mjs.map +1 -0
- package/lib/asserts/string/isValidDateTime.d.mts +35 -0
- package/lib/asserts/string/isValidDateTime.d.ts +35 -0
- package/lib/asserts/string/isValidDateTime.js +32 -0
- package/lib/asserts/string/isValidDateTime.js.map +1 -0
- package/lib/asserts/string/isValidDateTime.mjs +32 -0
- package/lib/asserts/string/isValidDateTime.mjs.map +1 -0
- package/lib/asserts/string/isValidTime.d.mts +29 -0
- package/lib/asserts/string/isValidTime.d.ts +29 -0
- package/lib/asserts/string/isValidTime.js +32 -0
- package/lib/asserts/string/isValidTime.js.map +1 -0
- package/lib/asserts/string/isValidTime.mjs +32 -0
- package/lib/asserts/string/isValidTime.mjs.map +1 -0
- package/lib/asserts/string/lowerCase.js +4 -4
- package/lib/asserts/string/lowerCase.mjs +2 -2
- package/lib/asserts/string/maxLength.js +4 -4
- package/lib/asserts/string/maxLength.mjs +2 -2
- package/lib/asserts/string/minLength.js +4 -4
- package/lib/asserts/string/minLength.mjs +2 -2
- package/lib/asserts/string/regExp.js +4 -4
- package/lib/asserts/string/regExp.mjs +2 -2
- package/lib/asserts/string/startsWith.js +4 -4
- package/lib/asserts/string/startsWith.mjs +2 -2
- package/lib/asserts/string/upperCase.js +4 -4
- package/lib/asserts/string/upperCase.mjs +2 -2
- package/lib/asserts/string/uuid.js +4 -4
- package/lib/asserts/string/uuid.mjs +2 -2
- package/lib/asserts/string/uuidV1.js +4 -4
- package/lib/asserts/string/uuidV1.mjs +2 -2
- package/lib/asserts/string/uuidV2.js +4 -4
- package/lib/asserts/string/uuidV2.mjs +2 -2
- package/lib/asserts/string/uuidV3.js +4 -4
- package/lib/asserts/string/uuidV3.mjs +2 -2
- package/lib/asserts/string/uuidV4.js +4 -4
- package/lib/asserts/string/uuidV4.mjs +2 -2
- package/lib/asserts/string/uuidV5.js +4 -4
- package/lib/asserts/string/uuidV5.mjs +2 -2
- package/lib/asserts/string/validUrl.js +4 -4
- package/lib/asserts/string/validUrl.mjs +2 -2
- package/lib/{chunk-32J4WVLE.js → chunk-2D5QE7F4.js} +17 -15
- package/lib/chunk-2D5QE7F4.js.map +1 -0
- package/lib/{chunk-XFR7Y4XX.mjs → chunk-2MFBOVP2.mjs} +3 -3
- package/lib/chunk-2MFBOVP2.mjs.map +1 -0
- package/lib/chunk-3IOQH3K4.js +74 -0
- package/lib/chunk-3IOQH3K4.js.map +1 -0
- package/lib/chunk-3ZPLJ5KC.js +14 -0
- package/lib/{chunk-LWAEUS2F.js.map → chunk-3ZPLJ5KC.js.map} +1 -1
- package/lib/{chunk-QV4JDW3T.mjs → chunk-4GDBM5LP.mjs} +2 -2
- package/lib/{chunk-PVOHKGBW.mjs → chunk-5HT3PYSG.mjs} +4 -4
- package/lib/chunk-5HT3PYSG.mjs.map +1 -0
- package/lib/{chunk-XZTZC73V.mjs → chunk-5LLJ22IG.mjs} +25 -17
- package/lib/chunk-5LLJ22IG.mjs.map +1 -0
- package/lib/{chunk-MRWZVTNH.mjs → chunk-ADSMWGDJ.mjs} +4 -4
- package/lib/{chunk-VGF3Y2EK.js → chunk-AN3VHQEQ.js} +7 -7
- package/lib/{chunk-VGF3Y2EK.js.map → chunk-AN3VHQEQ.js.map} +1 -1
- package/lib/chunk-AOUFWACR.mjs +74 -0
- package/lib/chunk-AOUFWACR.mjs.map +1 -0
- package/lib/{chunk-WK4O3HH4.js → chunk-AY7HKAG2.js} +2 -3
- package/lib/chunk-AY7HKAG2.js.map +1 -0
- package/lib/{chunk-M6OCVAUD.mjs → chunk-BUXOCPHI.mjs} +3 -3
- package/lib/{chunk-54RHVQFA.mjs → chunk-D42ISCFK.mjs} +2 -2
- package/lib/{chunk-5EIBKBYS.js → chunk-EU3ZZF7Y.js} +13 -13
- package/lib/chunk-EU3ZZF7Y.js.map +1 -0
- package/lib/{chunk-PEWNA24X.mjs → chunk-KBZUNXJB.mjs} +4 -4
- package/lib/chunk-KBZUNXJB.mjs.map +1 -0
- package/lib/chunk-LYNVPN3R.js +28 -0
- package/lib/chunk-LYNVPN3R.js.map +1 -0
- package/lib/{chunk-7XFLH6R2.mjs → chunk-NP64RC7B.mjs} +2 -3
- package/lib/chunk-NP64RC7B.mjs.map +1 -0
- package/lib/{chunk-YPAUFM3S.mjs → chunk-OHEMRF7Y.mjs} +3 -3
- package/lib/{chunk-QLVLZRHT.js → chunk-OJSTQQ3N.js} +5 -5
- package/lib/chunk-OJSTQQ3N.js.map +1 -0
- package/lib/{chunk-5AO66YV5.mjs → chunk-OKF3BVUD.mjs} +4 -4
- package/lib/{chunk-N6YMNLXG.js → chunk-OO6BTBVP.js} +11 -11
- package/lib/chunk-OO6BTBVP.js.map +1 -0
- package/lib/{chunk-SEIKS6G7.js → chunk-P6V6S6TZ.js} +19 -15
- package/lib/chunk-P6V6S6TZ.js.map +1 -0
- package/lib/{chunk-MTJJKWTP.js → chunk-PESVL5YJ.js} +7 -7
- package/lib/{chunk-MTJJKWTP.js.map → chunk-PESVL5YJ.js.map} +1 -1
- package/lib/{chunk-7GIRQ5EA.js → chunk-PIBDJJUU.js} +31 -23
- package/lib/chunk-PIBDJJUU.js.map +1 -0
- package/lib/{chunk-WPHJ4QTB.js → chunk-SPWF5IFU.js} +5 -5
- package/lib/{chunk-WPHJ4QTB.js.map → chunk-SPWF5IFU.js.map} +1 -1
- package/lib/{chunk-Z7OEFOAD.mjs → chunk-TQWUSDQD.mjs} +8 -8
- package/lib/chunk-TQWUSDQD.mjs.map +1 -0
- package/lib/{chunk-CQWI6YRI.js → chunk-UZ2PWO4O.js} +4 -4
- package/lib/{chunk-CQWI6YRI.js.map → chunk-UZ2PWO4O.js.map} +1 -1
- package/lib/{chunk-356HMXOP.js → chunk-VBTWYDEM.js} +4 -4
- package/lib/chunk-VBTWYDEM.js.map +1 -0
- package/lib/{chunk-4SPM2CSQ.js → chunk-W2GOLG3K.js} +5 -5
- package/lib/{chunk-4SPM2CSQ.js.map → chunk-W2GOLG3K.js.map} +1 -1
- package/lib/{chunk-GDSB7CDN.mjs → chunk-YBVMP4EI.mjs} +4 -4
- package/lib/chunk-YBVMP4EI.mjs.map +1 -0
- package/lib/{chunk-PJI3DRGP.mjs → chunk-YPAFWVDL.mjs} +4 -4
- package/lib/chunk-YPAFWVDL.mjs.map +1 -0
- package/lib/{chunk-UV4I7JZR.mjs → chunk-ZMEQCIRN.mjs} +16 -12
- package/lib/chunk-ZMEQCIRN.mjs.map +1 -0
- package/lib/{chunk-4SR7J2I4.js → chunk-ZVW3IHBW.js} +8 -8
- package/lib/chunk-ZVW3IHBW.js.map +1 -0
- package/lib/{chunk-TP5I237J.mjs → chunk-ZWE5Q37U.mjs} +14 -12
- package/lib/chunk-ZWE5Q37U.mjs.map +1 -0
- package/lib/codeGen.d.mts +1 -1
- package/lib/codeGen.d.ts +1 -1
- package/lib/codeGen.js +4 -4
- package/lib/codeGen.mjs +3 -3
- package/lib/exceptions.js +2 -2
- package/lib/exceptions.mjs +1 -1
- package/lib/helpers/core.d.mts +1 -1
- package/lib/helpers/core.d.ts +1 -1
- package/lib/helpers/core.js +4 -4
- package/lib/helpers/core.mjs +3 -3
- package/lib/helpers/isValidDateInner.d.mts +3 -0
- package/lib/helpers/isValidDateInner.d.ts +3 -0
- package/lib/helpers/isValidDateInner.js +7 -0
- package/lib/helpers/isValidDateInner.js.map +1 -0
- package/lib/helpers/isValidDateInner.mjs +7 -0
- package/lib/helpers/setStrictType.d.mts +1 -1
- package/lib/helpers/setStrictType.d.ts +1 -1
- package/lib/helpers/setStrictType.js +5 -5
- package/lib/helpers/setStrictType.mjs +4 -4
- package/lib/index.d.mts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +7 -7
- package/lib/index.mjs +6 -6
- package/lib/parse.d.mts +1 -1
- package/lib/parse.d.ts +1 -1
- package/lib/parse.js +6 -6
- package/lib/parse.mjs +5 -5
- package/lib/parseOrFail.d.mts +1 -1
- package/lib/parseOrFail.d.ts +1 -1
- package/lib/parseOrFail.js +6 -6
- package/lib/parseOrFail.mjs +5 -5
- package/lib/schemas/ArraySchema.d.mts +2 -2
- package/lib/schemas/ArraySchema.d.ts +2 -2
- package/lib/schemas/ArraySchema.js +8 -6
- package/lib/schemas/ArraySchema.js.map +1 -1
- package/lib/schemas/ArraySchema.mjs +7 -5
- package/lib/schemas/BigIntSchema.d.mts +3 -2
- package/lib/schemas/BigIntSchema.d.ts +3 -2
- package/lib/schemas/BigIntSchema.js +11 -10
- package/lib/schemas/BigIntSchema.js.map +1 -1
- package/lib/schemas/BigIntSchema.mjs +10 -9
- package/lib/schemas/BooleanSchema.d.mts +2 -2
- package/lib/schemas/BooleanSchema.d.ts +2 -2
- package/lib/schemas/BooleanSchema.js +9 -7
- package/lib/schemas/BooleanSchema.js.map +1 -1
- package/lib/schemas/BooleanSchema.mjs +8 -6
- package/lib/schemas/CommonSchema.d.mts +1 -1
- package/lib/schemas/CommonSchema.d.ts +1 -1
- package/lib/schemas/CommonSchema.js +7 -5
- package/lib/schemas/CommonSchema.js.map +1 -1
- package/lib/schemas/CommonSchema.mjs +6 -4
- package/lib/schemas/DateSchema.d.mts +2 -2
- package/lib/schemas/DateSchema.d.ts +2 -2
- package/lib/schemas/DateSchema.js +8 -6
- package/lib/schemas/DateSchema.js.map +1 -1
- package/lib/schemas/DateSchema.mjs +7 -5
- package/lib/schemas/NumberSchema.d.mts +2 -2
- package/lib/schemas/NumberSchema.d.ts +2 -2
- package/lib/schemas/NumberSchema.js +11 -10
- package/lib/schemas/NumberSchema.js.map +1 -1
- package/lib/schemas/NumberSchema.mjs +10 -9
- package/lib/schemas/ObjectSchema.d.mts +2 -2
- package/lib/schemas/ObjectSchema.d.ts +2 -2
- package/lib/schemas/ObjectSchema.js +8 -6
- package/lib/schemas/ObjectSchema.js.map +1 -1
- package/lib/schemas/ObjectSchema.mjs +7 -5
- package/lib/schemas/StringSchema.d.mts +3 -2
- package/lib/schemas/StringSchema.d.ts +3 -2
- package/lib/schemas/StringSchema.js +11 -10
- package/lib/schemas/StringSchema.js.map +1 -1
- package/lib/schemas/StringSchema.mjs +10 -9
- package/lib/translationMap.js +3 -3
- package/lib/translationMap.mjs +2 -2
- package/package.json +1 -1
- package/lib/chunk-2OINKFOA.js +0 -28
- package/lib/chunk-2OINKFOA.js.map +0 -1
- package/lib/chunk-32J4WVLE.js.map +0 -1
- package/lib/chunk-356HMXOP.js.map +0 -1
- package/lib/chunk-4SR7J2I4.js.map +0 -1
- package/lib/chunk-4UF67IQ2.mjs +0 -42
- package/lib/chunk-4UF67IQ2.mjs.map +0 -1
- package/lib/chunk-5EIBKBYS.js.map +0 -1
- package/lib/chunk-7GIRQ5EA.js.map +0 -1
- package/lib/chunk-7XFLH6R2.mjs.map +0 -1
- package/lib/chunk-EQNVYAKS.js +0 -42
- package/lib/chunk-EQNVYAKS.js.map +0 -1
- package/lib/chunk-GDSB7CDN.mjs.map +0 -1
- package/lib/chunk-LWAEUS2F.js +0 -14
- package/lib/chunk-N6YMNLXG.js.map +0 -1
- package/lib/chunk-PEWNA24X.mjs.map +0 -1
- package/lib/chunk-PJI3DRGP.mjs.map +0 -1
- package/lib/chunk-PVOHKGBW.mjs.map +0 -1
- package/lib/chunk-QLVLZRHT.js.map +0 -1
- package/lib/chunk-SEIKS6G7.js.map +0 -1
- package/lib/chunk-TP5I237J.mjs.map +0 -1
- package/lib/chunk-UV4I7JZR.mjs.map +0 -1
- package/lib/chunk-WK4O3HH4.js.map +0 -1
- package/lib/chunk-XFR7Y4XX.mjs.map +0 -1
- package/lib/chunk-XZTZC73V.mjs.map +0 -1
- package/lib/chunk-Z7OEFOAD.mjs.map +0 -1
- package/lib/helpers/isValidDate.d.mts +0 -3
- package/lib/helpers/isValidDate.d.ts +0 -3
- package/lib/helpers/isValidDate.js +0 -7
- package/lib/helpers/isValidDate.js.map +0 -1
- package/lib/helpers/isValidDate.mjs +0 -7
- /package/lib/{chunk-QV4JDW3T.mjs.map → chunk-4GDBM5LP.mjs.map} +0 -0
- /package/lib/{chunk-MRWZVTNH.mjs.map → chunk-ADSMWGDJ.mjs.map} +0 -0
- /package/lib/{chunk-M6OCVAUD.mjs.map → chunk-BUXOCPHI.mjs.map} +0 -0
- /package/lib/{chunk-54RHVQFA.mjs.map → chunk-D42ISCFK.mjs.map} +0 -0
- /package/lib/{chunk-YPAUFM3S.mjs.map → chunk-OHEMRF7Y.mjs.map} +0 -0
- /package/lib/{chunk-5AO66YV5.mjs.map → chunk-OKF3BVUD.mjs.map} +0 -0
- /package/lib/helpers/{isValidDate.mjs.map → isValidDateInner.mjs.map} +0 -0
package/lib/chunk-4UF67IQ2.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ctxSymbol
|
|
3
|
-
} from "./chunk-XZTZC73V.mjs";
|
|
4
|
-
|
|
5
|
-
// src/schemas/CommonSchema.ts
|
|
6
|
-
var CommonSchema = class {
|
|
7
|
-
[ctxSymbol];
|
|
8
|
-
constructor(ctx) {
|
|
9
|
-
this[ctxSymbol] = ctx;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @param validators - One or more custom validation functions.
|
|
13
|
-
* @returns {this} The schema instance with the added custom validation.
|
|
14
|
-
*/
|
|
15
|
-
custom(...validators) {
|
|
16
|
-
this[ctxSymbol].requiredValidations.push(...validators);
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Marks the schema as nullable, allowing the value to be `null`.
|
|
21
|
-
*
|
|
22
|
-
* @returns {WithNull<this>} The schema instance marked as nullable.
|
|
23
|
-
*/
|
|
24
|
-
nullable() {
|
|
25
|
-
this[ctxSymbol].isNullable = true;
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Marks the schema as optional, allowing the value to be `undefined`.
|
|
30
|
-
*
|
|
31
|
-
* @returns {WithUndefined<this>} The schema instance marked as optional.
|
|
32
|
-
*/
|
|
33
|
-
optional() {
|
|
34
|
-
this[ctxSymbol].isOptional = true;
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
CommonSchema
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=chunk-4UF67IQ2.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/exceptions.ts"],"sourcesContent":["import type { ExceptionContext } from './commonTypes';\n\nexport class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nfunction replacePlaceholders(template: string, replacements: Record<string, unknown>): string {\n const regex = /{{(.*?)}}/g;\n return template.replace(regex, (_, key) => {\n const vvv = key in replacements ? `${replacements[key] as string}` : `{{${key}}}`;\n return vvv;\n });\n}\n\nexport function guardException(\n expected: unknown,\n received: unknown,\n ctx: ExceptionContext,\n messageKey: string,\n): never | void {\n const rawMessage = ctx.t[messageKey] ?? messageKey;\n const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: ctx.pathToError });\n\n if (ctx.getAllErrors) {\n ctx.errors.push({\n expected,\n received,\n pathToError: ctx.pathToError,\n message,\n });\n\n return;\n }\n throw new ValidationError(expected, received, ctx.pathToError, message);\n}\n"],"mappings":";AAEO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAEO,IAAM,mBAAN,cAA+B,MAAM;AAAC;AAE7C,SAAS,oBAAoB,UAAkB,cAA+C;AAC5F,QAAM,QAAQ;AACd,SAAO,SAAS,QAAQ,OAAO,CAAC,GAAG,QAAQ;AACzC,UAAM,MAAM,OAAO,eAAe,GAAG,aAAa,GAAG,CAAW,KAAK,KAAK,GAAG;AAC7E,WAAO;AAAA,EACT,CAAC;AACH;AAEO,SAAS,eACd,UACA,UACA,KACA,YACc;AACd,QAAM,aAAa,IAAI,EAAE,UAAU,KAAK;AACxC,QAAM,UAAU,oBAAoB,YAAY,EAAE,GAAG,UAAU,GAAG,UAAU,GAAG,IAAI,YAAY,CAAC;AAEhG,MAAI,IAAI,cAAc;AACpB,QAAI,OAAO,KAAK;AAAA,MACd;AAAA,MACA;AAAA,MACA,aAAa,IAAI;AAAA,MACjB;AAAA,IACF,CAAC;AAED;AAAA,EACF;AACA,QAAM,IAAI,gBAAgB,UAAU,UAAU,IAAI,aAAa,OAAO;AACxE;","names":[]}
|
package/lib/chunk-EQNVYAKS.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunk7GIRQ5EAjs = require('./chunk-7GIRQ5EA.js');
|
|
4
|
-
|
|
5
|
-
// src/schemas/CommonSchema.ts
|
|
6
|
-
var CommonSchema = class {
|
|
7
|
-
|
|
8
|
-
constructor(ctx) {
|
|
9
|
-
this[_chunk7GIRQ5EAjs.ctxSymbol] = ctx;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* @param validators - One or more custom validation functions.
|
|
13
|
-
* @returns {this} The schema instance with the added custom validation.
|
|
14
|
-
*/
|
|
15
|
-
custom(...validators) {
|
|
16
|
-
this[_chunk7GIRQ5EAjs.ctxSymbol].requiredValidations.push(...validators);
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Marks the schema as nullable, allowing the value to be `null`.
|
|
21
|
-
*
|
|
22
|
-
* @returns {WithNull<this>} The schema instance marked as nullable.
|
|
23
|
-
*/
|
|
24
|
-
nullable() {
|
|
25
|
-
this[_chunk7GIRQ5EAjs.ctxSymbol].isNullable = true;
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Marks the schema as optional, allowing the value to be `undefined`.
|
|
30
|
-
*
|
|
31
|
-
* @returns {WithUndefined<this>} The schema instance marked as optional.
|
|
32
|
-
*/
|
|
33
|
-
optional() {
|
|
34
|
-
this[_chunk7GIRQ5EAjs.ctxSymbol].isOptional = true;
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
exports.CommonSchema = CommonSchema;
|
|
42
|
-
//# sourceMappingURL=chunk-EQNVYAKS.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-EQNVYAKS.js","../src/schemas/CommonSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACcO,IAAM,aAAA,EAAN,MAAmB;AAAA,EACxB;AAAU,EACV,WAAA,CAAY,GAAA,EAAuB;AACjC,IAAA,IAAA,CAAK,0BAAS,EAAA,EAAI,GAAA;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAA,CAAA,GAAU,UAAA,EAAwC;AAChD,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,mBAAA,CAAoB,IAAA,CAAK,GAAG,UAAU,CAAA;AACtD,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAA,CAAA,EAA2B;AACzB,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAA,CAAA,EAAgC;AAC9B,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AACF,CAAA;ADfA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-EQNVYAKS.js","sourcesContent":[null,"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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helpers/isValidDate.ts"],"sourcesContent":["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"],"mappings":";AAAO,SAAS,YAAY,GAAY;AACtC;AAAA;AAAA,IAEE,OAAO,UAAU,SAAS,KAAK,CAAC,MAAM,mBAAmB,CAAC,MAAM,OAAO,GAAG,YAAY,cAAc,EAAE,QAAQ,CAAC;AAAA;AAEnH;","names":[]}
|
package/lib/chunk-LWAEUS2F.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunk7GIRQ5EAjs = require('./chunk-7GIRQ5EA.js');
|
|
4
|
-
|
|
5
|
-
// src/helpers/setStrictType.ts
|
|
6
|
-
function _setStrictType(that, val) {
|
|
7
|
-
that[_chunk7GIRQ5EAjs.ctxSymbol].strictType = true;
|
|
8
|
-
that[_chunk7GIRQ5EAjs.ctxSymbol].strictTypeValue = val;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports._setStrictType = _setStrictType;
|
|
14
|
-
//# sourceMappingURL=chunk-LWAEUS2F.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-N6YMNLXG.js","../src/schemas/ObjectSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACV,WAAA,CAAY,GAAA,EAAuB,WAAA,EAAoC;AACrE,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,mBAAA,CAAoB,WAAW,CAAA;AACpC,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,OAAA,EAAS,WAAA;AAAA,EAC3B;AAAA,EAEQ,mBAAA,CAAoB,WAAA,EAAoC;AAC9D,IAAA,GAAA,CAAI,CAAC,WAAA,EAAa,MAAM,IAAI,sCAAA,CAAiB,iCAAiC,CAAA;AAC9E,IAAA,GAAA,CAAI,YAAA,WAAuB,6BAAA,EAAc,MAAM,IAAI,sCAAA,CAAiB,0BAA0B,CAAA;AAC9F,IAAA,IAAA,CAAA,MAAW,CAAC,GAAA,EAAK,KAAK,EAAA,GAAK,MAAA,CAAO,OAAA,CAAQ,WAAW,CAAA,EAAG;AACtD,MAAA,GAAA,CAAI,CAAA,CAAE,MAAA,WAAiB,6BAAA,CAAA;AACrB,QAAA,MAAM,IAAI,sCAAA,CAAiB,CAAA,8CAAA,EAAiD,GAAG,CAAA,CAAA,CAAG,CAAA;AAAA,IACtF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBO,iBAAA,CAAA,EAA0B;AAC/B,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,6BAAA,EAA+B,IAAA;AAC/C,IAAA,OAAO,IAAA;AAAA,EACT;AACF,UAAA;ADMA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-N6YMNLXG.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ObjectShapeSchemaType, ValidatorContext } from './CommonSchema';\n\nexport class ObjectSchema extends CommonSchema {\n _object = 1;\n constructor(ctx: ValidatorContext, shapeSchema: ObjectShapeSchemaType) {\n super(ctx);\n this.validateObjectEntry(shapeSchema);\n this[ctxSymbol].object = shapeSchema;\n }\n\n private validateObjectEntry(shapeSchema: ObjectShapeSchemaType) {\n if (!shapeSchema) throw new BuildSchemaError('Missing schema in object method');\n if (shapeSchema instanceof CommonSchema) throw new BuildSchemaError('Invalid schema in object');\n for (const [key, value] of Object.entries(shapeSchema)) {\n if (!(value instanceof CommonSchema))\n throw new BuildSchemaError(`Invalid schema in object method for property '${key}'`);\n }\n }\n\n /**\n * Allows unrecognized properties in the validated object.\n * When this method is called, the validation will not fail\n * if the received object contains properties not specified\n * in the validation schema.\n *\n * @returns {this} The current ObjectSchema instance.\n *\n * @example\n * const userSchema = object({\n * name: string(),\n * age: number(),\n * }).allowUnrecognized();\n *\n * parseOrFail(userSchema, ({ name: 'John', age: 30, extra: 'value' }););\n * // No error thrown\n */\n public allowUnrecognized(): this {\n this[ctxSymbol].allowUnrecognizedObjectProps = true;\n return this;\n }\n}\n\nexport type WithObject<Y extends ObjectShapeSchemaType> = ObjectSchema & { validation_object: Y };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/ArraySchema.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;AAIO,IAAM,cAAN,cAA0B,aAAa;AAAA,EAC5C,SAAS;AAAA,EACT,YAAY,KAAuB,aAA2B;AAC5D,UAAM,GAAG;AACT,SAAK,mBAAmB,WAAW;AACnC,SAAK,SAAS,EAAE,QAAQ;AAAA,EAC1B;AAAA,EAEQ,mBAAmB,aAA2B;AACpD,QAAI,CAAC,YAAa,OAAM,IAAI,iBAAiB,gCAAgC;AAC7E,QAAI,EAAE,uBAAuB,cAAe,OAAM,IAAI,iBAAiB,gCAAgC;AAAA,EACzG;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/BooleanSchema.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;AAKA,IAAM,YAAY,CAAC,aAAsB,CAAC,UAAmB,QAA0B;AACrF,MAAI,aAAa,SAAU,gBAAe,UAAU,UAAU,KAAK,aAAa;AAClF;AAEO,IAAM,gBAAN,cAA4B,aAAa;AAAA,EAC9C,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASX,WAAoC;AAClC,mBAAe,MAAM,IAAI;AACzB,WAAO,KAAK,OAAO,UAAU,IAAI,CAAC;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,YAAsC;AACpC,mBAAe,MAAM,KAAK;AAC1B,WAAO,KAAK,OAAO,UAAU,KAAK,CAAC;AAAA,EACrC;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/ObjectSchema.ts"],"sourcesContent":["import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ObjectShapeSchemaType, ValidatorContext } from './CommonSchema';\n\nexport class ObjectSchema extends CommonSchema {\n _object = 1;\n constructor(ctx: ValidatorContext, shapeSchema: ObjectShapeSchemaType) {\n super(ctx);\n this.validateObjectEntry(shapeSchema);\n this[ctxSymbol].object = shapeSchema;\n }\n\n private validateObjectEntry(shapeSchema: ObjectShapeSchemaType) {\n if (!shapeSchema) throw new BuildSchemaError('Missing schema in object method');\n if (shapeSchema instanceof CommonSchema) throw new BuildSchemaError('Invalid schema in object');\n for (const [key, value] of Object.entries(shapeSchema)) {\n if (!(value instanceof CommonSchema))\n throw new BuildSchemaError(`Invalid schema in object method for property '${key}'`);\n }\n }\n\n /**\n * Allows unrecognized properties in the validated object.\n * When this method is called, the validation will not fail\n * if the received object contains properties not specified\n * in the validation schema.\n *\n * @returns {this} The current ObjectSchema instance.\n *\n * @example\n * const userSchema = object({\n * name: string(),\n * age: number(),\n * }).allowUnrecognized();\n *\n * parseOrFail(userSchema, ({ name: 'John', age: 30, extra: 'value' }););\n * // No error thrown\n */\n public allowUnrecognized(): this {\n this[ctxSymbol].allowUnrecognizedObjectProps = true;\n return this;\n }\n}\n\nexport type WithObject<Y extends ObjectShapeSchemaType> = ObjectSchema & { validation_object: Y };\n"],"mappings":";;;;;;;;;;;AAIO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACV,YAAY,KAAuB,aAAoC;AACrE,UAAM,GAAG;AACT,SAAK,oBAAoB,WAAW;AACpC,SAAK,SAAS,EAAE,SAAS;AAAA,EAC3B;AAAA,EAEQ,oBAAoB,aAAoC;AAC9D,QAAI,CAAC,YAAa,OAAM,IAAI,iBAAiB,iCAAiC;AAC9E,QAAI,uBAAuB,aAAc,OAAM,IAAI,iBAAiB,0BAA0B;AAC9F,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,GAAG;AACtD,UAAI,EAAE,iBAAiB;AACrB,cAAM,IAAI,iBAAiB,iDAAiD,GAAG,GAAG;AAAA,IACtF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBO,oBAA0B;AAC/B,SAAK,SAAS,EAAE,+BAA+B;AAC/C,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-QLVLZRHT.js","../src/schemas/DateSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACJO,IAAM,WAAA,YAAN,MAAA,QAAyB,8BAAa;AAAA,iBAC3C,MAAA,EAAQ,EAAA;AAAA,EAER,WAAA,CAAY,GAAA,EAAuB;AACjC,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,KAAA,EAAO,IAAA;AAAA,EACzB;AACF,UAAA;ADKA;AACA;AACE;AACF,gCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-QLVLZRHT.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class DateSchema extends CommonSchema {\n _date = 1;\n\n constructor(ctx: ValidatorContext) {\n super(ctx);\n this[ctxSymbol].date = true;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-SEIKS6G7.js","../src/schemas/BigIntSchema.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,EAAA;AACF,IAAA;AACrB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAW8B,EAAA;AACN,IAAA;AACT,IAAA;AACb,IAAA;AACE,MAAA;AACmB,MAAA;AACrB,IAAA;AACmB,IAAA;AACrB,EAAA;AACF;ADY0B;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-SEIKS6G7.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 BigIntSchema extends CommonSchema {\n _bigint = 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 - bigint().equalTo(42n); // Infers the type 42n\n */\n equalTo<Y extends bigint>(expectedValue: Y): WithBigInt<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 WithBigInt<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 * bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n\n */\n oneOfValues<Y extends bigint>(expectedValue: Y[]): WithBigInt<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 );\n return this.custom(oneOfValues(expectedValue)) as WithBigInt<this, Y>;\n }\n}\n\nexport type WithBigInt<T extends BigIntSchema, Y = bigint> = T & { validation_bigint: Y };\nexport type ExtractFromBigInt<T> = T extends WithBigInt<BigIntSchema, infer Y> ? Y : never;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/StringSchema.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,IAAI,aAAa,GAAG;AAEzC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,IAAI,EAAE,GAAG;AAAA,IACrC;AACA,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/BigIntSchema.ts"],"sourcesContent":["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 BigIntSchema extends CommonSchema {\n _bigint = 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 - bigint().equalTo(42n); // Infers the type 42n\n */\n equalTo<Y extends bigint>(expectedValue: Y): WithBigInt<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 WithBigInt<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 * bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n\n */\n oneOfValues<Y extends bigint>(expectedValue: Y[]): WithBigInt<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 );\n return this.custom(oneOfValues(expectedValue)) as WithBigInt<this, Y>;\n }\n}\n\nexport type WithBigInt<T extends BigIntSchema, Y = bigint> = T & { validation_bigint: Y };\nexport type ExtractFromBigInt<T> = T extends WithBigInt<BigIntSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,GAAG,aAAa,GAAG;AACxC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG;AAAA,IACpC;AACA,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-WK4O3HH4.js","../src/exceptions.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,gBAAA,EAAN,MAAA,QAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAA,CAAY,QAAA,EAAmB,QAAA,EAAmB,WAAA,EAAqB,OAAA,EAAiB;AACtF,IAAA,KAAA,CAAM,CAAA;AACN,IAAA,IAAA,CAAK,SAAA,EAAW,QAAA;AAChB,IAAA,IAAA,CAAK,SAAA,EAAW,QAAA;AAChB,IAAA,IAAA,CAAK,YAAA,EAAc,WAAA;AACnB,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA;AAAA,EACjB;AACF,CAAA;AAEO,IAAM,iBAAA,EAAN,MAAA,QAA+B,MAAM;AAAC,CAAA;AAE7C,SAAS,mBAAA,CAAoB,QAAA,EAAkB,YAAA,EAA+C;AAC5F,EAAA,MAAM,MAAA,EAAQ,YAAA;AACd,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,KAAA,EAAO,CAAC,CAAA,EAAG,GAAA,EAAA,GAAQ;AACzC,IAAA,MAAM,IAAA,EAAM,IAAA,GAAO,aAAA,EAAe,CAAA,EAAA;AAC3B,IAAA;AACR,EAAA;AACH;AAIE;AAImC,EAAA;AACC,EAAA;AAEd,EAAA;AACJ,IAAA;AACd,MAAA;AACA,MAAA;AACiB,MAAA;AACjB,MAAA;AACD,IAAA;AAED,IAAA;AACF,EAAA;AACoC,EAAA;AACtC;ADTuC;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-WK4O3HH4.js","sourcesContent":[null,"import type { ExceptionContext } from './commonTypes';\n\nexport class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nfunction replacePlaceholders(template: string, replacements: Record<string, unknown>): string {\n const regex = /{{(.*?)}}/g;\n return template.replace(regex, (_, key) => {\n const vvv = key in replacements ? `${replacements[key] as string}` : `{{${key}}}`;\n return vvv;\n });\n}\n\nexport function guardException(\n expected: unknown,\n received: unknown,\n ctx: ExceptionContext,\n messageKey: string,\n): never | void {\n const rawMessage = ctx.t[messageKey] ?? messageKey;\n const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: ctx.pathToError });\n\n if (ctx.getAllErrors) {\n ctx.errors.push({\n expected,\n received,\n pathToError: ctx.pathToError,\n message,\n });\n\n return;\n }\n throw new ValidationError(expected, received, ctx.pathToError, message);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/DateSchema.ts"],"sourcesContent":["import { ctxSymbol } from '../helpers/core';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class DateSchema extends CommonSchema {\n _date = 1;\n\n constructor(ctx: ValidatorContext) {\n super(ctx);\n this[ctxSymbol].date = true;\n }\n}\n"],"mappings":";;;;;;;;AAGO,IAAM,aAAN,cAAyB,aAAa;AAAA,EAC3C,QAAQ;AAAA,EAER,YAAY,KAAuB;AACjC,UAAM,GAAG;AACT,SAAK,SAAS,EAAE,OAAO;AAAA,EACzB;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helpers/core.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;AAAO,IAAM,YAAY,OAAO,eAAe;AAOxC,SAAS,WAAW,QAAsB,eAAwB,OAAyB;AAChG,QAAM,aAAa,MAAM;AACzB,QAAM,aAAa,OAAO,SAAS;AACnC,MAAI,kBAAkB,QAAW;AAC/B,QAAI,CAAC,WAAW,WAAY,gBAAe,YAAY,eAAe,OAAO,WAAW,YAAY,CAAC;AACrG,WAAO;AAAA,EACT;AAEA,MAAI,kBAAkB,MAAM;AAC1B,QAAI,CAAC,WAAW,WAAY,gBAAe,YAAY,eAAe,OAAO,WAAW,YAAY,CAAC;AACrG,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,MAAM;AACnB,QAAI,CAAC,YAAY,aAAa,EAAG,gBAAe,QAAQ,eAAe,OAAO,WAAW,QAAQ,CAAC;AAAA,EACpG;AAEA,MAAI,WAAW,OAAO;AACpB,QAAI,CAAC,MAAM,QAAQ,aAAa,EAAG,QAAO,eAAe,SAAS,eAAe,OAAO,WAAW,SAAS,CAAC;AAC7G,UAAMA,UAAS,WAAW;AAC1B,UAAM,cAAc,MAAM;AAC1B,kBAAc,QAAQ,CAAC,MAAM,MAAM;AACjC,iBAAWA,SAAQ,MAAM,EAAE,GAAG,OAAO,aAAa,GAAG,WAAW,IAAI,CAAC,IAAI,CAAC;AAAA,IAC5E,CAAC;AAED,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO;AAEzB,MAAI,WAAW,QAAQ;AACrB,QAAI,cAAc,SAAU,gBAAe,UAAU,eAAe,OAAO,WAAW,cAAc,CAAC;AACrG,QAAI,MAAM,QAAQ,aAAa,EAAG,gBAAe,UAAU,eAAe,OAAO,WAAW,qBAAqB,CAAC;AAClH,UAAM,cAAc,WAAW;AAE/B,QAAI,CAAC,WAAW,8BAA8B;AAC5C,iBAAW,uBAAuB,OAAO,KAAK,aAAa,GAAG;AAC5D,YAAI,YAAY,mBAAmB,MAAM;AACvC,yBAAe,yBAAyB,qBAAqB,OAAO,WAAW,wBAAwB,CAAC;AAAA,MAC5G;AAAA,IACF;AAEA,UAAM,cAAc,MAAM;AAC1B,eAAW,CAAC,aAAa,aAAa,KAAK,OAAO,QAAQ,WAAW,GAAG;AACtE,YAAM,6BAA8B,cAA0C,WAAW;AACzF,UAAI,+BAA+B,QAAW;AAC5C,YAAI,CAAC,cAAc,SAAS,EAAE;AAC5B,yBAAe,YAAY,4BAA4B,OAAO,WAAW,oBAAoB,CAAC;AAAA,MAClG;AAEA,iBAAW,eAAe,4BAA4B,EAAE,GAAG,OAAO,aAAa,GAAG,WAAW,IAAI,WAAW,GAAG,CAAC;AAAA,IAClH;AAEA,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,KAAK,QAAQ;AAC1B,QAAI,CAAC,WAAW,KAAK,SAAS,SAAS;AACrC,qBAAe,WAAW,MAAM,WAAW,OAAO,WAAW,eAAe,CAAC;AAAA,EACjF;AAEA,aAAW,oBAAoB,QAAQ,CAAC,uBAAuB;AAC7D,uBAAmB,eAAe,KAAK;AAAA,EACzC,CAAC;AAED,SAAO;AACT;","names":["schema"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/NumberSchema.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bguard/bguard/lib/helpers/isValidDate.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B;AACE;AACF,mDAAC","file":"/home/runner/work/bguard/bguard/lib/helpers/isValidDate.js"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|