bguard 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/README.md +269 -121
  2. package/lib/CommonSchema-DOh3bsL-.d.ts +110 -0
  3. package/lib/CommonSchema-wi9MOXGF.d.mts +110 -0
  4. package/lib/InferType.d.mts +6 -14
  5. package/lib/InferType.d.ts +6 -14
  6. package/lib/asserts/array/index.d.mts +6 -5
  7. package/lib/asserts/array/index.d.ts +6 -5
  8. package/lib/asserts/array/index.js +7 -7
  9. package/lib/asserts/array/index.js.map +1 -1
  10. package/lib/asserts/array/index.mjs +6 -6
  11. package/lib/asserts/array/index.mjs.map +1 -1
  12. package/lib/asserts/array/maxArrayLength.js +4 -4
  13. package/lib/asserts/array/maxArrayLength.mjs +2 -2
  14. package/lib/asserts/array/minArrayLength.js +4 -4
  15. package/lib/asserts/array/minArrayLength.mjs +2 -2
  16. package/lib/asserts/bigint/bigintMax.js +4 -4
  17. package/lib/asserts/bigint/bigintMax.mjs +2 -2
  18. package/lib/asserts/bigint/bigintMaxExcluded.js +4 -4
  19. package/lib/asserts/bigint/bigintMaxExcluded.mjs +2 -2
  20. package/lib/asserts/bigint/bigintMin.js +4 -4
  21. package/lib/asserts/bigint/bigintMin.mjs +2 -2
  22. package/lib/asserts/bigint/bigintMinExcluded.js +4 -4
  23. package/lib/asserts/bigint/bigintMinExcluded.mjs +2 -2
  24. package/lib/asserts/bigint/index.d.mts +5 -4
  25. package/lib/asserts/bigint/index.d.ts +5 -4
  26. package/lib/asserts/bigint/index.js +10 -10
  27. package/lib/asserts/bigint/index.js.map +1 -1
  28. package/lib/asserts/bigint/index.mjs +9 -9
  29. package/lib/asserts/bigint/index.mjs.map +1 -1
  30. package/lib/asserts/boolean/index.d.mts +5 -4
  31. package/lib/asserts/boolean/index.d.ts +5 -4
  32. package/lib/asserts/boolean/index.js +8 -8
  33. package/lib/asserts/boolean/index.js.map +1 -1
  34. package/lib/asserts/boolean/index.mjs +7 -7
  35. package/lib/asserts/boolean/index.mjs.map +1 -1
  36. package/lib/asserts/date/dateMax.js +5 -5
  37. package/lib/asserts/date/dateMax.mjs +2 -2
  38. package/lib/asserts/date/dateMin.js +5 -5
  39. package/lib/asserts/date/dateMin.mjs +2 -2
  40. package/lib/asserts/date/index.d.mts +5 -4
  41. package/lib/asserts/date/index.d.ts +5 -4
  42. package/lib/asserts/date/index.js +7 -7
  43. package/lib/asserts/date/index.js.map +1 -1
  44. package/lib/asserts/date/index.mjs +6 -6
  45. package/lib/asserts/date/index.mjs.map +1 -1
  46. package/lib/asserts/mix/equalTo.js +4 -4
  47. package/lib/asserts/mix/equalTo.mjs +3 -3
  48. package/lib/asserts/mix/index.d.mts +5 -4
  49. package/lib/asserts/mix/index.d.ts +5 -4
  50. package/lib/asserts/mix/index.js +6 -6
  51. package/lib/asserts/mix/index.js.map +1 -1
  52. package/lib/asserts/mix/index.mjs +5 -5
  53. package/lib/asserts/mix/index.mjs.map +1 -1
  54. package/lib/asserts/mix/oneOfValues.js +4 -4
  55. package/lib/asserts/mix/oneOfValues.mjs +3 -3
  56. package/lib/asserts/number/index.d.mts +4 -3
  57. package/lib/asserts/number/index.d.ts +4 -3
  58. package/lib/asserts/number/index.js +10 -10
  59. package/lib/asserts/number/index.js.map +1 -1
  60. package/lib/asserts/number/index.mjs +9 -9
  61. package/lib/asserts/number/index.mjs.map +1 -1
  62. package/lib/asserts/number/max.js +4 -4
  63. package/lib/asserts/number/max.mjs +2 -2
  64. package/lib/asserts/number/maxExcluded.js +4 -4
  65. package/lib/asserts/number/maxExcluded.mjs +2 -2
  66. package/lib/asserts/number/min.js +4 -4
  67. package/lib/asserts/number/min.mjs +2 -2
  68. package/lib/asserts/number/minExcluded.js +4 -4
  69. package/lib/asserts/number/minExcluded.mjs +2 -2
  70. package/lib/asserts/number/negative.js +4 -4
  71. package/lib/asserts/number/negative.mjs +2 -2
  72. package/lib/asserts/number/positive.js +4 -4
  73. package/lib/asserts/number/positive.mjs +2 -2
  74. package/lib/asserts/object/index.d.mts +6 -5
  75. package/lib/asserts/object/index.d.ts +6 -5
  76. package/lib/asserts/object/index.js +7 -7
  77. package/lib/asserts/object/index.js.map +1 -1
  78. package/lib/asserts/object/index.mjs +6 -6
  79. package/lib/asserts/object/index.mjs.map +1 -1
  80. package/lib/asserts/object/maxKeys.d.mts +30 -0
  81. package/lib/asserts/object/maxKeys.d.ts +30 -0
  82. package/lib/asserts/object/maxKeys.js +23 -0
  83. package/lib/asserts/object/maxKeys.js.map +1 -0
  84. package/lib/asserts/object/maxKeys.mjs +23 -0
  85. package/lib/asserts/object/maxKeys.mjs.map +1 -0
  86. package/lib/asserts/string/atLeastOneDigit.js +4 -4
  87. package/lib/asserts/string/atLeastOneDigit.mjs +2 -2
  88. package/lib/asserts/string/atLeastOneLowerChar.js +4 -4
  89. package/lib/asserts/string/atLeastOneLowerChar.mjs +2 -2
  90. package/lib/asserts/string/atLeastOneSpecialChar.js +4 -4
  91. package/lib/asserts/string/atLeastOneSpecialChar.mjs +2 -2
  92. package/lib/asserts/string/atLeastOneUpperChar.js +4 -4
  93. package/lib/asserts/string/atLeastOneUpperChar.mjs +2 -2
  94. package/lib/asserts/string/contains.js +4 -4
  95. package/lib/asserts/string/contains.mjs +2 -2
  96. package/lib/asserts/string/email.js +4 -4
  97. package/lib/asserts/string/email.mjs +2 -2
  98. package/lib/asserts/string/endsWith.js +4 -4
  99. package/lib/asserts/string/endsWith.mjs +2 -2
  100. package/lib/asserts/string/index.d.mts +5 -4
  101. package/lib/asserts/string/index.d.ts +5 -4
  102. package/lib/asserts/string/index.js +10 -10
  103. package/lib/asserts/string/index.js.map +1 -1
  104. package/lib/asserts/string/index.mjs +9 -9
  105. package/lib/asserts/string/index.mjs.map +1 -1
  106. package/lib/asserts/string/isValidDate.js +4 -4
  107. package/lib/asserts/string/isValidDate.mjs +2 -2
  108. package/lib/asserts/string/isValidDateTime.js +4 -4
  109. package/lib/asserts/string/isValidDateTime.mjs +2 -2
  110. package/lib/asserts/string/isValidTime.js +5 -5
  111. package/lib/asserts/string/isValidTime.mjs +2 -2
  112. package/lib/asserts/string/lowerCase.js +4 -4
  113. package/lib/asserts/string/lowerCase.mjs +2 -2
  114. package/lib/asserts/string/maxLength.js +4 -4
  115. package/lib/asserts/string/maxLength.mjs +2 -2
  116. package/lib/asserts/string/minLength.js +4 -4
  117. package/lib/asserts/string/minLength.mjs +2 -2
  118. package/lib/asserts/string/regExp.js +4 -4
  119. package/lib/asserts/string/regExp.mjs +2 -2
  120. package/lib/asserts/string/startsWith.js +4 -4
  121. package/lib/asserts/string/startsWith.mjs +2 -2
  122. package/lib/asserts/string/upperCase.js +4 -4
  123. package/lib/asserts/string/upperCase.mjs +2 -2
  124. package/lib/asserts/string/uuid.js +4 -4
  125. package/lib/asserts/string/uuid.mjs +2 -2
  126. package/lib/asserts/string/uuidV1.js +4 -4
  127. package/lib/asserts/string/uuidV1.mjs +2 -2
  128. package/lib/asserts/string/uuidV2.js +4 -4
  129. package/lib/asserts/string/uuidV2.mjs +2 -2
  130. package/lib/asserts/string/uuidV3.js +4 -4
  131. package/lib/asserts/string/uuidV3.mjs +2 -2
  132. package/lib/asserts/string/uuidV4.js +4 -4
  133. package/lib/asserts/string/uuidV4.mjs +2 -2
  134. package/lib/asserts/string/uuidV5.js +4 -4
  135. package/lib/asserts/string/uuidV5.mjs +2 -2
  136. package/lib/asserts/string/validUrl.js +4 -4
  137. package/lib/asserts/string/validUrl.mjs +2 -2
  138. package/lib/{chunk-OJSTQQ3N.js → chunk-2KQASECD.js} +5 -5
  139. package/lib/{chunk-OJSTQQ3N.js.map → chunk-2KQASECD.js.map} +1 -1
  140. package/lib/{chunk-AY7HKAG2.js → chunk-5P6AZJCN.js} +5 -3
  141. package/lib/chunk-5P6AZJCN.js.map +1 -0
  142. package/lib/{chunk-AN3VHQEQ.js → chunk-5WHCMWXK.js} +12 -9
  143. package/lib/chunk-5WHCMWXK.js.map +1 -0
  144. package/lib/{chunk-UZ2PWO4O.js → chunk-5YYRBKDP.js} +4 -4
  145. package/lib/{chunk-UZ2PWO4O.js.map → chunk-5YYRBKDP.js.map} +1 -1
  146. package/lib/{chunk-YPAFWVDL.mjs → chunk-6D5W7SSQ.mjs} +4 -4
  147. package/lib/chunk-6D5W7SSQ.mjs.map +1 -0
  148. package/lib/chunk-7NBOVYSP.mjs +136 -0
  149. package/lib/chunk-7NBOVYSP.mjs.map +1 -0
  150. package/lib/{chunk-5LLJ22IG.mjs → chunk-BNCT7NOR.mjs} +21 -7
  151. package/lib/chunk-BNCT7NOR.mjs.map +1 -0
  152. package/lib/{chunk-BUXOCPHI.mjs → chunk-C3EDEQ3W.mjs} +3 -3
  153. package/lib/{chunk-TQWUSDQD.mjs → chunk-CHUPE6SJ.mjs} +6 -6
  154. package/lib/chunk-CHUPE6SJ.mjs.map +1 -0
  155. package/lib/{chunk-ZVW3IHBW.js → chunk-ECBOZ3BM.js} +8 -8
  156. package/lib/chunk-ECBOZ3BM.js.map +1 -0
  157. package/lib/{chunk-NP64RC7B.mjs → chunk-FGZKNBDP.mjs} +5 -3
  158. package/lib/chunk-FGZKNBDP.mjs.map +1 -0
  159. package/lib/{chunk-ZWE5Q37U.mjs → chunk-FP5QAEVQ.mjs} +6 -6
  160. package/lib/chunk-FP5QAEVQ.mjs.map +1 -0
  161. package/lib/{chunk-PESVL5YJ.js → chunk-G55SHHAR.js} +10 -8
  162. package/lib/chunk-G55SHHAR.js.map +1 -0
  163. package/lib/{chunk-4GDBM5LP.mjs → chunk-H32B3NHW.mjs} +2 -2
  164. package/lib/{chunk-D42ISCFK.mjs → chunk-H6LHV3EA.mjs} +2 -2
  165. package/lib/{chunk-SPWF5IFU.js → chunk-HP3DRZWK.js} +5 -5
  166. package/lib/{chunk-SPWF5IFU.js.map → chunk-HP3DRZWK.js.map} +1 -1
  167. package/lib/{chunk-W2GOLG3K.js → chunk-IZ3CBVEE.js} +5 -5
  168. package/lib/{chunk-W2GOLG3K.js.map → chunk-IZ3CBVEE.js.map} +1 -1
  169. package/lib/{chunk-OHEMRF7Y.mjs → chunk-K7X6DVM2.mjs} +3 -3
  170. package/lib/{chunk-KBZUNXJB.mjs → chunk-LPR3G5T3.mjs} +4 -4
  171. package/lib/{chunk-KBZUNXJB.mjs.map → chunk-LPR3G5T3.mjs.map} +1 -1
  172. package/lib/{chunk-2MFBOVP2.mjs → chunk-MHBY5OIQ.mjs} +3 -3
  173. package/lib/{chunk-EU3ZZF7Y.js → chunk-MLNQZ445.js} +13 -13
  174. package/lib/chunk-MLNQZ445.js.map +1 -0
  175. package/lib/chunk-QIDWASOC.js +14 -0
  176. package/lib/{chunk-3ZPLJ5KC.js.map → chunk-QIDWASOC.js.map} +1 -1
  177. package/lib/chunk-SHJVKSEZ.js +136 -0
  178. package/lib/chunk-SHJVKSEZ.js.map +1 -0
  179. package/lib/{chunk-ADSMWGDJ.mjs → chunk-TRGMD7LA.mjs} +7 -5
  180. package/lib/chunk-TRGMD7LA.mjs.map +1 -0
  181. package/lib/{chunk-OKF3BVUD.mjs → chunk-TV5IZY4L.mjs} +9 -6
  182. package/lib/chunk-TV5IZY4L.mjs.map +1 -0
  183. package/lib/{chunk-OO6BTBVP.js → chunk-U4USIJV3.js} +11 -11
  184. package/lib/{chunk-OO6BTBVP.js.map → chunk-U4USIJV3.js.map} +1 -1
  185. package/lib/{chunk-P6V6S6TZ.js → chunk-UUY7DPHK.js} +12 -12
  186. package/lib/chunk-UUY7DPHK.js.map +1 -0
  187. package/lib/chunk-VW4RMQD4.js +28 -0
  188. package/lib/{chunk-LYNVPN3R.js.map → chunk-VW4RMQD4.js.map} +1 -1
  189. package/lib/{chunk-ZMEQCIRN.mjs → chunk-WK4FJ5GD.mjs} +6 -6
  190. package/lib/chunk-WK4FJ5GD.mjs.map +1 -0
  191. package/lib/{chunk-PIBDJJUU.js → chunk-X762EUSZ.js} +31 -17
  192. package/lib/chunk-X762EUSZ.js.map +1 -0
  193. package/lib/{chunk-5HT3PYSG.mjs → chunk-YUMUCQKL.mjs} +4 -4
  194. package/lib/{chunk-5HT3PYSG.mjs.map → chunk-YUMUCQKL.mjs.map} +1 -1
  195. package/lib/{chunk-2D5QE7F4.js → chunk-Z6QU36MM.js} +12 -12
  196. package/lib/chunk-Z6QU36MM.js.map +1 -0
  197. package/lib/codeGen.d.mts +2 -1
  198. package/lib/codeGen.d.ts +2 -1
  199. package/lib/codeGen.js +3 -3
  200. package/lib/codeGen.mjs +2 -2
  201. package/lib/commonTypes.d.mts +26 -2
  202. package/lib/commonTypes.d.ts +26 -2
  203. package/lib/exceptions.d.mts +3 -2
  204. package/lib/exceptions.d.ts +3 -2
  205. package/lib/exceptions.js +2 -2
  206. package/lib/exceptions.mjs +1 -1
  207. package/lib/helpers/core.d.mts +2 -1
  208. package/lib/helpers/core.d.ts +2 -1
  209. package/lib/helpers/core.js +3 -3
  210. package/lib/helpers/core.mjs +2 -2
  211. package/lib/helpers/setStrictType.d.mts +2 -1
  212. package/lib/helpers/setStrictType.d.ts +2 -1
  213. package/lib/helpers/setStrictType.js +4 -4
  214. package/lib/helpers/setStrictType.mjs +3 -3
  215. package/lib/index.d.mts +1 -8
  216. package/lib/index.d.ts +1 -8
  217. package/lib/index.js +6 -6
  218. package/lib/index.mjs +5 -5
  219. package/lib/parse.d.mts +1 -8
  220. package/lib/parse.d.ts +1 -8
  221. package/lib/parse.js +5 -5
  222. package/lib/parse.mjs +4 -4
  223. package/lib/parseOrFail.d.mts +1 -8
  224. package/lib/parseOrFail.d.ts +1 -8
  225. package/lib/parseOrFail.js +5 -5
  226. package/lib/parseOrFail.mjs +4 -4
  227. package/lib/schemas/ArraySchema.d.mts +3 -6
  228. package/lib/schemas/ArraySchema.d.ts +3 -6
  229. package/lib/schemas/ArraySchema.js +7 -7
  230. package/lib/schemas/ArraySchema.mjs +6 -6
  231. package/lib/schemas/BigIntSchema.d.mts +6 -9
  232. package/lib/schemas/BigIntSchema.d.ts +6 -9
  233. package/lib/schemas/BigIntSchema.js +10 -10
  234. package/lib/schemas/BigIntSchema.mjs +9 -9
  235. package/lib/schemas/BooleanSchema.d.mts +6 -9
  236. package/lib/schemas/BooleanSchema.d.ts +6 -9
  237. package/lib/schemas/BooleanSchema.js +8 -8
  238. package/lib/schemas/BooleanSchema.mjs +7 -7
  239. package/lib/schemas/CommonSchema.d.mts +2 -1
  240. package/lib/schemas/CommonSchema.d.ts +2 -1
  241. package/lib/schemas/CommonSchema.js +6 -6
  242. package/lib/schemas/CommonSchema.mjs +5 -5
  243. package/lib/schemas/DateSchema.d.mts +2 -1
  244. package/lib/schemas/DateSchema.d.ts +2 -1
  245. package/lib/schemas/DateSchema.js +7 -7
  246. package/lib/schemas/DateSchema.mjs +6 -6
  247. package/lib/schemas/NumberSchema.d.mts +6 -9
  248. package/lib/schemas/NumberSchema.d.ts +6 -9
  249. package/lib/schemas/NumberSchema.js +10 -10
  250. package/lib/schemas/NumberSchema.mjs +9 -9
  251. package/lib/schemas/ObjectSchema.d.mts +3 -5
  252. package/lib/schemas/ObjectSchema.d.ts +3 -5
  253. package/lib/schemas/ObjectSchema.js +7 -7
  254. package/lib/schemas/ObjectSchema.mjs +6 -6
  255. package/lib/schemas/StringSchema.d.mts +6 -9
  256. package/lib/schemas/StringSchema.d.ts +6 -9
  257. package/lib/schemas/StringSchema.js +10 -10
  258. package/lib/schemas/StringSchema.mjs +9 -9
  259. package/lib/translationMap.js +3 -3
  260. package/lib/translationMap.mjs +2 -2
  261. package/package.json +1 -1
  262. package/lib/CommonSchema-CiY7spmg.d.mts +0 -71
  263. package/lib/CommonSchema-D9QVJBJe.d.ts +0 -71
  264. package/lib/chunk-2D5QE7F4.js.map +0 -1
  265. package/lib/chunk-3IOQH3K4.js +0 -74
  266. package/lib/chunk-3IOQH3K4.js.map +0 -1
  267. package/lib/chunk-3ZPLJ5KC.js +0 -14
  268. package/lib/chunk-5LLJ22IG.mjs.map +0 -1
  269. package/lib/chunk-ADSMWGDJ.mjs.map +0 -1
  270. package/lib/chunk-AN3VHQEQ.js.map +0 -1
  271. package/lib/chunk-AOUFWACR.mjs +0 -74
  272. package/lib/chunk-AOUFWACR.mjs.map +0 -1
  273. package/lib/chunk-AY7HKAG2.js.map +0 -1
  274. package/lib/chunk-EU3ZZF7Y.js.map +0 -1
  275. package/lib/chunk-LYNVPN3R.js +0 -28
  276. package/lib/chunk-NP64RC7B.mjs.map +0 -1
  277. package/lib/chunk-OKF3BVUD.mjs.map +0 -1
  278. package/lib/chunk-P6V6S6TZ.js.map +0 -1
  279. package/lib/chunk-PESVL5YJ.js.map +0 -1
  280. package/lib/chunk-PIBDJJUU.js.map +0 -1
  281. package/lib/chunk-TQWUSDQD.mjs.map +0 -1
  282. package/lib/chunk-YPAFWVDL.mjs.map +0 -1
  283. package/lib/chunk-ZMEQCIRN.mjs.map +0 -1
  284. package/lib/chunk-ZVW3IHBW.js.map +0 -1
  285. package/lib/chunk-ZWE5Q37U.mjs.map +0 -1
  286. /package/lib/{chunk-BUXOCPHI.mjs.map → chunk-C3EDEQ3W.mjs.map} +0 -0
  287. /package/lib/{chunk-4GDBM5LP.mjs.map → chunk-H32B3NHW.mjs.map} +0 -0
  288. /package/lib/{chunk-D42ISCFK.mjs.map → chunk-H6LHV3EA.mjs.map} +0 -0
  289. /package/lib/{chunk-OHEMRF7Y.mjs.map → chunk-K7X6DVM2.mjs.map} +0 -0
  290. /package/lib/{chunk-2MFBOVP2.mjs.map → chunk-MHBY5OIQ.mjs.map} +0 -0
