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
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  CommonSchema
3
- } from "./chunk-AOUFWACR.mjs";
3
+ } from "./chunk-7NBOVYSP.mjs";
4
4
  import {
5
5
  ctxSymbol
6
- } from "./chunk-5LLJ22IG.mjs";
6
+ } from "./chunk-BNCT7NOR.mjs";
7
7
  import {
8
8
  BuildSchemaError
9
- } from "./chunk-NP64RC7B.mjs";
9
+ } from "./chunk-FGZKNBDP.mjs";
10
10
 
11
11
  // src/schemas/ArraySchema.ts
12
12
  var ArraySchema = class extends CommonSchema {
@@ -25,4 +25,4 @@ var ArraySchema = class extends CommonSchema {
25
25
  export {
26
26
  ArraySchema
27
27
  };
28
- //# sourceMappingURL=chunk-KBZUNXJB.mjs.map
28
+ //# sourceMappingURL=chunk-LPR3G5T3.mjs.map
@@ -1 +1 @@
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 protected _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,EAClC,SAAS;AAAA,EACnB,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
+ {"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 protected _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"],"mappings":";;;;;;;;;;;AAIO,IAAM,cAAN,cAA0B,aAAa;AAAA,EAClC,SAAS;AAAA,EACnB,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,9 +1,9 @@
1
1
  import {
2
2
  CommonSchema
3
- } from "./chunk-AOUFWACR.mjs";
3
+ } from "./chunk-7NBOVYSP.mjs";
4
4
  import {
5
5
  ctxSymbol
6
- } from "./chunk-5LLJ22IG.mjs";
6
+ } from "./chunk-BNCT7NOR.mjs";
7
7
 
8
8
  // src/schemas/DateSchema.ts
9
9
  var DateSchema = class extends CommonSchema {
@@ -17,4 +17,4 @@ var DateSchema = class extends CommonSchema {
17
17
  export {
18
18
  DateSchema
19
19
  };
20
- //# sourceMappingURL=chunk-2MFBOVP2.mjs.map
20
+ //# sourceMappingURL=chunk-MHBY5OIQ.mjs.map
@@ -1,24 +1,24 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
2
 
3
- var _chunkSPWF5IFUjs = require('./chunk-SPWF5IFU.js');
3
+ var _chunkHP3DRZWKjs = require('./chunk-HP3DRZWK.js');
4
4
 
5
5
 
6
- var _chunkW2GOLG3Kjs = require('./chunk-W2GOLG3K.js');
6
+ var _chunkIZ3CBVEEjs = require('./chunk-IZ3CBVEE.js');
7
7
 
8
8
 
9
9
  var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
10
10
 
11
11
 
12
- var _chunk3ZPLJ5KCjs = require('./chunk-3ZPLJ5KC.js');
12
+ var _chunkQIDWASOCjs = require('./chunk-QIDWASOC.js');
13
13
 
14
14
 
15
- var _chunk3IOQH3K4js = require('./chunk-3IOQH3K4.js');
15
+ var _chunkSHJVKSEZjs = require('./chunk-SHJVKSEZ.js');
16
16
 
17
17
 
18
- var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
18
+ var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
19
19
 
20
20
  // src/schemas/NumberSchema.ts
21
- var NumberSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
21
+ var NumberSchema = (_class = class extends _chunkSHJVKSEZjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
22
22
  __init() {this._number = 1}
23
23
 
24
24
  /**
@@ -30,10 +30,10 @@ var NumberSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {constr
30
30
  * @example - number().equalTo(42); // Infers the type 42
31
31
  */
32
32
  equalTo(expectedValue) {
33
- if (this.limit) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
33
+ if (this.limit) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
34
34
  this.limit = true;
35
- _chunk3ZPLJ5KCjs._setStrictType.call(void 0, this, expectedValue);
36
- return this.custom(_chunkSPWF5IFUjs.equalTo.call(void 0, expectedValue));
35
+ _chunkQIDWASOCjs._setStrictType.call(void 0, this, expectedValue);
36
+ return this.custom(_chunkHP3DRZWKjs.equalTo.call(void 0, expectedValue));
37
37
  }
38
38
  /**
39
39
  * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
@@ -45,14 +45,14 @@ var NumberSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {constr
45
45
  * number().oneOfValues([5, 7]); // Infers the type 5 | 7
46
46
  */
47
47
  oneOfValues(expectedValue) {
48
- if (this.limit) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
48
+ if (this.limit) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
49
49
  this.limit = true;
50
- _chunk3ZPLJ5KCjs._setStrictType.call(void 0, this, expectedValue);
51
- return this.custom(_chunkW2GOLG3Kjs.oneOfValues.call(void 0, expectedValue));
50
+ _chunkQIDWASOCjs._setStrictType.call(void 0, this, expectedValue);
51
+ return this.custom(_chunkIZ3CBVEEjs.oneOfValues.call(void 0, expectedValue));
52
52
  }
53
53
  }, _class);
54
54
 
55
55
 
56
56
 
57
57
  exports.NumberSchema = NumberSchema;
58
- //# sourceMappingURL=chunk-EU3ZZF7Y.js.map
58
+ //# sourceMappingURL=chunk-MLNQZ445.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-MLNQZ445.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;ACXO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBACnC,QAAA,EAAU,EAAA;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,OAAA,CAA0B,aAAA,EAA2C;AAC1E,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,EAWO,WAAA,CAA8B,aAAA,EAA6C;AAChF,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;ADWA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-MLNQZ445.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { WithBGuardType } from '../commonTypes';\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 protected _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 public equalTo<Y extends number>(expectedValue: Y): WithBGuardType<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 WithBGuardType<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 public oneOfValues<Y extends number>(expectedValue: Y[]): WithBGuardType<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 WithBGuardType<this, Y>;\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkX762EUSZjs = require('./chunk-X762EUSZ.js');
4
+
5
+ // src/helpers/setStrictType.ts
6
+ function _setStrictType(that, val) {
7
+ that[_chunkX762EUSZjs.ctxSymbol].strictType = true;
8
+ that[_chunkX762EUSZjs.ctxSymbol].strictTypeValue = val;
9
+ }
10
+
11
+
12
+
13
+ exports._setStrictType = _setStrictType;
14
+ //# sourceMappingURL=chunk-QIDWASOC.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-3ZPLJ5KC.js","../src/helpers/setStrictType.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACDO,SAAS,cAAA,CAAe,IAAA,EAAoB,GAAA,EAAc;AAC/D,EAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,EAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,gBAAA,EAAkB,GAAA;AACpC;ADGA;AACA;AACE;AACF,wCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-3ZPLJ5KC.js","sourcesContent":[null,"import { ctxSymbol } from './core';\nimport type { CommonSchema } from '../schemas/CommonSchema';\n\nexport function _setStrictType(that: CommonSchema, val: unknown) {\n that[ctxSymbol].strictType = true;\n that[ctxSymbol].strictTypeValue = val;\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-QIDWASOC.js","../src/helpers/setStrictType.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACDO,SAAS,cAAA,CAAe,IAAA,EAAoB,GAAA,EAAc;AAC/D,EAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,EAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,gBAAA,EAAkB,GAAA;AACpC;ADGA;AACA;AACE;AACF,wCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-QIDWASOC.js","sourcesContent":[null,"import { ctxSymbol } from './core';\nimport type { CommonSchema } from '../schemas/CommonSchema';\n\nexport function _setStrictType(that: CommonSchema, val: unknown) {\n that[ctxSymbol].strictType = true;\n that[ctxSymbol].strictTypeValue = val;\n}\n"]}
@@ -0,0 +1,136 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkG55SHHARjs = require('./chunk-G55SHHAR.js');
4
+
5
+
6
+ var _chunkX762EUSZjs = require('./chunk-X762EUSZ.js');
7
+
8
+
9
+ var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
10
+
11
+ // src/schemas/CommonSchema.ts
12
+ var CommonSchema = class {
13
+
14
+ constructor(ctx) {
15
+ this[_chunkX762EUSZjs.ctxSymbol] = ctx;
16
+ }
17
+ /**
18
+ * @param validators - One or more custom validation functions.
19
+ * @returns {this} The schema instance with the added custom validation.
20
+ */
21
+ custom(...validators) {
22
+ this.defaultValueCheck();
23
+ this[_chunkX762EUSZjs.ctxSymbol].requiredValidations.push(...validators);
24
+ return this;
25
+ }
26
+ /**
27
+ * Marks the schema as nullable, allowing the value to be `null`.
28
+ *
29
+ * @returns {WithNull<this>} The schema instance marked as nullable.
30
+ */
31
+ nullable() {
32
+ this.defaultValueCheck();
33
+ this[_chunkX762EUSZjs.ctxSymbol].isNullable = true;
34
+ return this;
35
+ }
36
+ /**
37
+ * Marks the schema as optional, allowing the value to be `undefined`.
38
+ *
39
+ * @returns {WithUndefined<this>} The schema instance marked as optional.
40
+ */
41
+ optional() {
42
+ this.defaultValueCheck();
43
+ this[_chunkX762EUSZjs.ctxSymbol].isOptional = true;
44
+ return this;
45
+ }
46
+ /**
47
+ * Marks the schema as optional, allowing the value to be `undefined`.
48
+ *
49
+ * @returns {this} The schema instance. This method should be used as a last one because it does the check of previous methods and
50
+ */
51
+ default(defaultValue) {
52
+ const ctx = this[_chunkX762EUSZjs.ctxSymbol];
53
+ if (ctx.isOptional) {
54
+ throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(`Cannot call method 'default' after method 'optional'`);
55
+ }
56
+ try {
57
+ _chunkG55SHHARjs.parseOrFail.call(void 0, this, defaultValue);
58
+ } catch (e) {
59
+ throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(e.message);
60
+ }
61
+ this[_chunkX762EUSZjs.ctxSymbol].defaultValue = defaultValue;
62
+ return this;
63
+ }
64
+ /**
65
+ * Applies a transformation to the input value before any validation occurs.
66
+ * The transformation should return a value of the same type as the inferred type of the schema,
67
+ * ensuring that the overall type is not altered.
68
+ *
69
+ * @template In - The type of the input value before transformation (defaults to `unknown`).
70
+ * @param {TransformCallback<In, InferType<this>>} cb - The callback function that performs the transformation.
71
+ * @returns {this} The updated schema with the applied transformation.
72
+ *
73
+ * @example
74
+ * const schema = string()
75
+ * .nullable()
76
+ * .transformBeforeValidation((val) => val + '') // Ensure the value is a string
77
+ * .transformBeforeValidation((val: string) => (val === '' ? null : val)); // Convert empty strings to null
78
+ *
79
+ * // Parse 'test' will pass as 'test' is a valid string longer than 3 characters.
80
+ * parseOrFail(schema, 'test');
81
+ *
82
+ * // Parsing '' will be transformed to null and will pass due to .nullable().
83
+ * parseOrFail(schema, '');
84
+ */
85
+ transformBeforeValidation(cb) {
86
+ const ctx = this[_chunkX762EUSZjs.ctxSymbol];
87
+ if (ctx.transformListBefore) {
88
+ ctx.transformListBefore.push(cb);
89
+ } else {
90
+ ctx.transformListBefore = [cb];
91
+ }
92
+ return this;
93
+ }
94
+ /**
95
+ * Assigns a unique identifier to the schema.
96
+ * This ID can be used to track or map validation errors back to specific fields
97
+ * in a form or other structures.
98
+ *
99
+ * @param {string} value - The unique identifier for the schema.
100
+ * @returns {this} The updated schema with the assigned ID.
101
+ *
102
+ * @example
103
+ * const schema = string().id('username');
104
+ */
105
+ id(value) {
106
+ return this.meta("id", value);
107
+ }
108
+ /**
109
+ * Provides a description for the schema, offering additional context or information.
110
+ * The description can be used when displaying validation errors or for documentation purposes.
111
+ *
112
+ * @param {string} value - The description for the schema.
113
+ * @returns {this} The updated schema with the added description.
114
+ *
115
+ * @example
116
+ * const schema = string().description('The username of the account holder.');
117
+ */
118
+ description(value) {
119
+ return this.meta("description", value);
120
+ }
121
+ meta(key, value) {
122
+ const ctx = this[_chunkX762EUSZjs.ctxSymbol];
123
+ ctx.meta = { ...ctx.meta, [key]: value };
124
+ return this;
125
+ }
126
+ defaultValueCheck() {
127
+ if (this[_chunkX762EUSZjs.ctxSymbol].defaultValue !== void 0) {
128
+ throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)("Default value must be the last method called in schema");
129
+ }
130
+ }
131
+ };
132
+
133
+
134
+
135
+ exports.CommonSchema = CommonSchema;
136
+ //# sourceMappingURL=chunk-SHJVKSEZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-SHJVKSEZ.js","../src/schemas/CommonSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACeO,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,EAMO,MAAA,CAAA,GAAU,UAAA,EAAwC;AACvD,IAAA,IAAA,CAAK,iBAAA,CAAkB,CAAA;AACvB,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,EAOO,QAAA,CAAA,EAA2B;AAChC,IAAA,IAAA,CAAK,iBAAA,CAAkB,CAAA;AACvB,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,QAAA,CAAA,EAAgC;AACrC,IAAA,IAAA,CAAK,iBAAA,CAAkB,CAAA;AACvB,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,OAAA,CAAQ,YAAA,EAAqC;AAClD,IAAA,MAAM,IAAA,EAAM,IAAA,CAAK,0BAAS,CAAA;AAC1B,IAAA,GAAA,CAAI,GAAA,CAAI,UAAA,EAAY;AAClB,MAAA,MAAM,IAAI,sCAAA,CAAiB,CAAA,oDAAA,CAAsD,CAAA;AAAA,IACnF;AAEA,IAAA,IAAI;AACF,MAAA,0CAAA,IAAY,EAAM,YAAY,CAAA;AAAA,IAChC,EAAA,MAAA,CAAS,CAAA,EAAG;AACV,MAAA,MAAM,IAAI,sCAAA,CAAkB,CAAA,CAAY,OAAO,CAAA;AAAA,IACjD;AAEA,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,aAAA,EAAe,YAAA;AAC/B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBO,yBAAA,CAA8B,EAAA,EAAkD;AACrF,IAAA,MAAM,IAAA,EAAM,IAAA,CAAK,0BAAS,CAAA;AAC1B,IAAA,GAAA,CAAI,GAAA,CAAI,mBAAA,EAAqB;AAC3B,MAAA,GAAA,CAAI,mBAAA,CAAoB,IAAA,CAAK,EAAE,CAAA;AAAA,IACjC,EAAA,KAAO;AACL,MAAA,GAAA,CAAI,oBAAA,EAAsB,CAAC,EAAE,CAAA;AAAA,IAC/B;AAEA,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaO,EAAA,CAAG,KAAA,EAAqB;AAC7B,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,EAAM,KAAK,CAAA;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYO,WAAA,CAAY,KAAA,EAAqB;AACtC,IAAA,OAAO,IAAA,CAAK,IAAA,CAAK,aAAA,EAAe,KAAK,CAAA;AAAA,EACvC;AAAA,EAEQ,IAAA,CAAK,GAAA,EAAa,KAAA,EAAqB;AAC7C,IAAA,MAAM,IAAA,EAAM,IAAA,CAAK,0BAAS,CAAA;AAC1B,IAAA,GAAA,CAAI,KAAA,EAAO,EAAE,GAAG,GAAA,CAAI,IAAA,EAAM,CAAC,GAAG,CAAA,EAAG,MAAM,CAAA;AACvC,IAAA,OAAO,IAAA;AAAA,EACT;AAAA,EAEU,iBAAA,CAAA,EAAoB;AAC5B,IAAA,GAAA,CAAI,IAAA,CAAK,0BAAS,CAAA,CAAE,aAAA,IAAiB,KAAA,CAAA,EAAW;AAC9C,MAAA,MAAM,IAAI,sCAAA,CAAiB,wDAAwD,CAAA;AAAA,IACrF;AAAA,EACF;AACF,CAAA;ADzBA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-SHJVKSEZ.js","sourcesContent":[null,"import { InferType } from '../InferType';\nimport { MetaContext, BaseType, RequiredValidation, WithNull, WithUndefined, TransformCallback } from '../commonTypes';\nimport { BuildSchemaError } from '../exceptions';\nimport { ctxSymbol } from '../helpers/core';\nimport { parseOrFail } from '../parseOrFail';\n\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport interface ValidatorContext {\n type: BaseType[];\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 defaultValue?: unknown;\n meta?: MetaContext;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformListBefore?: TransformCallback<any, any>[];\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 public custom(...validators: RequiredValidation[]): this {\n this.defaultValueCheck();\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 public nullable(): WithNull<this> {\n this.defaultValueCheck();\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 public optional(): WithUndefined<this> {\n this.defaultValueCheck();\n this[ctxSymbol].isOptional = true;\n return this as WithUndefined<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {this} The schema instance. This method should be used as a last one because it does the check of previous methods and\n */\n public default(defaultValue: InferType<this>): this {\n const ctx = this[ctxSymbol];\n if (ctx.isOptional) {\n throw new BuildSchemaError(`Cannot call method 'default' after method 'optional'`);\n }\n\n try {\n parseOrFail(this, defaultValue);\n } catch (e) {\n throw new BuildSchemaError((e as Error).message);\n }\n\n this[ctxSymbol].defaultValue = defaultValue;\n return this;\n }\n\n /**\n * Applies a transformation to the input value before any validation occurs.\n * The transformation should return a value of the same type as the inferred type of the schema,\n * ensuring that the overall type is not altered.\n *\n * @template In - The type of the input value before transformation (defaults to `unknown`).\n * @param {TransformCallback<In, InferType<this>>} cb - The callback function that performs the transformation.\n * @returns {this} The updated schema with the applied transformation.\n *\n * @example\n * const schema = string()\n * .nullable()\n * .transformBeforeValidation((val) => val + '') // Ensure the value is a string\n * .transformBeforeValidation((val: string) => (val === '' ? null : val)); // Convert empty strings to null\n *\n * // Parse 'test' will pass as 'test' is a valid string longer than 3 characters.\n * parseOrFail(schema, 'test');\n *\n * // Parsing '' will be transformed to null and will pass due to .nullable().\n * parseOrFail(schema, '');\n */\n public transformBeforeValidation<In>(cb: TransformCallback<In, InferType<this>>): this {\n const ctx = this[ctxSymbol];\n if (ctx.transformListBefore) {\n ctx.transformListBefore.push(cb);\n } else {\n ctx.transformListBefore = [cb];\n }\n\n return this;\n }\n\n /**\n * Assigns a unique identifier to the schema.\n * This ID can be used to track or map validation errors back to specific fields\n * in a form or other structures.\n *\n * @param {string} value - The unique identifier for the schema.\n * @returns {this} The updated schema with the assigned ID.\n *\n * @example\n * const schema = string().id('username');\n */\n public id(value: string): this {\n return this.meta('id', value);\n }\n\n /**\n * Provides a description for the schema, offering additional context or information.\n * The description can be used when displaying validation errors or for documentation purposes.\n *\n * @param {string} value - The description for the schema.\n * @returns {this} The updated schema with the added description.\n *\n * @example\n * const schema = string().description('The username of the account holder.');\n */\n public description(value: string): this {\n return this.meta('description', value);\n }\n\n private meta(key: string, value: string): this {\n const ctx = this[ctxSymbol];\n ctx.meta = { ...ctx.meta, [key]: value };\n return this;\n }\n\n protected defaultValueCheck() {\n if (this[ctxSymbol].defaultValue !== undefined) {\n throw new BuildSchemaError('Default value must be the last method called in schema');\n }\n }\n}\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 MapMixTypes<T extends BaseType[]> = T extends (infer U)[]\n ? U extends keyof TypeMapping\n ? TypeMapping[U]\n : never\n : never;\n"]}
@@ -1,19 +1,21 @@
1
1
  import {
2
+ ctxSymbol,
2
3
  innerCheck
3
- } from "./chunk-5LLJ22IG.mjs";
4
+ } from "./chunk-BNCT7NOR.mjs";
4
5
  import {
5
6
  getTranslationByLocale
6
- } from "./chunk-4GDBM5LP.mjs";
7
+ } from "./chunk-H32B3NHW.mjs";
7
8
  import {
8
9
  ValidationError
9
- } from "./chunk-NP64RC7B.mjs";
10
+ } from "./chunk-FGZKNBDP.mjs";
10
11
 