@@ -0,0 +1,110 @@
1
+ import { InferType } from './InferType.js';
2
+ import { ExceptionContext, BaseType, RequiredValidation, MetaContext, TransformCallback, WithNull, WithUndefined } from './commonTypes.js';
3
+
4
+ declare const ctxSymbol: unique symbol;
5
+
6
+ declare function innerCheck(schema: CommonSchema, receivedValue: unknown, exCtx: ExceptionContext): unknown;
7
+
8
+ type ObjectShapeSchemaType = Record<string, CommonSchema>;
9
+ interface ValidatorContext {
10
+ type: BaseType[];
11
+ isNullable?: boolean;
12
+ isOptional?: boolean;
13
+ requiredValidations: RequiredValidation[];
14
+ array?: CommonSchema;
15
+ object?: ObjectShapeSchemaType;
16
+ allowUnrecognizedObjectProps?: boolean;
17
+ strictType?: boolean;
18
+ strictTypeValue?: unknown;
19
+ date?: boolean;
20
+ defaultValue?: unknown;
21
+ meta?: MetaContext;
22
+ transformListBefore?: TransformCallback<any, any>[];
23
+ }
24
+ declare class CommonSchema {
25
+ [ctxSymbol]: ValidatorContext;
26
+ constructor(ctx: ValidatorContext);
27
+ /**
28
+ * @param validators - One or more custom validation functions.
29
+ * @returns {this} The schema instance with the added custom validation.
30
+ */
31
+ custom(...validators: RequiredValidation[]): this;
32
+ /**
33
+ * Marks the schema as nullable, allowing the value to be `null`.
34
+ *
35
+ * @returns {WithNull<this>} The schema instance marked as nullable.
36
+ */
37
+ nullable(): WithNull<this>;
38
+ /**
39
+ * Marks the schema as optional, allowing the value to be `undefined`.
40
+ *
41
+ * @returns {WithUndefined<this>} The schema instance marked as optional.
42
+ */
43
+ optional(): WithUndefined<this>;
44
+ /**
45
+ * Marks the schema as optional, allowing the value to be `undefined`.
46
+ *
47
+ * @returns {this} The schema instance. This method should be used as a last one because it does the check of previous methods and
48
+ */
49
+ default(defaultValue: InferType<this>): this;
50
+ /**
51
+ * Applies a transformation to the input value before any validation occurs.
52
+ * The transformation should return a value of the same type as the inferred type of the schema,
53
+ * ensuring that the overall type is not altered.
54
+ *
55
+ * @template In - The type of the input value before transformation (defaults to `unknown`).
56
+ * @param {TransformCallback<In, InferType<this>>} cb - The callback function that performs the transformation.
57
+ * @returns {this} The updated schema with the applied transformation.
58
+ *
59
+ * @example
60
+ * const schema = string()
61
+ * .nullable()
62
+ * .transformBeforeValidation((val) => val + '') // Ensure the value is a string
63
+ * .transformBeforeValidation((val: string) => (val === '' ? null : val)); // Convert empty strings to null
64
+ *
65
+ * // Parse 'test' will pass as 'test' is a valid string longer than 3 characters.
66
+ * parseOrFail(schema, 'test');
67
+ *
68
+ * // Parsing '' will be transformed to null and will pass due to .nullable().
69
+ * parseOrFail(schema, '');
70
+ */
71
+ transformBeforeValidation<In>(cb: TransformCallback<In, InferType<this>>): this;
72
+ /**
73
+ * Assigns a unique identifier to the schema.
74
+ * This ID can be used to track or map validation errors back to specific fields
75
+ * in a form or other structures.
76
+ *
77
+ * @param {string} value - The unique identifier for the schema.
78
+ * @returns {this} The updated schema with the assigned ID.
79
+ *
80
+ * @example
81
+ * const schema = string().id('username');
82
+ */
83
+ id(value: string): this;
84
+ /**
85
+ * Provides a description for the schema, offering additional context or information.
86
+ * The description can be used when displaying validation errors or for documentation purposes.
87
+ *
88
+ * @param {string} value - The description for the schema.
89
+ * @returns {this} The updated schema with the added description.
90
+ *
91
+ * @example
92
+ * const schema = string().description('The username of the account holder.');
93
+ */
94
+ description(value: string): this;
95
+ private meta;
96
+ protected defaultValueCheck(): void;
97
+ }
98
+ type TypeMapping = {
99
+ number: number;
100
+ string: string;
101
+ boolean: boolean;
102
+ undefined: undefined;
103
+ object: object;
104
+ function: Function;
105
+ symbol: symbol;
106
+ bigint: bigint;
107
+ };
108
+ type MapMixTypes<T extends BaseType[]> = T extends (infer U)[] ? U extends keyof TypeMapping ? TypeMapping[U] : never : never;
109
+
110
+ export { CommonSchema as C, type MapMixTypes as M, type ObjectShapeSchemaType as O, type ValidatorContext as V, ctxSymbol as c, innerCheck as i };
@@ -0,0 +1,110 @@
1
+ import { InferType } from './InferType.mjs';
2
+ import { ExceptionContext, BaseType, RequiredValidation, MetaContext, TransformCallback, WithNull, WithUndefined } from './commonTypes.mjs';
3
+
4
+ declare const ctxSymbol: unique symbol;
5
+
6
+ declare function innerCheck(schema: CommonSchema, receivedValue: unknown, exCtx: ExceptionContext): unknown;
7
+
8
+ type ObjectShapeSchemaType = Record<string, CommonSchema>;
9
+ interface ValidatorContext {
10
+ type: BaseType[];
11
+ isNullable?: boolean;
12
+ isOptional?: boolean;
13
+ requiredValidations: RequiredValidation[];
14
+ array?: CommonSchema;
15
+ object?: ObjectShapeSchemaType;
16
+ allowUnrecognizedObjectProps?: boolean;
17
+ strictType?: boolean;
18
+ strictTypeValue?: unknown;
19
+ date?: boolean;
20
+ defaultValue?: unknown;
21
+ meta?: MetaContext;
22
+ transformListBefore?: TransformCallback<any, any>[];
23
+ }
24
+ declare class CommonSchema {
25
+ [ctxSymbol]: ValidatorContext;
26
+ constructor(ctx: ValidatorContext);
27
+ /**
28
+ * @param validators - One or more custom validation functions.
29
+ * @returns {this} The schema instance with the added custom validation.
30
+ */
31
+ custom(...validators: RequiredValidation[]): this;
32
+ /**
33
+ * Marks the schema as nullable, allowing the value to be `null`.
34
+ *
35
+ * @returns {WithNull<this>} The schema instance marked as nullable.
36
+ */
37
+ nullable(): WithNull<this>;
38
+ /**
39
+ * Marks the schema as optional, allowing the value to be `undefined`.
40
+ *
41
+ * @returns {WithUndefined<this>} The schema instance marked as optional.
42
+ */
43
+ optional(): WithUndefined<this>;
44
+ /**
45
+ * Marks the schema as optional, allowing the value to be `undefined`.
46
+ *
47
+ * @returns {this} The schema instance. This method should be used as a last one because it does the check of previous methods and
48
+ */
49
+ default(defaultValue: InferType<this>): this;
50
+ /**
51
+ * Applies a transformation to the input value before any validation occurs.
52
+ * The transformation should return a value of the same type as the inferred type of the schema,
53
+ * ensuring that the overall type is not altered.
54
+ *
55
+ * @template In - The type of the input value before transformation (defaults to `unknown`).
56
+ * @param {TransformCallback<In, InferType<this>>} cb - The callback function that performs the transformation.
57
+ * @returns {this} The updated schema with the applied transformation.
58
+ *
59
+ * @example
60
+ * const schema = string()
61
+ * .nullable()
62
+ * .transformBeforeValidation((val) => val + '') // Ensure the value is a string
63
+ * .transformBeforeValidation((val: string) => (val === '' ? null : val)); // Convert empty strings to null
64
+ *
65
+ * // Parse 'test' will pass as 'test' is a valid string longer than 3 characters.
66
+ * parseOrFail(schema, 'test');
67
+ *
68
+ * // Parsing '' will be transformed to null and will pass due to .nullable().
69
+ * parseOrFail(schema, '');
70
+ */
71
+ transformBeforeValidation<In>(cb: TransformCallback<In, InferType<this>>): this;
72
+ /**
73
+ * Assigns a unique identifier to the schema.
74
+ * This ID can be used to track or map validation errors back to specific fields
75
+ * in a form or other structures.
76
+ *
77
+ * @param {string} value - The unique identifier for the schema.
78
+ * @returns {this} The updated schema with the assigned ID.
79
+ *
80
+ * @example
81
+ * const schema = string().id('username');
82
+ */
83
+ id(value: string): this;
84
+ /**
85
+ * Provides a description for the schema, offering additional context or information.
86
+ * The description can be used when displaying validation errors or for documentation purposes.
87
+ *
88
+ * @param {string} value - The description for the schema.
89
+ * @returns {this} The updated schema with the added description.
90
+ *
91
+ * @example
92
+ * const schema = string().description('The username of the account holder.');
93
+ */
94
+ description(value: string): this;
95
+ private meta;
96
+ protected defaultValueCheck(): void;
97
+ }
98
+ type TypeMapping = {
99
+ number: number;
100
+ string: string;
101
+ boolean: boolean;
102
+ undefined: undefined;
103
+ object: object;
104
+ function: Function;
105
+ symbol: symbol;
106
+ bigint: bigint;
107
+ };
108
+ type MapMixTypes<T extends BaseType[]> = T extends (infer U)[] ? U extends keyof TypeMapping ? TypeMapping[U] : never : never;
109
+
110
+ export { CommonSchema as C, type MapMixTypes as M, type ObjectShapeSchemaType as O, type ValidatorContext as V, ctxSymbol as c, innerCheck as i };
@@ -1,22 +1,14 @@
1
- import { ArraySchema, ExtractFromArray } from './schemas/ArraySchema.mjs';
2
- import { WithBigInt, BigIntSchema, ExtractFromBigInt } from './schemas/BigIntSchema.mjs';
3
- import { WithBoolean, BooleanSchema, ExtractFromBoolean } from './schemas/BooleanSchema.mjs';
4
- import { W as WithMix, E as ExtractFromMix, a as WithUndefined, C as CommonSchema, b as WithNull } from './CommonSchema-CiY7spmg.mjs';
5
- import { DateSchema } from './schemas/DateSchema.mjs';
6
- import { WithNumber, NumberSchema, ExtractFromNumber } from './schemas/NumberSchema.mjs';
7
- import { ObjectSchema, WithObject } from './schemas/ObjectSchema.mjs';
8
- import { WithString, StringSchema, ExtractFromString } from './schemas/StringSchema.mjs';
9
- import './commonTypes.mjs';
1
+ import { WithBGuardType, ExtractFromBGuardType, WithArray, ExtractFromArray, WithObject, WithUndefined, WithNull } from './commonTypes.mjs';
10
2
 