11
12
  // src/parseOrFail.ts
12
13
  function parseOrFail(schema, receivedValue, options) {
13
14
  try {
14
15
  return innerCheck(schema, receivedValue, {
15
16
  t: getTranslationByLocale(options?.lng),
16
- pathToError: ""
17
+ pathToError: "",
18
+ meta: schema[ctxSymbol].meta
17
19
  });
18
20
  } catch (e) {
19
21
  if (e instanceof ValidationError) throw e;
@@ -24,4 +26,4 @@ function parseOrFail(schema, receivedValue, options) {
24
26
  export {
25
27
  parseOrFail
26
28
  };
27
- //# sourceMappingURL=chunk-ADSMWGDJ.mjs.map
29
+ //# sourceMappingURL=chunk-TRGMD7LA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/parseOrFail.ts"],"sourcesContent":["import type { InferType } from './InferType';\nimport type { CommonSchema } from './schemas/CommonSchema';\nimport { ctxSymbol, innerCheck } from './helpers/core';\nimport { getTranslationByLocale } from './translationMap';\nimport { ValidationError } from './exceptions';\ninterface ParseOptions {\n /**\n * Set language keyword to map error messages.\n * @default 'default'\n * @example 'sr' or 'Serbia' or any string to identify language\n */\n lng?: string;\n}\n\n/**\n * Parses and validates a value against the provided schema, returning a type-safe result.\n *\n * This function will throw a `ValidationError` if the value does not conform to the schema.\n * The inferred TypeScript type of the returned value will match the structure defined by the schema.\n *\n * @template T\n * @param {T} schema - The schema to validate the received value against. This schema dictates the expected structure and type of the value.\n * @param {unknown} receivedValue - The value to be validated and parsed according to the schema.\n * @param {ParseOptions} options - Options\n * @param {ParseOptions.lng} options.lng - Set language keyword to map Error message\n * @returns {InferType<T>} The validated value, with its TypeScript type inferred from the schema.\n *\n * @throws {ValidationError} If the received value does not match the schema, a `ValidationError` will be thrown.\n * @throws {Error} If an unexpected error occurs during validation, an error will be thrown with a generic message.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number(),\n * });\n *\n * const result = parseOrFail(schema, { name: 'Alice', age: 30 });\n * // result will be inferred as { name: string; age: number }\n *\n * parseOrFail(schema, { name: 'Alice', age: '30' });\n * // Throws ValidationError because 'age' should be a number, not a string.\n */\nexport function parseOrFail<T extends CommonSchema>(\n schema: T,\n receivedValue: unknown,\n options?: ParseOptions,\n): InferType<T> {\n try {\n return innerCheck(schema, receivedValue, {\n t: getTranslationByLocale(options?.lng),\n pathToError: '',\n meta: schema[ctxSymbol].meta,\n }) as InferType<T>;\n } catch (e) {\n if (e instanceof ValidationError) throw e;\n /* istanbul ignore next */\n throw new Error('Something unexpected happened');\n }\n}\n"],"mappings":";;;;;;;;;;;;AA0CO,SAAS,YACd,QACA,eACA,SACc;AACd,MAAI;AACF,WAAO,WAAW,QAAQ,eAAe;AAAA,MACvC,GAAG,uBAAuB,SAAS,GAAG;AAAA,MACtC,aAAa;AAAA,MACb,MAAM,OAAO,SAAS,EAAE;AAAA,IAC1B,CAAC;AAAA,EACH,SAAS,GAAG;AACV,QAAI,aAAa,gBAAiB,OAAM;AAExC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AACF;","names":[]}
@@ -1,12 +1,13 @@
1
1
  import {
2
+ ctxSymbol,
2
3
  innerCheck
3
- } from "./chunk-5LLJ22IG.mjs";
4
+ } from "./chunk-BNCT7NOR.mjs";
4
5
  import {
5
6
  getTranslationByLocale
6
- } from "./chunk-4GDBM5LP.mjs";
7
+ } from "./chunk-H32B3NHW.mjs";
7
8
  import {
8
9
  ValidationError
9
- } from "./chunk-NP64RC7B.mjs";
10
+ } from "./chunk-FGZKNBDP.mjs";
10
11
 