11
- type ResolveNullish<T, Y> = T extends WithUndefined<WithNull<CommonSchema>> ? Y | null | undefined : T extends WithUndefined<CommonSchema> ? Y | undefined : T extends WithNull<CommonSchema> ? Y | null : Y;
12
- type InferType<T> = T extends WithString<StringSchema> ? ResolveNullish<T, ExtractFromString<T>> : T extends StringSchema ? ResolveNullish<T, string> : T extends WithNumber<NumberSchema> ? ResolveNullish<T, ExtractFromNumber<T>> : T extends NumberSchema ? ResolveNullish<T, number> : T extends WithBoolean<BooleanSchema> ? ResolveNullish<T, ExtractFromBoolean<T>> : T extends BooleanSchema ? ResolveNullish<T, boolean> : T extends ArraySchema ? ResolveNullish<T, InferType<ExtractFromArray<T>>[]> : T extends ObjectSchema ? ResolveNullish<T, ExtractFromObject<T>> : T extends WithMix ? ResolveNullish<T, ExtractFromMix<T>> : T extends WithBigInt<BigIntSchema> ? ResolveNullish<T, ExtractFromBigInt<T>> : T extends BigIntSchema ? ResolveNullish<T, bigint> : T extends DateSchema ? ResolveNullish<T, Date> : unknown;
3
+ type ResolveNullish<T, Y> = T extends WithUndefined<WithNull<unknown>> ? Y | null | undefined : T extends WithUndefined<unknown> ? Y | undefined : T extends WithNull<unknown> ? Y | null : Y;
4
+ type InferType<T> = T extends WithBGuardType<unknown, unknown> ? ResolveNullish<T, ExtractFromBGuardType<T>> : T extends WithArray<unknown, unknown> ? ResolveNullish<T, InferType<ExtractFromArray<T>>[]> : T extends WithObject<unknown, unknown> ? ResolveNullish<T, ExtractFromObject<T>> : unknown;
13
5
  type Merge<T> = T extends infer U ? {
14
6
  [K in keyof U]: U[K];
15
7
  } : never;