11
12
  // src/parse.ts
12
13
  function parse(schema, receivedValue, options) {
@@ -15,7 +16,8 @@ function parse(schema, receivedValue, options) {
15
16
  t: getTranslationByLocale(options?.lng),
16
17
  pathToError: "",
17
18
  getAllErrors: options?.getAllErrors,
18
- errors: []
19
+ errors: [],
20
+ meta: schema[ctxSymbol].meta
19
21
  };
20
22
  const parsedValue = innerCheck(schema, receivedValue, ctx);
21
23
  if (ctx.getAllErrors && ctx.errors.length) {
@@ -33,7 +35,8 @@ function parse(schema, receivedValue, options) {
33
35
  message: "Something unexpected happened",
34
36
  expected: "",
35
37
  received: "",
36
- pathToError: ""
38
+ pathToError: "",
39
+ meta: void 0
37
40
  }
38
41
  ],
39
42
  void 0
@@ -44,4 +47,4 @@ function parse(schema, receivedValue, options) {
44
47
  export {
45
48
  parse
46
49
  };
47
- //# sourceMappingURL=chunk-OKF3BVUD.mjs.map
50
+ //# sourceMappingURL=chunk-TV5IZY4L.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/parse.ts"],"sourcesContent":["import { InferType } from './InferType';\nimport { ctxSymbol, innerCheck } from './helpers/core';\nimport { getTranslationByLocale } from './translationMap';\nimport { ValidationError } from './exceptions';\nimport { CommonSchema } from './schemas/CommonSchema';\nimport { ExceptionContext, ValidationErrorData } from './commonTypes';\n\ninterface ParseOptions {\n /**\n * Set language keyword to map error messages.\n * @default 'default'\n * @example 'sr' or 'Serbia' or any string to identify language\n */\n lng?: string;\n\n /**\n * If true, collects all validation errors and returns them.\n * If false or undefined, returns the first validation error it can find and stops looking,\n * which provides a small runtime optimization.\n * @default undefined\n */\n getAllErrors?: boolean;\n}\n\n/**\n * Parses and validates a value against the provided schema, returning a type-safe parsedValue.\n *\n * This function will throw a `ValidationError` if the value does not conform to the schema.\n * The inferred TypeScript type of the returned value will match the structure defined by the schema.\n *\n * @template T\n * @param {T} schema - The schema to validate the received value against. This schema dictates the expected structure and type of the value.\n * @param {unknown} receivedValue - The value to be validated and parsed according to the schema.\n * @param {ParseOptions} options - Options\n * @param {ParseOptions.lng} options.lng - Set language keyword to map Error messages\n * @param {ParseOptions.lng} options.getAllErrors - If `false` or `undefined` - returns the first validation error it can find and stops looking, which provides a small runtime optimization.\n * @returns {[undefined, InferType<T>]} A tuple of [undefined, InferType<T>] if parsing is successful.\n * @returns {[ValidationErrorData[], undefined]} A tuple of [ValidationErrorData[], undefined]] if errors occur.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number(),\n * });\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: 30 });\n * // parsedValue will be inferred as { name: string; age: number }\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: '30' });\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // Array 'errors' returns only one element.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { getAllErrors: true});\n * // Returns array \"errors\" with multiple errors because 'age' should be a number and 'name' a string.\n * // With provided options { getAllErrors: true}, we can expecte more than one error in 'errors' array.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { lng: 'SR'});\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // With provided options { lng: 'SR'}, errors will be translated to a language mapped with keyword 'SR'\n */\nexport function parse<T extends CommonSchema>(\n schema: T,\n receivedValue: unknown,\n options?: ParseOptions,\n): [ValidationErrorData[], undefined] | [undefined, InferType<T>] {\n try {\n const ctx: ExceptionContext = {\n t: getTranslationByLocale(options?.lng),\n pathToError: '',\n getAllErrors: options?.getAllErrors,\n errors: [],\n meta: schema[ctxSymbol].meta,\n };\n\n const parsedValue = innerCheck(schema, receivedValue, ctx) as InferType<T>;\n\n if (ctx.getAllErrors && ctx.errors.length) {\n return [ctx.errors, undefined];\n }\n\n return [undefined, parsedValue];\n } catch (e) {\n if (e instanceof ValidationError) {\n delete e.stack;\n return [[e], undefined];\n }\n /* istanbul ignore next */\n return [\n [\n {\n message: 'Something unexpected happened',\n expected: '',\n received: '',\n pathToError: '',\n meta: undefined,\n },\n ],\n undefined,\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;AA+DO,SAAS,MACd,QACA,eACA,SACgE;AAChE,MAAI;AACF,UAAM,MAAwB;AAAA,MAC5B,GAAG,uBAAuB,SAAS,GAAG;AAAA,MACtC,aAAa;AAAA,MACb,cAAc,SAAS;AAAA,MACvB,QAAQ,CAAC;AAAA,MACT,MAAM,OAAO,SAAS,EAAE;AAAA,IAC1B;AAEA,UAAM,cAAc,WAAW,QAAQ,eAAe,GAAG;AAEzD,QAAI,IAAI,gBAAgB,IAAI,OAAO,QAAQ;AACzC,aAAO,CAAC,IAAI,QAAQ,MAAS;AAAA,IAC/B;AAEA,WAAO,CAAC,QAAW,WAAW;AAAA,EAChC,SAAS,GAAG;AACV,QAAI,aAAa,iBAAiB;AAChC,aAAO,EAAE;AACT,aAAO,CAAC,CAAC,CAAC,GAAG,MAAS;AAAA,IACxB;AAEA,WAAO;AAAA,MACL;AAAA,QACE;AAAA,UACE,SAAS;AAAA,UACT,UAAU;AAAA,UACV,UAAU;AAAA,UACV,aAAa;AAAA,UACb,MAAM;AAAA,QACR;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,27 +1,27 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
2
 
3
- var _chunk3IOQH3K4js = require('./chunk-3IOQH3K4.js');
3
+ var _chunkSHJVKSEZjs = require('./chunk-SHJVKSEZ.js');
4
4
 
5
5
 
6
- var _chunkPIBDJJUUjs = require('./chunk-PIBDJJUU.js');
6
+ var _chunkX762EUSZjs = require('./chunk-X762EUSZ.js');
7
7
 
8
8
 
9
- var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
9
+ var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
10
10
 
11
11
  // src/schemas/ObjectSchema.ts
12
- var ObjectSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {
12
+ var ObjectSchema = (_class = class extends _chunkSHJVKSEZjs.CommonSchema {
13
13
  __init() {this._object = 1}
14
14
  constructor(ctx, shapeSchema) {
15
15
  super(ctx);_class.prototype.__init.call(this);;
16
16
  this.validateObjectEntry(shapeSchema);
17
- this[_chunkPIBDJJUUjs.ctxSymbol].object = shapeSchema;
17
+ this[_chunkX762EUSZjs.ctxSymbol].object = shapeSchema;
18
18
  }
19
19
  validateObjectEntry(shapeSchema) {
20
- if (!shapeSchema) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)("Missing schema in object method");
21
- if (shapeSchema instanceof _chunk3IOQH3K4js.CommonSchema) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)("Invalid schema in object");
20
+ if (!shapeSchema) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)("Missing schema in object method");
21
+ if (shapeSchema instanceof _chunkSHJVKSEZjs.CommonSchema) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)("Invalid schema in object");
22
22
  for (const [key, value] of Object.entries(shapeSchema)) {
23
- if (!(value instanceof _chunk3IOQH3K4js.CommonSchema))
24
- throw new (0, _chunkAY7HKAG2js.BuildSchemaError)(`Invalid schema in object method for property '${key}'`);
23
+ if (!(value instanceof _chunkSHJVKSEZjs.CommonSchema))
24
+ throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(`Invalid schema in object method for property '${key}'`);
25
25
  }
26
26
  }
27
27
  /**
@@ -42,7 +42,7 @@ var ObjectSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {
42
42
  * // No error thrown
43
43
  */
44
44
  allowUnrecognized() {
45
- this[_chunkPIBDJJUUjs.ctxSymbol].allowUnrecognizedObjectProps = true;
45
+ this[_chunkX762EUSZjs.ctxSymbol].allowUnrecognizedObjectProps = true;
46
46
  return this;
47
47
  }
48
48
  }, _class);