16
- type ExtractFromObject<T extends ObjectSchema> = T extends WithObject<infer X> ? Merge<{
17
- [K in keyof X as X[K] extends WithUndefined<CommonSchema> ? never : K]: InferType<X[K]>;
8
+ type ExtractFromObject<T> = T extends WithObject<unknown, infer X> ? Merge<{
9
+ [K in keyof X as X[K] extends WithUndefined<unknown> ? never : K]: InferType<X[K]>;
18
10
  } & {
19
- [K in keyof X as X[K] extends WithUndefined<CommonSchema> ? K : never]?: InferType<X[K]>;
11
+ [K in keyof X as X[K] extends WithUndefined<unknown> ? K : never]?: InferType<X[K]>;
20
12
  }> : unknown;
21
13
 
22
14
  export type { InferType };
@@ -1,22 +1,14 @@
1
- import { ArraySchema, ExtractFromArray } from './schemas/ArraySchema.js';
2
- import { WithBigInt, BigIntSchema, ExtractFromBigInt } from './schemas/BigIntSchema.js';
3
- import { WithBoolean, BooleanSchema, ExtractFromBoolean } from './schemas/BooleanSchema.js';
4
- import { W as WithMix, E as ExtractFromMix, a as WithUndefined, C as CommonSchema, b as WithNull } from './CommonSchema-D9QVJBJe.js';
5
- import { DateSchema } from './schemas/DateSchema.js';
6
- import { WithNumber, NumberSchema, ExtractFromNumber } from './schemas/NumberSchema.js';
7
- import { ObjectSchema, WithObject } from './schemas/ObjectSchema.js';
8
- import { WithString, StringSchema, ExtractFromString } from './schemas/StringSchema.js';
9
- import './commonTypes.js';
1
+ import { WithBGuardType, ExtractFromBGuardType, WithArray, ExtractFromArray, WithObject, WithUndefined, WithNull } from './commonTypes.js';
10
2
 
11
- type ResolveNullish<T, Y> = T extends WithUndefined<WithNull<CommonSchema>> ? Y | null | undefined : T extends WithUndefined<CommonSchema> ? Y | undefined : T extends WithNull<CommonSchema> ? Y | null : Y;
12
- type InferType<T> = T extends WithString<StringSchema> ? ResolveNullish<T, ExtractFromString<T>> : T extends StringSchema ? ResolveNullish<T, string> : T extends WithNumber<NumberSchema> ? ResolveNullish<T, ExtractFromNumber<T>> : T extends NumberSchema ? ResolveNullish<T, number> : T extends WithBoolean<BooleanSchema> ? ResolveNullish<T, ExtractFromBoolean<T>> : T extends BooleanSchema ? ResolveNullish<T, boolean> : T extends ArraySchema ? ResolveNullish<T, InferType<ExtractFromArray<T>>[]> : T extends ObjectSchema ? ResolveNullish<T, ExtractFromObject<T>> : T extends WithMix ? ResolveNullish<T, ExtractFromMix<T>> : T extends WithBigInt<BigIntSchema> ? ResolveNullish<T, ExtractFromBigInt<T>> : T extends BigIntSchema ? ResolveNullish<T, bigint> : T extends DateSchema ? ResolveNullish<T, Date> : unknown;
3
+ type ResolveNullish<T, Y> = T extends WithUndefined<WithNull<unknown>> ? Y | null | undefined : T extends WithUndefined<unknown> ? Y | undefined : T extends WithNull<unknown> ? Y | null : Y;
4
+ type InferType<T> = T extends WithBGuardType<unknown, unknown> ? ResolveNullish<T, ExtractFromBGuardType<T>> : T extends WithArray<unknown, unknown> ? ResolveNullish<T, InferType<ExtractFromArray<T>>[]> : T extends WithObject<unknown, unknown> ? ResolveNullish<T, ExtractFromObject<T>> : unknown;
13
5
  type Merge<T> = T extends infer U ? {
14
6
  [K in keyof U]: U[K];
15
7
  } : never;
16
- type ExtractFromObject<T extends ObjectSchema> = T extends WithObject<infer X> ? Merge<{
17
- [K in keyof X as X[K] extends WithUndefined<CommonSchema> ? never : K]: InferType<X[K]>;
8
+ type ExtractFromObject<T> = T extends WithObject<unknown, infer X> ? Merge<{
9
+ [K in keyof X as X[K] extends WithUndefined<unknown> ? never : K]: InferType<X[K]>;
18
10
  } & {
19
- [K in keyof X as X[K] extends WithUndefined<CommonSchema> ? K : never]?: InferType<X[K]>;
11
+ [K in keyof X as X[K] extends WithUndefined<unknown> ? K : never]?: InferType<X[K]>;
20
12
  }> : unknown;
21
13
 
22
14
  export type { InferType };
@@ -1,12 +1,13 @@
1
- import { WithArray } from '../../schemas/ArraySchema.mjs';
2
- import { C as CommonSchema } from '../../CommonSchema-CiY7spmg.mjs';
3
- import '../../commonTypes.mjs';
1
+ import { WithArray } from '../../commonTypes.mjs';
2
+ import { ArraySchema } from '../../schemas/ArraySchema.mjs';
3
+ import { C as CommonSchema } from '../../CommonSchema-wi9MOXGF.mjs';
4
+ import '../../InferType.mjs';
4
5
 
5
6
  /**
6
7
  * @description Creates a new schema for validating arrays where each element must match the specified schema.
7
8
  * @template T
8
9
  * @param {T} arraySchema - The schema that each element of the array must match.
9
- * @returns {WithArray<T>} A new instance of `ArraySchema` for validating arrays of elements that match the specified schema.
10
+ * @returns {WithArray<ArraySchema, T>} A new instance of `ArraySchema` for validating arrays of elements that match the specified schema.
10
11
  * @example
11
12
  * const schema = array(string());
12
13
  * parseOrFail(schema, ['hello', 'world']); // Validates successfully
@@ -14,6 +15,6 @@ import '../../commonTypes.mjs';
14
15
  *
15
16
  * @instance Of ArraySchema
16
17
  */
17
- declare function array<T extends CommonSchema>(arraySchema: T): WithArray<T>;
18
+ declare function array<T extends CommonSchema>(arraySchema: T): WithArray<ArraySchema, T>;
18
19
 
19
20
  export { array };
@@ -1,12 +1,13 @@
1
- import { WithArray } from '../../schemas/ArraySchema.js';
2
- import { C as CommonSchema } from '../../CommonSchema-D9QVJBJe.js';
3
- import '../../commonTypes.js';
1
+ import { WithArray } from '../../commonTypes.js';
2
+ import { ArraySchema } from '../../schemas/ArraySchema.js';
3
+ import { C as CommonSchema } from '../../CommonSchema-DOh3bsL-.js';
4
+ import '../../InferType.js';
4
5
 
5
6
  /**
6
7
  * @description Creates a new schema for validating arrays where each element must match the specified schema.
7
8
  * @template T
8
9
  * @param {T} arraySchema - The schema that each element of the array must match.
9
- * @returns {WithArray<T>} A new instance of `ArraySchema` for validating arrays of elements that match the specified schema.
10
+ * @returns {WithArray<ArraySchema, T>} A new instance of `ArraySchema` for validating arrays of elements that match the specified schema.
10
11
  * @example
11
12
  * const schema = array(string());
12
13
  * parseOrFail(schema, ['hello', 'world']); // Validates successfully
@@ -14,6 +15,6 @@ import '../../commonTypes.js';
14
15
  *
15
16
  * @instance Of ArraySchema
16
17
  */
17
- declare function array<T extends CommonSchema>(arraySchema: T): WithArray<T>;
18
+ declare function array<T extends CommonSchema>(arraySchema: T): WithArray<ArraySchema, T>;
18
19
 
19
20
  export { array };
@@ -1,16 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkLYNVPN3Rjs = require('../../chunk-LYNVPN3R.js');
4
- require('../../chunk-3IOQH3K4.js');
5
- require('../../chunk-PESVL5YJ.js');
6
- require('../../chunk-PIBDJJUU.js');
3
+ var _chunkVW4RMQD4js = require('../../chunk-VW4RMQD4.js');
4
+ require('../../chunk-SHJVKSEZ.js');
5
+ require('../../chunk-G55SHHAR.js');
6
+ require('../../chunk-X762EUSZ.js');
7
7
  require('../../chunk-VBTWYDEM.js');
8
- require('../../chunk-UZ2PWO4O.js');
9
- require('../../chunk-AY7HKAG2.js');
8
+ require('../../chunk-5YYRBKDP.js');
9
+ require('../../chunk-5P6AZJCN.js');
10
10
 
11
11
  // src/asserts/array/index.ts
12
12
  function array(arraySchema) {
13
- return new (0, _chunkLYNVPN3Rjs.ArraySchema)({ type: [], requiredValidations: [] }, arraySchema);
13
+ return new (0, _chunkVW4RMQD4js.ArraySchema)({ type: [], requiredValidations: [] }, arraySchema);
14
14
  }
15
15
 
16
16
 
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/array/index.js","../../../src/asserts/array/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACA;ACKO,SAAS,KAAA,CAA8B,WAAA,EAA8B;AAC1E,EAAA,OAAO,IAAI,iCAAA,CAAY,EAAE,IAAA,EAAM,CAAC,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAA,EAAG,WAAW,CAAA;AAC3E;ADHA;AACE;AACF,sBAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/array/index.js","sourcesContent":[null,"import { ArraySchema, WithArray } from '../../schemas/ArraySchema';\nimport { CommonSchema } from '../../schemas/CommonSchema';\n\n/**\n * @description Creates a new schema for validating arrays where each element must match the specified schema.\n * @template T\n * @param {T} arraySchema - The schema that each element of the array must match.\n * @returns {WithArray<T>} A new instance of `ArraySchema` for validating arrays of elements that match the specified schema.\n * @example\n * const schema = array(string());\n * parseOrFail(schema, ['hello', 'world']); // Validates successfully\n * parseOrFail(schema, ['hello', 123]); // Throws a validation error\n *\n * @instance Of ArraySchema\n */\nexport function array<T extends CommonSchema>(arraySchema: T): WithArray<T> {\n return new ArraySchema({ type: [], requiredValidations: [] }, arraySchema) as WithArray<T>;\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/array/index.js","../../../src/asserts/array/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC,mCAAgC;AAChC;AACA;ACMO,SAAS,KAAA,CAA8B,WAAA,EAA2C;AACvF,EAAA,OAAO,IAAI,iCAAA,CAAY,EAAE,IAAA,EAAM,CAAC,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAA,EAAG,WAAW,CAAA;AAC3E;ADJA;AACE;AACF,sBAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/array/index.js","sourcesContent":[null,"import { WithArray } from '../../commonTypes';\nimport { ArraySchema } from '../../schemas/ArraySchema';\nimport { CommonSchema } from '../../schemas/CommonSchema';\n\n/**\n * @description Creates a new schema for validating arrays where each element must match the specified schema.\n * @template T\n * @param {T} arraySchema - The schema that each element of the array must match.\n * @returns {WithArray<ArraySchema, T>} A new instance of `ArraySchema` for validating arrays of elements that match the specified schema.\n * @example\n * const schema = array(string());\n * parseOrFail(schema, ['hello', 'world']); // Validates successfully\n * parseOrFail(schema, ['hello', 123]); // Throws a validation error\n *\n * @instance Of ArraySchema\n */\nexport function array<T extends CommonSchema>(arraySchema: T): WithArray<ArraySchema, T> {\n return new ArraySchema({ type: [], requiredValidations: [] }, arraySchema) as WithArray<ArraySchema, T>;\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  ArraySchema
3
- } from "../../chunk-KBZUNXJB.mjs";
4
- import "../../chunk-AOUFWACR.mjs";
5
- import "../../chunk-ADSMWGDJ.mjs";
6
- import "../../chunk-5LLJ22IG.mjs";
3
+ } from "../../chunk-LPR3G5T3.mjs";
4
+ import "../../chunk-7NBOVYSP.mjs";
5
+ import "../../chunk-TRGMD7LA.mjs";
6
+ import "../../chunk-BNCT7NOR.mjs";
7
7
  import "../../chunk-YBVMP4EI.mjs";
8
- import "../../chunk-4GDBM5LP.mjs";
9
- import "../../chunk-NP64RC7B.mjs";
8
+ import "../../chunk-H32B3NHW.mjs";
9
+ import "../../chunk-FGZKNBDP.mjs";
10
10
 
11
11
  // src/asserts/array/index.ts
12
12
  function array(arraySchema) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/asserts/array/index.ts"],"sourcesContent":["import { ArraySchema, WithArray } from '../../schemas/ArraySchema';\nimport { CommonSchema } from '../../schemas/CommonSchema';\n\n/**\n * @description Creates a new schema for validating arrays where each element must match the specified schema.\n * @template T\n * @param {T} arraySchema - The schema that each element of the array must match.\n * @returns {WithArray<T>} A new instance of `ArraySchema` for validating arrays of elements that match the specified schema.\n * @example\n * const schema = array(string());\n * parseOrFail(schema, ['hello', 'world']); // Validates successfully\n * parseOrFail(schema, ['hello', 123]); // Throws a validation error\n *\n * @instance Of ArraySchema\n */\nexport function array<T extends CommonSchema>(arraySchema: T): WithArray<T> {\n return new ArraySchema({ type: [], requiredValidations: [] }, arraySchema) as WithArray<T>;\n}\n"],"mappings":";;;;;;;;;;;AAeO,SAAS,MAA8B,aAA8B;AAC1E,SAAO,IAAI,YAAY,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,EAAE,GAAG,WAAW;AAC3E;","names":[]}
1
+ {"version":3,"sources":["../../../src/asserts/array/index.ts"],"sourcesContent":["import { WithArray } from '../../commonTypes';\nimport { ArraySchema } from '../../schemas/ArraySchema';\nimport { CommonSchema } from '../../schemas/CommonSchema';\n\n/**\n * @description Creates a new schema for validating arrays where each element must match the specified schema.\n * @template T\n * @param {T} arraySchema - The schema that each element of the array must match.\n * @returns {WithArray<ArraySchema, T>} A new instance of `ArraySchema` for validating arrays of elements that match the specified schema.\n * @example\n * const schema = array(string());\n * parseOrFail(schema, ['hello', 'world']); // Validates successfully\n * parseOrFail(schema, ['hello', 123]); // Throws a validation error\n *\n * @instance Of ArraySchema\n */\nexport function array<T extends CommonSchema>(arraySchema: T): WithArray<ArraySchema, T> {\n return new ArraySchema({ type: [], requiredValidations: [] }, arraySchema) as WithArray<ArraySchema, T>;\n}\n"],"mappings":";;;;;;;;;;;AAgBO,SAAS,MAA8B,aAA2C;AACvF,SAAO,IAAI,YAAY,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,EAAE,GAAG,WAAW;AAC3E;","names":[]}
@@ -1,19 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUZ2PWO4Ojs = require('../../chunk-UZ2PWO4O.js');
3
+ var _chunk5YYRBKDPjs = require('../../chunk-5YYRBKDP.js');
4
4
 
5
5
 
6
- var _chunkAY7HKAG2js = require('../../chunk-AY7HKAG2.js');
6
+ var _chunk5P6AZJCNjs = require('../../chunk-5P6AZJCN.js');
7
7
 
8
8
  // src/asserts/array/maxArrayLength.ts
9
9
  var maxArrayLengthErrorMessage = "The received value length is greater than expected";
10
10
  var maxArrayLengthErrorKey = "a:maxArrayLength";
11
11
  var maxArrayLength = (expected) => (received, ctx) => {
12
- if (received.length > expected) _chunkAY7HKAG2js.guardException.call(void 0, expected, received, ctx, maxArrayLengthErrorMessage);
12
+ if (received.length > expected) _chunk5P6AZJCNjs.guardException.call(void 0, expected, received, ctx, maxArrayLengthErrorMessage);
13
13
  };
14
14
  maxArrayLength.key = maxArrayLengthErrorKey;
15
15
  maxArrayLength.message = maxArrayLengthErrorMessage;
16
- _chunkUZ2PWO4Ojs.setToDefaultLocale.call(void 0, maxArrayLength);
16
+ _chunk5YYRBKDPjs.setToDefaultLocale.call(void 0, maxArrayLength);
17
17
 
18
18
 
19
19
  exports.maxArrayLength = maxArrayLength;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  setToDefaultLocale
3
- } from "../../chunk-4GDBM5LP.mjs";
3
+ } from "../../chunk-H32B3NHW.mjs";
4
4
  import {
5
5
  guardException
6
- } from "../../chunk-NP64RC7B.mjs";
6
+ } from "../../chunk-FGZKNBDP.mjs";
7
7
 
8
8
  // src/asserts/array/maxArrayLength.ts
9
9
  var maxArrayLengthErrorMessage = "The received value length is greater than expected";
@@ -1,19 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUZ2PWO4Ojs = require('../../chunk-UZ2PWO4O.js');
3
+ var _chunk5YYRBKDPjs = require('../../chunk-5YYRBKDP.js');
4
4
 
5
5
 
6
- var _chunkAY7HKAG2js = require('../../chunk-AY7HKAG2.js');
6
+ var _chunk5P6AZJCNjs = require('../../chunk-5P6AZJCN.js');
7
7
 
8
8
  // src/asserts/array/minArrayLength.ts
9
9
  var minArrayLengthErrorMessage = "The received value length is less than expected";
10
10
  var minArrayLengthErrorKey = "a:minArrayLength";
11
11
  var minArrayLength = (expected) => (received, ctx) => {
12
- if (received.length < expected) _chunkAY7HKAG2js.guardException.call(void 0, expected, received, ctx, minArrayLengthErrorMessage);
12
+ if (received.length < expected) _chunk5P6AZJCNjs.guardException.call(void 0, expected, received, ctx, minArrayLengthErrorMessage);
13
13
  };
14
14
  minArrayLength.key = minArrayLengthErrorKey;
15
15
  minArrayLength.message = minArrayLengthErrorMessage;