@@ -50,4 +50,4 @@ var ObjectSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {
50
50
 
51
51
 
52
52
  exports.ObjectSchema = ObjectSchema;
53
- //# sourceMappingURL=chunk-OO6BTBVP.js.map
53
+ //# sourceMappingURL=chunk-U4USIJV3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-OO6BTBVP.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,iBACnC,QAAA,EAAU,EAAA;AAAA,EACpB,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-OO6BTBVP.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 protected _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
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-U4USIJV3.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,iBACnC,QAAA,EAAU,EAAA;AAAA,EACpB,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-U4USIJV3.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 protected _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"]}
@@ -1,24 +1,24 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
2
 
3
- var _chunkSPWF5IFUjs = require('./chunk-SPWF5IFU.js');
3
+ var _chunkHP3DRZWKjs = require('./chunk-HP3DRZWK.js');
4
4
 
5
5
 
6
- var _chunkW2GOLG3Kjs = require('./chunk-W2GOLG3K.js');
6
+ var _chunkIZ3CBVEEjs = require('./chunk-IZ3CBVEE.js');
7
7
 
8
8
 
9
9
  var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
10
10
 
11
11
 
12
- var _chunk3ZPLJ5KCjs = require('./chunk-3ZPLJ5KC.js');
12
+ var _chunkQIDWASOCjs = require('./chunk-QIDWASOC.js');
13
13
 
14
14
 
15
- var _chunk3IOQH3K4js = require('./chunk-3IOQH3K4.js');
15
+ var _chunkSHJVKSEZjs = require('./chunk-SHJVKSEZ.js');
16
16
 
17
17
 
18
- var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
18
+ var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
19
19
 
20
20
  // src/schemas/BigIntSchema.ts
21
- var BigIntSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
21
+ var BigIntSchema = (_class = class extends _chunkSHJVKSEZjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
22
22
  __init() {this._bigint = 1}
23
23
 
24
24
  /**
@@ -32,8 +32,8 @@ var BigIntSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {constr
32
32
  equalTo(expectedValue) {
33
33
  this.defaultValueCheck();
34
34
  this.limitCheck();
35
- _chunk3ZPLJ5KCjs._setStrictType.call(void 0, this, `${expectedValue}n`);
36
- return this.custom(_chunkSPWF5IFUjs.equalTo.call(void 0, expectedValue));
35
+ _chunkQIDWASOCjs._setStrictType.call(void 0, this, `${expectedValue}n`);
36
+ return this.custom(_chunkHP3DRZWKjs.equalTo.call(void 0, expectedValue));
37
37
  }
38
38
  /**
39
39
  * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
@@ -47,14 +47,14 @@ var BigIntSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {constr
47
47
  oneOfValues(expectedValue) {
48
48
  this.defaultValueCheck();
49
49
  this.limitCheck();
50
- _chunk3ZPLJ5KCjs._setStrictType.call(void 0,
50
+ _chunkQIDWASOCjs._setStrictType.call(void 0,
51
51
  this,
52
52
  expectedValue.map((el) => `${el}n`)
53
53
  );
54
- return this.custom(_chunkW2GOLG3Kjs.oneOfValues.call(void 0, expectedValue));
54
+ return this.custom(_chunkIZ3CBVEEjs.oneOfValues.call(void 0, expectedValue));
55
55
  }
56
56
  limitCheck() {
57
- if (this.limit) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
57
+ if (this.limit) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
58
58
  this.limit = true;
59
59
  }
60
60
  }, _class);
@@ -62,4 +62,4 @@ var BigIntSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {constr
62
62
 
63
63
 
64
64
  exports.BigIntSchema = BigIntSchema;
65
- //# sourceMappingURL=chunk-P6V6S6TZ.js.map
65
+ //# sourceMappingURL=chunk-UUY7DPHK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-UUY7DPHK.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;ACXO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBACnC,QAAA,EAAU,EAAA;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,OAAA,CAA0B,aAAA,EAA2C;AAC1E,IAAA,IAAA,CAAK,iBAAA,CAAkB,CAAA;AACvB,IAAA,IAAA,CAAK,UAAA,CAAW,CAAA;AAChB,IAAA,6CAAA,IAAe,EAAM,CAAA,EAAA;AACF,IAAA;AACrB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWqC,EAAA;AAC9B,IAAA;AACW,IAAA;AAChB,IAAA;AACE,MAAA;AACmB,MAAA;AACrB,IAAA;AACmB,IAAA;AACrB,EAAA;AAEqB,EAAA;AACG,IAAA;AACT,IAAA;AACf,EAAA;AACF;ADU0B;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-UUY7DPHK.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { WithBGuardType } from '../commonTypes';\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 protected _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 public equalTo<Y extends bigint>(expectedValue: Y): WithBGuardType<this, Y> {\n this.defaultValueCheck();\n this.limitCheck();\n _setStrictType(this, `${expectedValue}n`);\n return this.custom(equalTo(expectedValue)) as WithBGuardType<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 public oneOfValues<Y extends bigint>(expectedValue: Y[]): WithBGuardType<this, Y> {\n this.defaultValueCheck();\n this.limitCheck();\n _setStrictType(\n this,\n expectedValue.map((el) => `${el}n`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n private limitCheck() {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n }\n}\n"]}
@@ -0,0 +1,28 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
+
3
+ var _chunkSHJVKSEZjs = require('./chunk-SHJVKSEZ.js');
4
+
5
+
6
+ var _chunkX762EUSZjs = require('./chunk-X762EUSZ.js');
7
+
8
+
9
+ var _chunk5P6AZJCNjs = require('./chunk-5P6AZJCN.js');
10
+
11
+ // src/schemas/ArraySchema.ts
12
+ var ArraySchema = (_class = class extends _chunkSHJVKSEZjs.CommonSchema {
13
+ __init() {this._array = 1}
14
+ constructor(ctx, arraySchema) {
15
+ super(ctx);_class.prototype.__init.call(this);;
16
+ this.validateArrayEntry(arraySchema);
17
+ this[_chunkX762EUSZjs.ctxSymbol].array = arraySchema;
18
+ }
19
+ validateArrayEntry(arraySchema) {
20
+ if (!arraySchema) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)("Missing schema in array method");
21
+ if (!(arraySchema instanceof _chunkSHJVKSEZjs.CommonSchema)) throw new (0, _chunk5P6AZJCNjs.BuildSchemaError)("Invalid schema in array method");
22
+ }
23
+ }, _class);
24
+
25
+
26
+
27
+ exports.ArraySchema = ArraySchema;
28
+ //# sourceMappingURL=chunk-VW4RMQD4.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-LYNVPN3R.js","../src/schemas/ArraySchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNO,IAAM,YAAA,YAAN,MAAA,QAA0B,8BAAa;AAAA,iBAClC,OAAA,EAAS,EAAA;AAAA,EACnB,WAAA,CAAY,GAAA,EAAuB,WAAA,EAA2B;AAC5D,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,kBAAA,CAAmB,WAAW,CAAA;AACnC,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,MAAA,EAAQ,WAAA;AAAA,EAC1B;AAAA,EAEQ,kBAAA,CAAmB,WAAA,EAA2B;AACpD,IAAA,GAAA,CAAI,CAAC,WAAA,EAAa,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAC7E,IAAA,GAAA,CAAI,CAAA,CAAE,YAAA,WAAuB,6BAAA,CAAA,EAAe,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAAA,EACzG;AACF,UAAA;ADOA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-LYNVPN3R.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class ArraySchema extends CommonSchema {\n protected _array = 1;\n constructor(ctx: ValidatorContext, arraySchema: CommonSchema) {\n super(ctx);\n this.validateArrayEntry(arraySchema);\n this[ctxSymbol].array = arraySchema;\n }\n\n private validateArrayEntry(arraySchema: CommonSchema) {\n if (!arraySchema) throw new BuildSchemaError('Missing schema in array method');\n if (!(arraySchema instanceof CommonSchema)) throw new BuildSchemaError('Invalid schema in array method');\n }\n}\n\nexport type WithArray<Y extends CommonSchema> = ArraySchema & { validation_array: Y };\nexport type ExtractFromArray<T> = T extends WithArray<infer X> ? X : never;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-VW4RMQD4.js","../src/schemas/ArraySchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNO,IAAM,YAAA,YAAN,MAAA,QAA0B,8BAAa;AAAA,iBAClC,OAAA,EAAS,EAAA;AAAA,EACnB,WAAA,CAAY,GAAA,EAAuB,WAAA,EAA2B;AAC5D,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,kBAAA,CAAmB,WAAW,CAAA;AACnC,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,MAAA,EAAQ,WAAA;AAAA,EAC1B;AAAA,EAEQ,kBAAA,CAAmB,WAAA,EAA2B;AACpD,IAAA,GAAA,CAAI,CAAC,WAAA,EAAa,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAC7E,IAAA,GAAA,CAAI,CAAA,CAAE,YAAA,WAAuB,6BAAA,CAAA,EAAe,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAAA,EACzG;AACF,UAAA;ADOA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-VW4RMQD4.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class ArraySchema extends CommonSchema {\n protected _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"]}
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  equalTo
3
- } from "./chunk-BUXOCPHI.mjs";
3
+ } from "./chunk-C3EDEQ3W.mjs";
4
4
  import {
5
5
  oneOfValues
6
- } from "./chunk-OHEMRF7Y.mjs";
6
+ } from "./chunk-K7X6DVM2.mjs";
7
7
  import {
8
8
  ONLY_ONCE
9
9
  } from "./chunk-ASZW6XRM.mjs";
10
10
  import {
11
11
  _setStrictType
12
- } from "./chunk-D42ISCFK.mjs";
12
+ } from "./chunk-H6LHV3EA.mjs";
13
13
  import {
14
14
  CommonSchema
15
- } from "./chunk-AOUFWACR.mjs";
15
+ } from "./chunk-7NBOVYSP.mjs";
16
16
  import {
17
17
  BuildSchemaError
18
- } from "./chunk-NP64RC7B.mjs";
18
+ } from "./chunk-FGZKNBDP.mjs";
19
19
 
20
20
  // src/schemas/BigIntSchema.ts
21
21
  var BigIntSchema = class extends CommonSchema {
@@ -62,4 +62,4 @@ var BigIntSchema = class extends CommonSchema {
62
62
  export {
63
63
  BigIntSchema
64
64
  };
65
- //# sourceMappingURL=chunk-ZMEQCIRN.mjs.map
65
+ //# sourceMappingURL=chunk-WK4FJ5GD.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/BigIntSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { WithBGuardType } from '../commonTypes';\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 protected _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 public equalTo<Y extends bigint>(expectedValue: Y): WithBGuardType<this, Y> {\n this.defaultValueCheck();\n this.limitCheck();\n _setStrictType(this, `${expectedValue}n`);\n return this.custom(equalTo(expectedValue)) as WithBGuardType<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 public oneOfValues<Y extends bigint>(expectedValue: Y[]): WithBGuardType<this, Y> {\n this.defaultValueCheck();\n this.limitCheck();\n _setStrictType(\n this,\n expectedValue.map((el) => `${el}n`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n private limitCheck() {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQO,IAAM,eAAN,cAA2B,aAAa;AAAA,EACnC,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,QAA0B,eAA2C;AAC1E,SAAK,kBAAkB;AACvB,SAAK,WAAW;AAChB,mBAAe,MAAM,GAAG,aAAa,GAAG;AACxC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWO,YAA8B,eAA6C;AAChF,SAAK,kBAAkB;AACvB,SAAK,WAAW;AAChB;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG;AAAA,IACpC;AACA,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AAAA,EAEQ,aAAa;AACnB,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AAAA,EACf;AACF;","names":[]}