16
- _chunkUZ2PWO4Ojs.setToDefaultLocale.call(void 0, minArrayLength);
16
+ _chunk5YYRBKDPjs.setToDefaultLocale.call(void 0, minArrayLength);
17
17
 
18
18
 
19
19
  exports.minArrayLength = minArrayLength;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  setToDefaultLocale
3
- } from "../../chunk-4GDBM5LP.mjs";
3
+ } from "../../chunk-H32B3NHW.mjs";
4
4
  import {
5
5
  guardException
6
- } from "../../chunk-NP64RC7B.mjs";
6
+ } from "../../chunk-FGZKNBDP.mjs";
7
7
 
8
8
  // src/asserts/array/minArrayLength.ts
9
9
  var minArrayLengthErrorMessage = "The received value length is less than expected";
@@ -1,19 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUZ2PWO4Ojs = require('../../chunk-UZ2PWO4O.js');
3
+ var _chunk5YYRBKDPjs = require('../../chunk-5YYRBKDP.js');
4
4
 
5
5
 
6
- var _chunkAY7HKAG2js = require('../../chunk-AY7HKAG2.js');
6
+ var _chunk5P6AZJCNjs = require('../../chunk-5P6AZJCN.js');
7
7
 
8
8
  // src/asserts/bigint/bigintMax.ts
9
9
  var bigintMaxErrorMessage = "The received value is greater than expected";
10
10
  var bigintMaxErrorKey = "bi:max";
11
11
  var bigintMax = (expected) => (received, ctx) => {
12
- if (expected < received) _chunkAY7HKAG2js.guardException.call(void 0, expected, received, ctx, bigintMaxErrorKey);
12
+ if (expected < received) _chunk5P6AZJCNjs.guardException.call(void 0, expected, received, ctx, bigintMaxErrorKey);
13
13
  };
14
14
  bigintMax.key = bigintMaxErrorKey;
15
15
  bigintMax.message = bigintMaxErrorMessage;
16
- _chunkUZ2PWO4Ojs.setToDefaultLocale.call(void 0, bigintMax);
16
+ _chunk5YYRBKDPjs.setToDefaultLocale.call(void 0, bigintMax);
17
17
 
18
18
 
19
19
  exports.bigintMax = bigintMax;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  setToDefaultLocale
3
- } from "../../chunk-4GDBM5LP.mjs";
3
+ } from "../../chunk-H32B3NHW.mjs";
4
4
  import {
5
5
  guardException
6
- } from "../../chunk-NP64RC7B.mjs";
6
+ } from "../../chunk-FGZKNBDP.mjs";
7
7
 
8
8
  // src/asserts/bigint/bigintMax.ts
9
9
  var bigintMaxErrorMessage = "The received value is greater than expected";
@@ -1,19 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUZ2PWO4Ojs = require('../../chunk-UZ2PWO4O.js');
3
+ var _chunk5YYRBKDPjs = require('../../chunk-5YYRBKDP.js');
4
4
 
5
5
 
6
- var _chunkAY7HKAG2js = require('../../chunk-AY7HKAG2.js');
6
+ var _chunk5P6AZJCNjs = require('../../chunk-5P6AZJCN.js');
7
7
 
8
8
  // src/asserts/bigint/bigintMaxExcluded.ts
9
9
  var bigintMaxExcludedErrorMessage = "The received value is greater than or equal to expected";
10
10
  var bigintMaxExcludedErrorKey = "bi:maxExcluded";
11
11
  var bigintMaxExcluded = (expected) => (received, ctx) => {
12
- if (expected <= received) _chunkAY7HKAG2js.guardException.call(void 0, expected, received, ctx, bigintMaxExcludedErrorKey);
12
+ if (expected <= received) _chunk5P6AZJCNjs.guardException.call(void 0, expected, received, ctx, bigintMaxExcludedErrorKey);
13
13
  };
14
14
  bigintMaxExcluded.key = bigintMaxExcludedErrorKey;
15
15
  bigintMaxExcluded.message = bigintMaxExcludedErrorMessage;
16
- _chunkUZ2PWO4Ojs.setToDefaultLocale.call(void 0, bigintMaxExcluded);
16
+ _chunk5YYRBKDPjs.setToDefaultLocale.call(void 0, bigintMaxExcluded);
17
17
 
18
18
 
19
19
  exports.bigintMaxExcluded = bigintMaxExcluded;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  setToDefaultLocale
3
- } from "../../chunk-4GDBM5LP.mjs";
3
+ } from "../../chunk-H32B3NHW.mjs";
4
4
  import {
5
5
  guardException
6
- } from "../../chunk-NP64RC7B.mjs";
6
+ } from "../../chunk-FGZKNBDP.mjs";
7
7
 
8
8
  // src/asserts/bigint/bigintMaxExcluded.ts
9
9
  var bigintMaxExcludedErrorMessage = "The received value is greater than or equal to expected";
@@ -1,19 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUZ2PWO4Ojs = require('../../chunk-UZ2PWO4O.js');
3
+ var _chunk5YYRBKDPjs = require('../../chunk-5YYRBKDP.js');
4
4
 
5
5
 
6
- var _chunkAY7HKAG2js = require('../../chunk-AY7HKAG2.js');
6
+ var _chunk5P6AZJCNjs = require('../../chunk-5P6AZJCN.js');
7
7
 
8
8
  // src/asserts/bigint/bigintMin.ts
9
9
  var bigintMinErrorMessage = "The received value is less than expected";
10
10
  var bigintMinErrorKey = "bi:min";
11
11
  var bigintMin = (expected) => (received, ctx) => {
12
- if (expected > received) _chunkAY7HKAG2js.guardException.call(void 0, expected, received, ctx, bigintMinErrorKey);
12
+ if (expected > received) _chunk5P6AZJCNjs.guardException.call(void 0, expected, received, ctx, bigintMinErrorKey);
13
13
  };
14
14
  bigintMin.key = bigintMinErrorKey;
15
15
  bigintMin.message = bigintMinErrorMessage;
16
- _chunkUZ2PWO4Ojs.setToDefaultLocale.call(void 0, bigintMin);
16
+ _chunk5YYRBKDPjs.setToDefaultLocale.call(void 0, bigintMin);
17
17
 
18
18
 
19
19
  exports.bigintMin = bigintMin;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  setToDefaultLocale
3
- } from "../../chunk-4GDBM5LP.mjs";
3
+ } from "../../chunk-H32B3NHW.mjs";
4
4
  import {
5
5
  guardException
6
- } from "../../chunk-NP64RC7B.mjs";
6
+ } from "../../chunk-FGZKNBDP.mjs";
7
7
 
8
8
  // src/asserts/bigint/bigintMin.ts
9
9
  var bigintMinErrorMessage = "The received value is less than expected";
@@ -1,19 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUZ2PWO4Ojs = require('../../chunk-UZ2PWO4O.js');
3
+ var _chunk5YYRBKDPjs = require('../../chunk-5YYRBKDP.js');
4
4
 
5
5
 
6
- var _chunkAY7HKAG2js = require('../../chunk-AY7HKAG2.js');
6
+ var _chunk5P6AZJCNjs = require('../../chunk-5P6AZJCN.js');
7
7
 
8
8
  // src/asserts/bigint/bigintMinExcluded.ts
9
9
  var bigintMinExcludedErrorMessage = "The received value is less than or equal to expected";
10
10
  var bigintMinExcludedErrorKey = "bi:minExcluded";
11
11
  var bigintMinExcluded = (expected) => (received, ctx) => {
12
- if (expected >= received) _chunkAY7HKAG2js.guardException.call(void 0, expected, received, ctx, bigintMinExcludedErrorKey);
12
+ if (expected >= received) _chunk5P6AZJCNjs.guardException.call(void 0, expected, received, ctx, bigintMinExcludedErrorKey);
13
13
  };
14
14
  bigintMinExcluded.key = bigintMinExcludedErrorKey;
15
15
  bigintMinExcluded.message = bigintMinExcludedErrorMessage;
16
- _chunkUZ2PWO4Ojs.setToDefaultLocale.call(void 0, bigintMinExcluded);
16
+ _chunk5YYRBKDPjs.setToDefaultLocale.call(void 0, bigintMinExcluded);
17
17
 
18
18
 
19
19
  exports.bigintMinExcluded = bigintMinExcluded;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  setToDefaultLocale
3
- } from "../../chunk-4GDBM5LP.mjs";
3
+ } from "../../chunk-H32B3NHW.mjs";
4
4
  import {
5
5
  guardException
6
- } from "../../chunk-NP64RC7B.mjs";
6
+ } from "../../chunk-FGZKNBDP.mjs";
7
7
 
8
8
  // src/asserts/bigint/bigintMinExcluded.ts
9
9
  var bigintMinExcludedErrorMessage = "The received value is less than or equal to expected";