bguard 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/README.md +777 -447
  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 +8 -6
  9. package/lib/asserts/array/index.js.map +1 -1
  10. package/lib/asserts/array/index.mjs +7 -5
  11. package/lib/asserts/array/index.mjs.map +1 -1
  12. package/lib/asserts/array/maxArrayLength.d.mts +22 -0
  13. package/lib/asserts/array/maxArrayLength.d.ts +22 -0
  14. package/lib/asserts/array/maxArrayLength.js +20 -0
  15. package/lib/asserts/array/maxArrayLength.js.map +1 -0
  16. package/lib/asserts/array/maxArrayLength.mjs +20 -0
  17. package/lib/asserts/array/maxArrayLength.mjs.map +1 -0
  18. package/lib/asserts/array/minArrayLength.d.mts +22 -0
  19. package/lib/asserts/array/minArrayLength.d.ts +22 -0
  20. package/lib/asserts/array/minArrayLength.js +20 -0
  21. package/lib/asserts/array/minArrayLength.js.map +1 -0
  22. package/lib/asserts/array/minArrayLength.mjs +20 -0
  23. package/lib/asserts/array/minArrayLength.mjs.map +1 -0
  24. package/lib/asserts/bigint/bigintMax.js +4 -4
  25. package/lib/asserts/bigint/bigintMax.mjs +2 -2
  26. package/lib/asserts/bigint/bigintMaxExcluded.js +4 -4
  27. package/lib/asserts/bigint/bigintMaxExcluded.mjs +2 -2
  28. package/lib/asserts/bigint/bigintMin.js +4 -4
  29. package/lib/asserts/bigint/bigintMin.mjs +2 -2
  30. package/lib/asserts/bigint/bigintMinExcluded.js +4 -4
  31. package/lib/asserts/bigint/bigintMinExcluded.mjs +2 -2
  32. package/lib/asserts/bigint/index.d.mts +5 -4
  33. package/lib/asserts/bigint/index.d.ts +5 -4
  34. package/lib/asserts/bigint/index.js +11 -10
  35. package/lib/asserts/bigint/index.js.map +1 -1
  36. package/lib/asserts/bigint/index.mjs +10 -9
  37. package/lib/asserts/bigint/index.mjs.map +1 -1
  38. package/lib/asserts/boolean/index.d.mts +5 -4
  39. package/lib/asserts/boolean/index.d.ts +5 -4
  40. package/lib/asserts/boolean/index.js +9 -7
  41. package/lib/asserts/boolean/index.js.map +1 -1
  42. package/lib/asserts/boolean/index.mjs +8 -6
  43. package/lib/asserts/boolean/index.mjs.map +1 -1
  44. package/lib/asserts/date/dateMax.js +6 -6
  45. package/lib/asserts/date/dateMax.js.map +1 -1
  46. package/lib/asserts/date/dateMax.mjs +5 -5
  47. package/lib/asserts/date/dateMax.mjs.map +1 -1
  48. package/lib/asserts/date/dateMin.js +6 -6
  49. package/lib/asserts/date/dateMin.js.map +1 -1
  50. package/lib/asserts/date/dateMin.mjs +5 -5
  51. package/lib/asserts/date/dateMin.mjs.map +1 -1
  52. package/lib/asserts/date/index.d.mts +5 -4
  53. package/lib/asserts/date/index.d.ts +5 -4
  54. package/lib/asserts/date/index.js +8 -6
  55. package/lib/asserts/date/index.js.map +1 -1
  56. package/lib/asserts/date/index.mjs +7 -5
  57. package/lib/asserts/date/index.mjs.map +1 -1
  58. package/lib/asserts/mix/equalTo.js +4 -4
  59. package/lib/asserts/mix/equalTo.mjs +3 -3
  60. package/lib/asserts/mix/index.d.mts +5 -4
  61. package/lib/asserts/mix/index.d.ts +5 -4
  62. package/lib/asserts/mix/index.js +7 -5
  63. package/lib/asserts/mix/index.js.map +1 -1
  64. package/lib/asserts/mix/index.mjs +6 -4
  65. package/lib/asserts/mix/index.mjs.map +1 -1
  66. package/lib/asserts/mix/oneOfValues.js +4 -4
  67. package/lib/asserts/mix/oneOfValues.mjs +3 -3
  68. package/lib/asserts/number/index.d.mts +4 -3
  69. package/lib/asserts/number/index.d.ts +4 -3
  70. package/lib/asserts/number/index.js +11 -10
  71. package/lib/asserts/number/index.js.map +1 -1
  72. package/lib/asserts/number/index.mjs +10 -9
  73. package/lib/asserts/number/index.mjs.map +1 -1
  74. package/lib/asserts/number/max.js +4 -4
  75. package/lib/asserts/number/max.mjs +2 -2
  76. package/lib/asserts/number/maxExcluded.js +4 -4
  77. package/lib/asserts/number/maxExcluded.mjs +2 -2
  78. package/lib/asserts/number/min.js +4 -4
  79. package/lib/asserts/number/min.mjs +2 -2
  80. package/lib/asserts/number/minExcluded.js +4 -4
  81. package/lib/asserts/number/minExcluded.mjs +2 -2
  82. package/lib/asserts/number/negative.js +4 -4
  83. package/lib/asserts/number/negative.mjs +2 -2
  84. package/lib/asserts/number/positive.js +4 -4
  85. package/lib/asserts/number/positive.mjs +2 -2
  86. package/lib/asserts/object/index.d.mts +6 -5
  87. package/lib/asserts/object/index.d.ts +6 -5
  88. package/lib/asserts/object/index.js +8 -6
  89. package/lib/asserts/object/index.js.map +1 -1
  90. package/lib/asserts/object/index.mjs +7 -5
  91. package/lib/asserts/object/index.mjs.map +1 -1
  92. package/lib/asserts/object/maxKeys.d.mts +30 -0
  93. package/lib/asserts/object/maxKeys.d.ts +30 -0
  94. package/lib/asserts/object/maxKeys.js +23 -0
  95. package/lib/asserts/object/maxKeys.js.map +1 -0
  96. package/lib/asserts/object/maxKeys.mjs +23 -0
  97. package/lib/asserts/object/maxKeys.mjs.map +1 -0
  98. package/lib/asserts/string/atLeastOneDigit.js +4 -4
  99. package/lib/asserts/string/atLeastOneDigit.mjs +2 -2
  100. package/lib/asserts/string/atLeastOneLowerChar.js +4 -4
  101. package/lib/asserts/string/atLeastOneLowerChar.mjs +2 -2
  102. package/lib/asserts/string/atLeastOneSpecialChar.js +4 -4
  103. package/lib/asserts/string/atLeastOneSpecialChar.mjs +2 -2
  104. package/lib/asserts/string/atLeastOneUpperChar.js +4 -4
  105. package/lib/asserts/string/atLeastOneUpperChar.mjs +2 -2
  106. package/lib/asserts/string/contains.js +4 -4
  107. package/lib/asserts/string/contains.mjs +2 -2
  108. package/lib/asserts/string/email.js +4 -4
  109. package/lib/asserts/string/email.mjs +2 -2
  110. package/lib/asserts/string/endsWith.js +4 -4
  111. package/lib/asserts/string/endsWith.mjs +2 -2
  112. package/lib/asserts/string/index.d.mts +5 -4
  113. package/lib/asserts/string/index.d.ts +5 -4
  114. package/lib/asserts/string/index.js +11 -10
  115. package/lib/asserts/string/index.js.map +1 -1
  116. package/lib/asserts/string/index.mjs +10 -9
  117. package/lib/asserts/string/index.mjs.map +1 -1
  118. package/lib/asserts/string/isValidDate.d.mts +21 -0
  119. package/lib/asserts/string/isValidDate.d.ts +21 -0
  120. package/lib/asserts/string/isValidDate.js +25 -0
  121. package/lib/asserts/string/isValidDate.js.map +1 -0
  122. package/lib/asserts/string/isValidDate.mjs +25 -0
  123. package/lib/asserts/string/isValidDate.mjs.map +1 -0
  124. package/lib/asserts/string/isValidDateTime.d.mts +35 -0
  125. package/lib/asserts/string/isValidDateTime.d.ts +35 -0
  126. package/lib/asserts/string/isValidDateTime.js +32 -0
  127. package/lib/asserts/string/isValidDateTime.js.map +1 -0
  128. package/lib/asserts/string/isValidDateTime.mjs +32 -0
  129. package/lib/asserts/string/isValidDateTime.mjs.map +1 -0
  130. package/lib/asserts/string/isValidTime.d.mts +29 -0
  131. package/lib/asserts/string/isValidTime.d.ts +29 -0
  132. package/lib/asserts/string/isValidTime.js +32 -0
  133. package/lib/asserts/string/isValidTime.js.map +1 -0
  134. package/lib/asserts/string/isValidTime.mjs +32 -0
  135. package/lib/asserts/string/isValidTime.mjs.map +1 -0
  136. package/lib/asserts/string/lowerCase.js +4 -4
  137. package/lib/asserts/string/lowerCase.mjs +2 -2
  138. package/lib/asserts/string/maxLength.js +4 -4
  139. package/lib/asserts/string/maxLength.mjs +2 -2
  140. package/lib/asserts/string/minLength.js +4 -4
  141. package/lib/asserts/string/minLength.mjs +2 -2
  142. package/lib/asserts/string/regExp.js +4 -4
  143. package/lib/asserts/string/regExp.mjs +2 -2
  144. package/lib/asserts/string/startsWith.js +4 -4
  145. package/lib/asserts/string/startsWith.mjs +2 -2
  146. package/lib/asserts/string/upperCase.js +4 -4
  147. package/lib/asserts/string/upperCase.mjs +2 -2
  148. package/lib/asserts/string/uuid.js +4 -4
  149. package/lib/asserts/string/uuid.mjs +2 -2
  150. package/lib/asserts/string/uuidV1.js +4 -4
  151. package/lib/asserts/string/uuidV1.mjs +2 -2
  152. package/lib/asserts/string/uuidV2.js +4 -4
  153. package/lib/asserts/string/uuidV2.mjs +2 -2
  154. package/lib/asserts/string/uuidV3.js +4 -4
  155. package/lib/asserts/string/uuidV3.mjs +2 -2
  156. package/lib/asserts/string/uuidV4.js +4 -4
  157. package/lib/asserts/string/uuidV4.mjs +2 -2
  158. package/lib/asserts/string/uuidV5.js +4 -4
  159. package/lib/asserts/string/uuidV5.mjs +2 -2
  160. package/lib/asserts/string/validUrl.js +4 -4
  161. package/lib/asserts/string/validUrl.mjs +2 -2
  162. package/lib/{chunk-QLVLZRHT.js → chunk-2KQASECD.js} +5 -5
  163. package/lib/chunk-2KQASECD.js.map +1 -0
  164. package/lib/{chunk-WK4O3HH4.js → chunk-5P6AZJCN.js} +6 -5
  165. package/lib/chunk-5P6AZJCN.js.map +1 -0
  166. package/lib/{chunk-VGF3Y2EK.js → chunk-5WHCMWXK.js} +12 -9
  167. package/lib/chunk-5WHCMWXK.js.map +1 -0
  168. package/lib/{chunk-CQWI6YRI.js → chunk-5YYRBKDP.js} +4 -4
  169. package/lib/{chunk-CQWI6YRI.js.map → chunk-5YYRBKDP.js.map} +1 -1
  170. package/lib/{chunk-PJI3DRGP.mjs → chunk-6D5W7SSQ.mjs} +4 -4
  171. package/lib/chunk-6D5W7SSQ.mjs.map +1 -0
  172. package/lib/chunk-7NBOVYSP.mjs +136 -0
  173. package/lib/chunk-7NBOVYSP.mjs.map +1 -0
  174. package/lib/{chunk-XZTZC73V.mjs → chunk-BNCT7NOR.mjs} +36 -14
  175. package/lib/chunk-BNCT7NOR.mjs.map +1 -0
  176. package/lib/{chunk-M6OCVAUD.mjs → chunk-C3EDEQ3W.mjs} +3 -3
  177. package/lib/{chunk-Z7OEFOAD.mjs → chunk-CHUPE6SJ.mjs} +8 -8
  178. package/lib/chunk-CHUPE6SJ.mjs.map +1 -0
  179. package/lib/{chunk-4SR7J2I4.js → chunk-ECBOZ3BM.js} +8 -8
  180. package/lib/chunk-ECBOZ3BM.js.map +1 -0
  181. package/lib/{chunk-7XFLH6R2.mjs → chunk-FGZKNBDP.mjs} +6 -5
  182. package/lib/chunk-FGZKNBDP.mjs.map +1 -0
  183. package/lib/{chunk-TP5I237J.mjs → chunk-FP5QAEVQ.mjs} +14 -12
  184. package/lib/chunk-FP5QAEVQ.mjs.map +1 -0
  185. package/lib/{chunk-MTJJKWTP.js → chunk-G55SHHAR.js} +10 -8
  186. package/lib/chunk-G55SHHAR.js.map +1 -0
  187. package/lib/{chunk-QV4JDW3T.mjs → chunk-H32B3NHW.mjs} +2 -2
  188. package/lib/{chunk-54RHVQFA.mjs → chunk-H6LHV3EA.mjs} +2 -2
  189. package/lib/{chunk-WPHJ4QTB.js → chunk-HP3DRZWK.js} +5 -5
  190. package/lib/{chunk-WPHJ4QTB.js.map → chunk-HP3DRZWK.js.map} +1 -1
  191. package/lib/{chunk-4SPM2CSQ.js → chunk-IZ3CBVEE.js} +5 -5
  192. package/lib/{chunk-4SPM2CSQ.js.map → chunk-IZ3CBVEE.js.map} +1 -1
  193. package/lib/{chunk-YPAUFM3S.mjs → chunk-K7X6DVM2.mjs} +3 -3
  194. package/lib/{chunk-PEWNA24X.mjs → chunk-LPR3G5T3.mjs} +4 -4
  195. package/lib/chunk-LPR3G5T3.mjs.map +1 -0
  196. package/lib/{chunk-XFR7Y4XX.mjs → chunk-MHBY5OIQ.mjs} +3 -3
  197. package/lib/chunk-MHBY5OIQ.mjs.map +1 -0
  198. package/lib/{chunk-5EIBKBYS.js → chunk-MLNQZ445.js} +13 -13
  199. package/lib/chunk-MLNQZ445.js.map +1 -0
  200. package/lib/chunk-QIDWASOC.js +14 -0
  201. package/lib/{chunk-LWAEUS2F.js.map → chunk-QIDWASOC.js.map} +1 -1
  202. package/lib/chunk-SHJVKSEZ.js +136 -0
  203. package/lib/chunk-SHJVKSEZ.js.map +1 -0
  204. package/lib/{chunk-MRWZVTNH.mjs → chunk-TRGMD7LA.mjs} +7 -5
  205. package/lib/chunk-TRGMD7LA.mjs.map +1 -0
  206. package/lib/{chunk-5AO66YV5.mjs → chunk-TV5IZY4L.mjs} +9 -6
  207. package/lib/chunk-TV5IZY4L.mjs.map +1 -0
  208. package/lib/{chunk-N6YMNLXG.js → chunk-U4USIJV3.js} +11 -11
  209. package/lib/chunk-U4USIJV3.js.map +1 -0
  210. package/lib/{chunk-SEIKS6G7.js → chunk-UUY7DPHK.js} +19 -15
  211. package/lib/chunk-UUY7DPHK.js.map +1 -0
  212. package/lib/{chunk-356HMXOP.js → chunk-VBTWYDEM.js} +4 -4
  213. package/lib/chunk-VBTWYDEM.js.map +1 -0
  214. package/lib/chunk-VW4RMQD4.js +28 -0
  215. package/lib/chunk-VW4RMQD4.js.map +1 -0
  216. package/lib/{chunk-UV4I7JZR.mjs → chunk-WK4FJ5GD.mjs} +16 -12
  217. package/lib/chunk-WK4FJ5GD.mjs.map +1 -0
  218. package/lib/chunk-X762EUSZ.js +91 -0
  219. package/lib/chunk-X762EUSZ.js.map +1 -0
  220. package/lib/{chunk-GDSB7CDN.mjs → chunk-YBVMP4EI.mjs} +4 -4
  221. package/lib/chunk-YBVMP4EI.mjs.map +1 -0
  222. package/lib/{chunk-PVOHKGBW.mjs → chunk-YUMUCQKL.mjs} +4 -4
  223. package/lib/chunk-YUMUCQKL.mjs.map +1 -0
  224. package/lib/{chunk-32J4WVLE.js → chunk-Z6QU36MM.js} +17 -15
  225. package/lib/chunk-Z6QU36MM.js.map +1 -0
  226. package/lib/codeGen.d.mts +2 -1
  227. package/lib/codeGen.d.ts +2 -1
  228. package/lib/codeGen.js +4 -4
  229. package/lib/codeGen.mjs +3 -3
  230. package/lib/commonTypes.d.mts +26 -2
  231. package/lib/commonTypes.d.ts +26 -2
  232. package/lib/exceptions.d.mts +3 -2
  233. package/lib/exceptions.d.ts +3 -2
  234. package/lib/exceptions.js +2 -2
  235. package/lib/exceptions.mjs +1 -1
  236. package/lib/helpers/core.d.mts +2 -1
  237. package/lib/helpers/core.d.ts +2 -1
  238. package/lib/helpers/core.js +4 -4
  239. package/lib/helpers/core.mjs +3 -3
  240. package/lib/helpers/isValidDateInner.d.mts +3 -0
  241. package/lib/helpers/isValidDateInner.d.ts +3 -0
  242. package/lib/helpers/isValidDateInner.js +7 -0
  243. package/lib/helpers/isValidDateInner.js.map +1 -0
  244. package/lib/helpers/isValidDateInner.mjs +7 -0
  245. package/lib/helpers/setStrictType.d.mts +2 -1
  246. package/lib/helpers/setStrictType.d.ts +2 -1
  247. package/lib/helpers/setStrictType.js +5 -5
  248. package/lib/helpers/setStrictType.mjs +4 -4
  249. package/lib/index.d.mts +1 -8
  250. package/lib/index.d.ts +1 -8
  251. package/lib/index.js +7 -7
  252. package/lib/index.mjs +6 -6
  253. package/lib/parse.d.mts +1 -8
  254. package/lib/parse.d.ts +1 -8
  255. package/lib/parse.js +6 -6
  256. package/lib/parse.mjs +5 -5
  257. package/lib/parseOrFail.d.mts +1 -8
  258. package/lib/parseOrFail.d.ts +1 -8
  259. package/lib/parseOrFail.js +6 -6
  260. package/lib/parseOrFail.mjs +5 -5
  261. package/lib/schemas/ArraySchema.d.mts +4 -7
  262. package/lib/schemas/ArraySchema.d.ts +4 -7
  263. package/lib/schemas/ArraySchema.js +8 -6
  264. package/lib/schemas/ArraySchema.js.map +1 -1
  265. package/lib/schemas/ArraySchema.mjs +7 -5
  266. package/lib/schemas/BigIntSchema.d.mts +8 -10
  267. package/lib/schemas/BigIntSchema.d.ts +8 -10
  268. package/lib/schemas/BigIntSchema.js +11 -10
  269. package/lib/schemas/BigIntSchema.js.map +1 -1
  270. package/lib/schemas/BigIntSchema.mjs +10 -9
  271. package/lib/schemas/BooleanSchema.d.mts +7 -10
  272. package/lib/schemas/BooleanSchema.d.ts +7 -10
  273. package/lib/schemas/BooleanSchema.js +9 -7
  274. package/lib/schemas/BooleanSchema.js.map +1 -1
  275. package/lib/schemas/BooleanSchema.mjs +8 -6
  276. package/lib/schemas/CommonSchema.d.mts +2 -1
  277. package/lib/schemas/CommonSchema.d.ts +2 -1
  278. package/lib/schemas/CommonSchema.js +7 -5
  279. package/lib/schemas/CommonSchema.js.map +1 -1
  280. package/lib/schemas/CommonSchema.mjs +6 -4
  281. package/lib/schemas/DateSchema.d.mts +3 -2
  282. package/lib/schemas/DateSchema.d.ts +3 -2
  283. package/lib/schemas/DateSchema.js +8 -6
  284. package/lib/schemas/DateSchema.js.map +1 -1
  285. package/lib/schemas/DateSchema.mjs +7 -5
  286. package/lib/schemas/NumberSchema.d.mts +7 -10
  287. package/lib/schemas/NumberSchema.d.ts +7 -10
  288. package/lib/schemas/NumberSchema.js +11 -10
  289. package/lib/schemas/NumberSchema.js.map +1 -1
  290. package/lib/schemas/NumberSchema.mjs +10 -9
  291. package/lib/schemas/ObjectSchema.d.mts +4 -6
  292. package/lib/schemas/ObjectSchema.d.ts +4 -6
  293. package/lib/schemas/ObjectSchema.js +8 -6
  294. package/lib/schemas/ObjectSchema.js.map +1 -1
  295. package/lib/schemas/ObjectSchema.mjs +7 -5
  296. package/lib/schemas/StringSchema.d.mts +8 -10
  297. package/lib/schemas/StringSchema.d.ts +8 -10
  298. package/lib/schemas/StringSchema.js +11 -10
  299. package/lib/schemas/StringSchema.js.map +1 -1
  300. package/lib/schemas/StringSchema.mjs +10 -9
  301. package/lib/translationMap.js +3 -3
  302. package/lib/translationMap.mjs +2 -2
  303. package/package.json +1 -1
  304. package/lib/CommonSchema-9RtxTxdX.d.ts +0 -63
  305. package/lib/CommonSchema-DJmQ3F_9.d.mts +0 -63
  306. package/lib/chunk-2OINKFOA.js +0 -28
  307. package/lib/chunk-2OINKFOA.js.map +0 -1
  308. package/lib/chunk-32J4WVLE.js.map +0 -1
  309. package/lib/chunk-356HMXOP.js.map +0 -1
  310. package/lib/chunk-4SR7J2I4.js.map +0 -1
  311. package/lib/chunk-4UF67IQ2.mjs +0 -42
  312. package/lib/chunk-4UF67IQ2.mjs.map +0 -1
  313. package/lib/chunk-5AO66YV5.mjs.map +0 -1
  314. package/lib/chunk-5EIBKBYS.js.map +0 -1
  315. package/lib/chunk-7GIRQ5EA.js +0 -69
  316. package/lib/chunk-7GIRQ5EA.js.map +0 -1
  317. package/lib/chunk-7XFLH6R2.mjs.map +0 -1
  318. package/lib/chunk-EQNVYAKS.js +0 -42
  319. package/lib/chunk-EQNVYAKS.js.map +0 -1
  320. package/lib/chunk-GDSB7CDN.mjs.map +0 -1
  321. package/lib/chunk-LWAEUS2F.js +0 -14
  322. package/lib/chunk-MRWZVTNH.mjs.map +0 -1
  323. package/lib/chunk-MTJJKWTP.js.map +0 -1
  324. package/lib/chunk-N6YMNLXG.js.map +0 -1
  325. package/lib/chunk-PEWNA24X.mjs.map +0 -1
  326. package/lib/chunk-PJI3DRGP.mjs.map +0 -1
  327. package/lib/chunk-PVOHKGBW.mjs.map +0 -1
  328. package/lib/chunk-QLVLZRHT.js.map +0 -1
  329. package/lib/chunk-SEIKS6G7.js.map +0 -1
  330. package/lib/chunk-TP5I237J.mjs.map +0 -1
  331. package/lib/chunk-UV4I7JZR.mjs.map +0 -1
  332. package/lib/chunk-VGF3Y2EK.js.map +0 -1
  333. package/lib/chunk-WK4O3HH4.js.map +0 -1
  334. package/lib/chunk-XFR7Y4XX.mjs.map +0 -1
  335. package/lib/chunk-XZTZC73V.mjs.map +0 -1
  336. package/lib/chunk-Z7OEFOAD.mjs.map +0 -1
  337. package/lib/helpers/isValidDate.d.mts +0 -3
  338. package/lib/helpers/isValidDate.d.ts +0 -3
  339. package/lib/helpers/isValidDate.js +0 -7
  340. package/lib/helpers/isValidDate.js.map +0 -1
  341. package/lib/helpers/isValidDate.mjs +0 -7
  342. /package/lib/{chunk-M6OCVAUD.mjs.map → chunk-C3EDEQ3W.mjs.map} +0 -0
  343. /package/lib/{chunk-QV4JDW3T.mjs.map → chunk-H32B3NHW.mjs.map} +0 -0
  344. /package/lib/{chunk-54RHVQFA.mjs.map → chunk-H6LHV3EA.mjs.map} +0 -0
  345. /package/lib/{chunk-YPAUFM3S.mjs.map → chunk-K7X6DVM2.mjs.map} +0 -0
  346. /package/lib/helpers/{isValidDate.mjs.map → isValidDateInner.mjs.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-356HMXOP.js","../src/helpers/isValidDate.ts"],"names":[],"mappings":"AAAA;ACAO,SAAS,WAAA,CAAY,CAAA,EAAY;AACtC,EAAA,OAAA;AAAA;AAAA,IAEE,MAAA,CAAO,SAAA,CAAU,QAAA,CAAS,IAAA,CAAK,CAAC,EAAA,IAAM,gBAAA,GAAmB,CAAC,KAAA,CAAM,uBAAO,CAAA,2BAAG,UAAA,IAAY,WAAA,GAAc,CAAA,CAAE,OAAA,CAAQ,CAAC;AAAA,EAAA,CAAA;AAEnH;ADEA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-356HMXOP.js","sourcesContent":[null,"export function isValidDate(d: unknown) {\n return (\n // @ts-expect-error we expect d to have getTime method\n Object.prototype.toString.call(d) === '[object Date]' && !isNaN(typeof d?.getTime === 'function' && d.getTime())\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-4SR7J2I4.js","../src/schemas/BooleanSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACLA,IAAM,UAAA,EAAY,CAAC,QAAA,EAAA,GAAsB,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AACrF,EAAA,GAAA,CAAI,SAAA,IAAa,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,aAAa,CAAA;AAClF,CAAA;AAEO,IAAM,cAAA,YAAN,MAAA,QAA4B,8BAAa;AAAA,iBAC9C,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASX,QAAA,CAAA,EAAoC;AAClC,IAAA,6CAAA,IAAe,EAAM,IAAI,CAAA;AACzB,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,IAAI,CAAC,CAAA;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,SAAA,CAAA,EAAsC;AACpC,IAAA,6CAAA,IAAe,EAAM,KAAK,CAAA;AAC1B,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,KAAK,CAAC,CAAA;AAAA,EACrC;AACF,UAAA;ADIA;AACA;AACE;AACF,sCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-4SR7J2I4.js","sourcesContent":[null,"import { CommonSchema } from './CommonSchema';\nimport { guardException } from '../exceptions';\nimport { ExceptionContext } from '../commonTypes';\nimport { _setStrictType } from '../helpers/setStrictType';\n\nconst isBoolean = (expected: boolean) => (received: boolean, ctx: ExceptionContext) => {\n if (received !== expected) guardException(expected, received, ctx, 'c:isBoolean');\n};\n\nexport class BooleanSchema extends CommonSchema {\n _boolean = 1;\n\n /**\n * Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value true, with the true value inferred as the TypeScript type\n *\n * @example - boolean().onlyTrue(); // Infers the type true\n */\n onlyTrue(): WithBoolean<this, true> {\n _setStrictType(this, true);\n return this.custom(isBoolean(true)) as WithBoolean<this, true>;\n }\n\n /**\n * Restricts the schema to exactly match the boolean value false and infers the false value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value false, with the false value inferred as the TypeScript type\n *\n * @example - boolean().onlyFalse(); // Infers the type false\n */\n onlyFalse(): WithBoolean<this, false> {\n _setStrictType(this, false);\n return this.custom(isBoolean(false)) as WithBoolean<this, false>;\n }\n}\n\nexport type WithBoolean<T extends BooleanSchema, Y = boolean> = T & { validation_boolean: Y };\nexport type ExtractFromBoolean<T> = T extends WithBoolean<BooleanSchema, infer Y> ? Y : never;\n"]}
@@ -1,42 +0,0 @@
1
- import {
2
- ctxSymbol
3
- } from "./chunk-XZTZC73V.mjs";
4
-
5
- // src/schemas/CommonSchema.ts
6
- var CommonSchema = class {
7
- [ctxSymbol];
8
- constructor(ctx) {
9
- this[ctxSymbol] = ctx;
10
- }
11
- /**
12
- * @param validators - One or more custom validation functions.
13
- * @returns {this} The schema instance with the added custom validation.
14
- */
15
- custom(...validators) {
16
- this[ctxSymbol].requiredValidations.push(...validators);
17
- return this;
18
- }
19
- /**
20
- * Marks the schema as nullable, allowing the value to be `null`.
21
- *
22
- * @returns {WithNull<this>} The schema instance marked as nullable.
23
- */
24
- nullable() {
25
- this[ctxSymbol].isNullable = true;
26
- return this;
27
- }
28
- /**
29
- * Marks the schema as optional, allowing the value to be `undefined`.
30
- *
31
- * @returns {WithUndefined<this>} The schema instance marked as optional.
32
- */
33
- optional() {
34
- this[ctxSymbol].isOptional = true;
35
- return this;
36
- }
37
- };
38
-
39
- export {
40
- CommonSchema
41
- };
42
- //# sourceMappingURL=chunk-4UF67IQ2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/CommonSchema.ts"],"sourcesContent":["import { PrimitiveType, RequiredValidation } from '../commonTypes';\nimport { ctxSymbol } from '../helpers/core';\n\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport interface ValidatorContext {\n type: PrimitiveType[];\n isNullable?: boolean;\n isOptional?: boolean;\n requiredValidations: RequiredValidation[];\n array?: CommonSchema;\n object?: ObjectShapeSchemaType;\n allowUnrecognizedObjectProps?: boolean;\n strictType?: boolean;\n strictTypeValue?: unknown;\n date?: boolean;\n}\n\nexport class CommonSchema {\n [ctxSymbol]: ValidatorContext;\n constructor(ctx: ValidatorContext) {\n this[ctxSymbol] = ctx;\n }\n\n /**\n * @param validators - One or more custom validation functions.\n * @returns {this} The schema instance with the added custom validation.\n */\n custom(...validators: RequiredValidation[]): this {\n this[ctxSymbol].requiredValidations.push(...validators);\n return this;\n }\n\n /**\n * Marks the schema as nullable, allowing the value to be `null`.\n *\n * @returns {WithNull<this>} The schema instance marked as nullable.\n */\n nullable(): WithNull<this> {\n this[ctxSymbol].isNullable = true;\n return this as WithNull<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {WithUndefined<this>} The schema instance marked as optional.\n */\n optional(): WithUndefined<this> {\n this[ctxSymbol].isOptional = true;\n return this as WithUndefined<this>;\n }\n}\n\nexport type WithNull<T extends CommonSchema> = T & { validation_null: true };\nexport type WithUndefined<T extends CommonSchema> = T & { validation_undefined: true };\n\ntype TypeMapping = {\n number: number;\n string: string;\n boolean: boolean;\n undefined: undefined;\n object: object;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n function: Function;\n symbol: symbol;\n bigint: bigint;\n};\n\nexport type WithMix<Y = unknown> = CommonSchema & { validation_mix: Y };\nexport type ExtractFromMix<T> = T extends WithMix<infer X> ? X : never;\n\nexport type MapMixTypes<T extends PrimitiveType[]> = T extends (infer U)[]\n ? U extends keyof TypeMapping\n ? TypeMapping[U]\n : never\n : never;\n"],"mappings":";;;;;AAkBO,IAAM,eAAN,MAAmB;AAAA,EACxB,CAAC,SAAS;AAAA,EACV,YAAY,KAAuB;AACjC,SAAK,SAAS,IAAI;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU,YAAwC;AAChD,SAAK,SAAS,EAAE,oBAAoB,KAAK,GAAG,UAAU;AACtD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAA2B;AACzB,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAgC;AAC9B,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/parse.ts"],"sourcesContent":["import { InferType } from './InferType';\nimport { 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 };\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 },\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,IACX;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,QACf;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-5EIBKBYS.js","../src/schemas/NumberSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACZO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAA,CAA8B,aAAA,EAAyC;AACrE,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADYA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-5EIBKBYS.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"]}
@@ -1,69 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunk356HMXOPjs = require('./chunk-356HMXOP.js');
4
-
5
-
6
- var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
7
-
8
- // src/helpers/core.ts
9
- var ctxSymbol = Symbol("contextSymbol");
10
- function innerCheck(schema, receivedValue, exCtx) {
11
- const commonTmap = exCtx.t;
12
- const schemaData = schema[ctxSymbol];
13
- if (receivedValue === void 0) {
14
- if (!schemaData.isOptional) _chunkWK4O3HH4js.guardException.call(void 0, "Required", receivedValue, exCtx, commonTmap["c:optional"]);
15
- return receivedValue;
16
- }
17
- if (receivedValue === null) {
18
- if (!schemaData.isNullable) _chunkWK4O3HH4js.guardException.call(void 0, "Not null", receivedValue, exCtx, commonTmap["c:nullable"]);
19
- return receivedValue;
20
- }
21
- if (schemaData.date) {
22
- if (!_chunk356HMXOPjs.isValidDate.call(void 0, receivedValue)) _chunkWK4O3HH4js.guardException.call(void 0, "Date", receivedValue, exCtx, commonTmap["c:date"]);
23
- }
24
- if (schemaData.array) {
25
- if (!Array.isArray(receivedValue)) return _chunkWK4O3HH4js.guardException.call(void 0, "Array", receivedValue, exCtx, commonTmap["c:array"]);
26
- const schema2 = schemaData.array;
27
- const pathToError = exCtx.pathToError;
28
- receivedValue.forEach((elem, i) => {
29
- innerCheck(schema2, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });
30
- });
31
- return receivedValue;
32
- }
33
- const typeOfVal = typeof receivedValue;
34
- if (schemaData.object) {
35
- if (typeOfVal !== "object") _chunkWK4O3HH4js.guardException.call(void 0, "Object", receivedValue, exCtx, commonTmap["c:objectType"]);
36
- if (Array.isArray(receivedValue)) _chunkWK4O3HH4js.guardException.call(void 0, "Object", receivedValue, exCtx, commonTmap["c:objectTypeAsArray"]);
37
- const shapeSchema = schemaData.object;
38
- if (!schemaData.allowUnrecognizedObjectProps) {
39
- for (const keyPerReceivedValue of Object.keys(receivedValue)) {
40
- if (shapeSchema[keyPerReceivedValue] === void 0)
41
- _chunkWK4O3HH4js.guardException.call(void 0, "Unrecognized property", keyPerReceivedValue, exCtx, commonTmap["c:unrecognizedProperty"]);
42
- }
43
- }
44
- const pathToError = exCtx.pathToError;
45
- for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {
46
- const receivedObjectValuePropery = receivedValue[keyOfSchema];
47
- if (receivedObjectValuePropery === void 0) {
48
- if (!valueOfSchema[ctxSymbol].isOptional)
49
- _chunkWK4O3HH4js.guardException.call(void 0, "Required", receivedObjectValuePropery, exCtx, commonTmap["c:requiredProperty"]);
50
- }
51
- innerCheck(valueOfSchema, receivedObjectValuePropery, { ...exCtx, pathToError: `${pathToError}.${keyOfSchema}` });
52
- }
53
- return receivedValue;
54
- }
55
- if (schemaData.type.length) {
56
- if (!schemaData.type.includes(typeOfVal))
57
- _chunkWK4O3HH4js.guardException.call(void 0, schemaData.type, typeOfVal, exCtx, commonTmap["c:invalidType"]);
58
- }
59
- schemaData.requiredValidations.forEach((requiredValidation) => {
60
- requiredValidation(receivedValue, exCtx);
61
- });
62
- return receivedValue;
63
- }
64
-
65
-
66
-
67
-
68
- exports.ctxSymbol = ctxSymbol; exports.innerCheck = innerCheck;
69
- //# sourceMappingURL=chunk-7GIRQ5EA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-7GIRQ5EA.js","../src/helpers/core.ts"],"names":["schema"],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACPO,IAAM,UAAA,EAAY,MAAA,CAAO,eAAe,CAAA;AAOxC,SAAS,UAAA,CAAW,MAAA,EAAsB,aAAA,EAAwB,KAAA,EAAyB;AAChG,EAAA,MAAM,WAAA,EAAa,KAAA,CAAM,CAAA;AACzB,EAAA,MAAM,WAAA,EAAa,MAAA,CAAO,SAAS,CAAA;AACnC,EAAA,GAAA,CAAI,cAAA,IAAkB,KAAA,CAAA,EAAW;AAC/B,IAAA,GAAA,CAAI,CAAC,UAAA,CAAW,UAAA,EAAY,6CAAA,UAAe,EAAY,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,YAAY,CAAC,CAAA;AACrG,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,cAAA,IAAkB,IAAA,EAAM;AAC1B,IAAA,GAAA,CAAI,CAAC,UAAA,CAAW,UAAA,EAAY,6CAAA,UAAe,EAAY,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,YAAY,CAAC,CAAA;AACrG,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,UAAA,CAAW,IAAA,EAAM;AACnB,IAAA,GAAA,CAAI,CAAC,0CAAA,aAAyB,CAAA,EAAG,6CAAA,MAAe,EAAQ,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,QAAQ,CAAC,CAAA;AAAA,EACpG;AAEA,EAAA,GAAA,CAAI,UAAA,CAAW,KAAA,EAAO;AACpB,IAAA,GAAA,CAAI,CAAC,KAAA,CAAM,OAAA,CAAQ,aAAa,CAAA,EAAG,OAAO,6CAAA,OAAe,EAAS,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,SAAS,CAAC,CAAA;AAC7G,IAAA,MAAMA,QAAAA,EAAS,UAAA,CAAW,KAAA;AAC1B,IAAA,MAAM,YAAA,EAAc,KAAA,CAAM,WAAA;AAC1B,IAAA,aAAA,CAAc,OAAA,CAAQ,CAAC,IAAA,EAAM,CAAA,EAAA,GAAM;AACjC,MAAA,UAAA,CAAWA,OAAAA,EAAQ,IAAA,EAAM,EAAE,GAAG,KAAA,EAAO,WAAA,EAAa,CAAA,EAAA;AACnD,IAAA;AAEM,IAAA;AACT,EAAA;AAEyB,EAAA;AAEF,EAAA;AACgC,IAAA;AACJ,IAAA;AAClB,IAAA;AAEe,IAAA;AACE,MAAA;AACH,QAAA;AACC,UAAA;AAC5C,MAAA;AACF,IAAA;AAE0B,IAAA;AACwB,IAAA;AAC8B,MAAA;AAChC,MAAA;AACd,QAAA;AACD,UAAA;AAC/B,MAAA;AAE0B,MAAA;AAC5B,IAAA;AAEO,IAAA;AACT,EAAA;AAE4B,EAAA;AACa,IAAA;AACa,MAAA;AACtD,EAAA;AAEwC,EAAA;AACC,IAAA;AACxC,EAAA;AAEM,EAAA;AACT;ADV0D;AACA;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-7GIRQ5EA.js","sourcesContent":[null,"export const ctxSymbol = Symbol('contextSymbol');\n\nimport { ExceptionContext } from '../commonTypes';\nimport { guardException } from '../exceptions';\nimport type { CommonSchema } from '../schemas/CommonSchema';\nimport { isValidDate } from './isValidDate';\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, exCtx: ExceptionContext) {\n const commonTmap = exCtx.t;\n const schemaData = schema[ctxSymbol];\n if (receivedValue === undefined) {\n if (!schemaData.isOptional) guardException('Required', receivedValue, exCtx, commonTmap['c:optional']);\n return receivedValue;\n }\n\n if (receivedValue === null) {\n if (!schemaData.isNullable) guardException('Not null', receivedValue, exCtx, commonTmap['c:nullable']);\n return receivedValue;\n }\n\n if (schemaData.date) {\n if (!isValidDate(receivedValue)) guardException('Date', receivedValue, exCtx, commonTmap['c:date']);\n }\n\n if (schemaData.array) {\n if (!Array.isArray(receivedValue)) return guardException('Array', receivedValue, exCtx, commonTmap['c:array']);\n const schema = schemaData.array;\n const pathToError = exCtx.pathToError;\n receivedValue.forEach((elem, i) => {\n innerCheck(schema, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });\n });\n\n return receivedValue;\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (schemaData.object) {\n if (typeOfVal !== 'object') guardException('Object', receivedValue, exCtx, commonTmap['c:objectType']);\n if (Array.isArray(receivedValue)) guardException('Object', receivedValue, exCtx, commonTmap['c:objectTypeAsArray']);\n const shapeSchema = schemaData.object;\n\n if (!schemaData.allowUnrecognizedObjectProps) {\n for (const keyPerReceivedValue of Object.keys(receivedValue)) {\n if (shapeSchema[keyPerReceivedValue] === undefined)\n guardException('Unrecognized property', keyPerReceivedValue, exCtx, commonTmap['c:unrecognizedProperty']);\n }\n }\n\n const pathToError = exCtx.pathToError;\n for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {\n const receivedObjectValuePropery = (receivedValue as Record<string, unknown>)[keyOfSchema];\n if (receivedObjectValuePropery === undefined) {\n if (!valueOfSchema[ctxSymbol].isOptional)\n guardException('Required', receivedObjectValuePropery, exCtx, commonTmap['c:requiredProperty']);\n }\n\n innerCheck(valueOfSchema, receivedObjectValuePropery, { ...exCtx, pathToError: `${pathToError}.${keyOfSchema}` });\n }\n\n return receivedValue;\n }\n\n if (schemaData.type.length) {\n if (!schemaData.type.includes(typeOfVal))\n guardException(schemaData.type, typeOfVal, exCtx, commonTmap['c:invalidType']);\n }\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\n return receivedValue;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/exceptions.ts"],"sourcesContent":["import type { ExceptionContext } from './commonTypes';\n\nexport class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nfunction replacePlaceholders(template: string, replacements: Record<string, unknown>): string {\n const regex = /{{(.*?)}}/g;\n return template.replace(regex, (_, key) => {\n const vvv = key in replacements ? `${replacements[key] as string}` : `{{${key}}}`;\n return vvv;\n });\n}\n\nexport function guardException(\n expected: unknown,\n received: unknown,\n ctx: ExceptionContext,\n messageKey: string,\n): never | void {\n const rawMessage = ctx.t[messageKey] ?? messageKey;\n const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: ctx.pathToError });\n\n if (ctx.getAllErrors) {\n ctx.errors.push({\n expected,\n received,\n pathToError: ctx.pathToError,\n message,\n });\n\n return;\n }\n throw new ValidationError(expected, received, ctx.pathToError, message);\n}\n"],"mappings":";AAEO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAEO,IAAM,mBAAN,cAA+B,MAAM;AAAC;AAE7C,SAAS,oBAAoB,UAAkB,cAA+C;AAC5F,QAAM,QAAQ;AACd,SAAO,SAAS,QAAQ,OAAO,CAAC,GAAG,QAAQ;AACzC,UAAM,MAAM,OAAO,eAAe,GAAG,aAAa,GAAG,CAAW,KAAK,KAAK,GAAG;AAC7E,WAAO;AAAA,EACT,CAAC;AACH;AAEO,SAAS,eACd,UACA,UACA,KACA,YACc;AACd,QAAM,aAAa,IAAI,EAAE,UAAU,KAAK;AACxC,QAAM,UAAU,oBAAoB,YAAY,EAAE,GAAG,UAAU,GAAG,UAAU,GAAG,IAAI,YAAY,CAAC;AAEhG,MAAI,IAAI,cAAc;AACpB,QAAI,OAAO,KAAK;AAAA,MACd;AAAA,MACA;AAAA,MACA,aAAa,IAAI;AAAA,MACjB;AAAA,IACF,CAAC;AAED;AAAA,EACF;AACA,QAAM,IAAI,gBAAgB,UAAU,UAAU,IAAI,aAAa,OAAO;AACxE;","names":[]}
@@ -1,42 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunk7GIRQ5EAjs = require('./chunk-7GIRQ5EA.js');
4
-
5
- // src/schemas/CommonSchema.ts
6
- var CommonSchema = class {
7
-
8
- constructor(ctx) {
9
- this[_chunk7GIRQ5EAjs.ctxSymbol] = ctx;
10
- }
11
- /**
12
- * @param validators - One or more custom validation functions.
13
- * @returns {this} The schema instance with the added custom validation.
14
- */
15
- custom(...validators) {
16
- this[_chunk7GIRQ5EAjs.ctxSymbol].requiredValidations.push(...validators);
17
- return this;
18
- }
19
- /**
20
- * Marks the schema as nullable, allowing the value to be `null`.
21
- *
22
- * @returns {WithNull<this>} The schema instance marked as nullable.
23
- */
24
- nullable() {
25
- this[_chunk7GIRQ5EAjs.ctxSymbol].isNullable = true;
26
- return this;
27
- }
28
- /**
29
- * Marks the schema as optional, allowing the value to be `undefined`.
30
- *
31
- * @returns {WithUndefined<this>} The schema instance marked as optional.
32
- */
33
- optional() {
34
- this[_chunk7GIRQ5EAjs.ctxSymbol].isOptional = true;
35
- return this;
36
- }
37
- };
38
-
39
-
40
-
41
- exports.CommonSchema = CommonSchema;
42
- //# sourceMappingURL=chunk-EQNVYAKS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-EQNVYAKS.js","../src/schemas/CommonSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACcO,IAAM,aAAA,EAAN,MAAmB;AAAA,EACxB;AAAU,EACV,WAAA,CAAY,GAAA,EAAuB;AACjC,IAAA,IAAA,CAAK,0BAAS,EAAA,EAAI,GAAA;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAA,CAAA,GAAU,UAAA,EAAwC;AAChD,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,mBAAA,CAAoB,IAAA,CAAK,GAAG,UAAU,CAAA;AACtD,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAA,CAAA,EAA2B;AACzB,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAA,CAAA,EAAgC;AAC9B,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AACF,CAAA;ADfA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-EQNVYAKS.js","sourcesContent":[null,"import { PrimitiveType, RequiredValidation } from '../commonTypes';\nimport { ctxSymbol } from '../helpers/core';\n\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport interface ValidatorContext {\n type: PrimitiveType[];\n isNullable?: boolean;\n isOptional?: boolean;\n requiredValidations: RequiredValidation[];\n array?: CommonSchema;\n object?: ObjectShapeSchemaType;\n allowUnrecognizedObjectProps?: boolean;\n strictType?: boolean;\n strictTypeValue?: unknown;\n date?: boolean;\n}\n\nexport class CommonSchema {\n [ctxSymbol]: ValidatorContext;\n constructor(ctx: ValidatorContext) {\n this[ctxSymbol] = ctx;\n }\n\n /**\n * @param validators - One or more custom validation functions.\n * @returns {this} The schema instance with the added custom validation.\n */\n custom(...validators: RequiredValidation[]): this {\n this[ctxSymbol].requiredValidations.push(...validators);\n return this;\n }\n\n /**\n * Marks the schema as nullable, allowing the value to be `null`.\n *\n * @returns {WithNull<this>} The schema instance marked as nullable.\n */\n nullable(): WithNull<this> {\n this[ctxSymbol].isNullable = true;\n return this as WithNull<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {WithUndefined<this>} The schema instance marked as optional.\n */\n optional(): WithUndefined<this> {\n this[ctxSymbol].isOptional = true;\n return this as WithUndefined<this>;\n }\n}\n\nexport type WithNull<T extends CommonSchema> = T & { validation_null: true };\nexport type WithUndefined<T extends CommonSchema> = T & { validation_undefined: true };\n\ntype TypeMapping = {\n number: number;\n string: string;\n boolean: boolean;\n undefined: undefined;\n object: object;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n function: Function;\n symbol: symbol;\n bigint: bigint;\n};\n\nexport type WithMix<Y = unknown> = CommonSchema & { validation_mix: Y };\nexport type ExtractFromMix<T> = T extends WithMix<infer X> ? X : never;\n\nexport type MapMixTypes<T extends PrimitiveType[]> = T extends (infer U)[]\n ? U extends keyof TypeMapping\n ? TypeMapping[U]\n : never\n : never;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/helpers/isValidDate.ts"],"sourcesContent":["export function isValidDate(d: unknown) {\n return (\n // @ts-expect-error we expect d to have getTime method\n Object.prototype.toString.call(d) === '[object Date]' && !isNaN(typeof d?.getTime === 'function' && d.getTime())\n );\n}\n"],"mappings":";AAAO,SAAS,YAAY,GAAY;AACtC;AAAA;AAAA,IAEE,OAAO,UAAU,SAAS,KAAK,CAAC,MAAM,mBAAmB,CAAC,MAAM,OAAO,GAAG,YAAY,cAAc,EAAE,QAAQ,CAAC;AAAA;AAEnH;","names":[]}
@@ -1,14 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunk7GIRQ5EAjs = require('./chunk-7GIRQ5EA.js');
4
-
5
- // src/helpers/setStrictType.ts
6
- function _setStrictType(that, val) {
7
- that[_chunk7GIRQ5EAjs.ctxSymbol].strictType = true;
8
- that[_chunk7GIRQ5EAjs.ctxSymbol].strictTypeValue = val;
9
- }
10
-
11
-
12
-
13
- exports._setStrictType = _setStrictType;
14
- //# sourceMappingURL=chunk-LWAEUS2F.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/parseOrFail.ts"],"sourcesContent":["import type { InferType } from './InferType';\nimport type { CommonSchema } from './schemas/CommonSchema';\nimport { 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 }) 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,IACf,CAAC;AAAA,EACH,SAAS,GAAG;AACV,QAAI,aAAa,gBAAiB,OAAM;AAExC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-MTJJKWTP.js","../src/parseOrFail.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACgCO,SAAS,WAAA,CACd,MAAA,EACA,aAAA,EACA,OAAA,EACc;AACd,EAAA,IAAI;AACF,IAAA,OAAO,yCAAA,MAAW,EAAQ,aAAA,EAAe;AAAA,MACvC,CAAA,EAAG,qDAAA,gBAAuB,OAAA,2BAAS,KAAG,CAAA;AAAA,MACtC,WAAA,EAAa;AAAA,IACf,CAAC,CAAA;AAAA,EACH,EAAA,MAAA,CAAS,CAAA,EAAG;AACV,IAAA,GAAA,CAAI,EAAA,WAAa,gCAAA,EAAiB,MAAM,CAAA;AAExC,IAAA,MAAM,IAAI,KAAA,CAAM,+BAA+B,CAAA;AAAA,EACjD;AACF;ADnCA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-MTJJKWTP.js","sourcesContent":[null,"import type { InferType } from './InferType';\nimport type { CommonSchema } from './schemas/CommonSchema';\nimport { 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 }) 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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-N6YMNLXG.js","../src/schemas/ObjectSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACV,WAAA,CAAY,GAAA,EAAuB,WAAA,EAAoC;AACrE,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,mBAAA,CAAoB,WAAW,CAAA;AACpC,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,OAAA,EAAS,WAAA;AAAA,EAC3B;AAAA,EAEQ,mBAAA,CAAoB,WAAA,EAAoC;AAC9D,IAAA,GAAA,CAAI,CAAC,WAAA,EAAa,MAAM,IAAI,sCAAA,CAAiB,iCAAiC,CAAA;AAC9E,IAAA,GAAA,CAAI,YAAA,WAAuB,6BAAA,EAAc,MAAM,IAAI,sCAAA,CAAiB,0BAA0B,CAAA;AAC9F,IAAA,IAAA,CAAA,MAAW,CAAC,GAAA,EAAK,KAAK,EAAA,GAAK,MAAA,CAAO,OAAA,CAAQ,WAAW,CAAA,EAAG;AACtD,MAAA,GAAA,CAAI,CAAA,CAAE,MAAA,WAAiB,6BAAA,CAAA;AACrB,QAAA,MAAM,IAAI,sCAAA,CAAiB,CAAA,8CAAA,EAAiD,GAAG,CAAA,CAAA,CAAG,CAAA;AAAA,IACtF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBO,iBAAA,CAAA,EAA0B;AAC/B,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,6BAAA,EAA+B,IAAA;AAC/C,IAAA,OAAO,IAAA;AAAA,EACT;AACF,UAAA;ADMA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-N6YMNLXG.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ObjectShapeSchemaType, ValidatorContext } from './CommonSchema';\n\nexport class ObjectSchema extends CommonSchema {\n _object = 1;\n constructor(ctx: ValidatorContext, shapeSchema: ObjectShapeSchemaType) {\n super(ctx);\n this.validateObjectEntry(shapeSchema);\n this[ctxSymbol].object = shapeSchema;\n }\n\n private validateObjectEntry(shapeSchema: ObjectShapeSchemaType) {\n if (!shapeSchema) throw new BuildSchemaError('Missing schema in object method');\n if (shapeSchema instanceof CommonSchema) throw new BuildSchemaError('Invalid schema in object');\n for (const [key, value] of Object.entries(shapeSchema)) {\n if (!(value instanceof CommonSchema))\n throw new BuildSchemaError(`Invalid schema in object method for property '${key}'`);\n }\n }\n\n /**\n * Allows unrecognized properties in the validated object.\n * When this method is called, the validation will not fail\n * if the received object contains properties not specified\n * in the validation schema.\n *\n * @returns {this} The current ObjectSchema instance.\n *\n * @example\n * const userSchema = object({\n * name: string(),\n * age: number(),\n * }).allowUnrecognized();\n *\n * parseOrFail(userSchema, ({ name: 'John', age: 30, extra: 'value' }););\n * // No error thrown\n */\n public allowUnrecognized(): this {\n this[ctxSymbol].allowUnrecognizedObjectProps = true;\n return this;\n }\n}\n\nexport type WithObject<Y extends ObjectShapeSchemaType> = ObjectSchema & { validation_object: Y };\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/ArraySchema.ts"],"sourcesContent":["import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class ArraySchema extends CommonSchema {\n _array = 1;\n constructor(ctx: ValidatorContext, arraySchema: CommonSchema) {\n super(ctx);\n this.validateArrayEntry(arraySchema);\n this[ctxSymbol].array = arraySchema;\n }\n\n private validateArrayEntry(arraySchema: CommonSchema) {\n if (!arraySchema) throw new BuildSchemaError('Missing schema in array method');\n if (!(arraySchema instanceof CommonSchema)) throw new BuildSchemaError('Invalid schema in array method');\n }\n}\n\nexport type WithArray<Y extends CommonSchema> = ArraySchema & { validation_array: Y };\nexport type ExtractFromArray<T> = T extends WithArray<infer X> ? X : never;\n"],"mappings":";;;;;;;;;;;AAIO,IAAM,cAAN,cAA0B,aAAa;AAAA,EAC5C,SAAS;AAAA,EACT,YAAY,KAAuB,aAA2B;AAC5D,UAAM,GAAG;AACT,SAAK,mBAAmB,WAAW;AACnC,SAAK,SAAS,EAAE,QAAQ;AAAA,EAC1B;AAAA,EAEQ,mBAAmB,aAA2B;AACpD,QAAI,CAAC,YAAa,OAAM,IAAI,iBAAiB,gCAAgC;AAC7E,QAAI,EAAE,uBAAuB,cAAe,OAAM,IAAI,iBAAiB,gCAAgC;AAAA,EACzG;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/BooleanSchema.ts"],"sourcesContent":["import { CommonSchema } from './CommonSchema';\nimport { guardException } from '../exceptions';\nimport { ExceptionContext } from '../commonTypes';\nimport { _setStrictType } from '../helpers/setStrictType';\n\nconst isBoolean = (expected: boolean) => (received: boolean, ctx: ExceptionContext) => {\n if (received !== expected) guardException(expected, received, ctx, 'c:isBoolean');\n};\n\nexport class BooleanSchema extends CommonSchema {\n _boolean = 1;\n\n /**\n * Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value true, with the true value inferred as the TypeScript type\n *\n * @example - boolean().onlyTrue(); // Infers the type true\n */\n onlyTrue(): WithBoolean<this, true> {\n _setStrictType(this, true);\n return this.custom(isBoolean(true)) as WithBoolean<this, true>;\n }\n\n /**\n * Restricts the schema to exactly match the boolean value false and infers the false value as the TypeScript type.\n *\n * @returns - The schema instance restricted to the value false, with the false value inferred as the TypeScript type\n *\n * @example - boolean().onlyFalse(); // Infers the type false\n */\n onlyFalse(): WithBoolean<this, false> {\n _setStrictType(this, false);\n return this.custom(isBoolean(false)) as WithBoolean<this, false>;\n }\n}\n\nexport type WithBoolean<T extends BooleanSchema, Y = boolean> = T & { validation_boolean: Y };\nexport type ExtractFromBoolean<T> = T extends WithBoolean<BooleanSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;AAKA,IAAM,YAAY,CAAC,aAAsB,CAAC,UAAmB,QAA0B;AACrF,MAAI,aAAa,SAAU,gBAAe,UAAU,UAAU,KAAK,aAAa;AAClF;AAEO,IAAM,gBAAN,cAA4B,aAAa;AAAA,EAC9C,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASX,WAAoC;AAClC,mBAAe,MAAM,IAAI;AACzB,WAAO,KAAK,OAAO,UAAU,IAAI,CAAC;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,YAAsC;AACpC,mBAAe,MAAM,KAAK;AAC1B,WAAO,KAAK,OAAO,UAAU,KAAK,CAAC;AAAA,EACrC;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/ObjectSchema.ts"],"sourcesContent":["import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ObjectShapeSchemaType, ValidatorContext } from './CommonSchema';\n\nexport class ObjectSchema extends CommonSchema {\n _object = 1;\n constructor(ctx: ValidatorContext, shapeSchema: ObjectShapeSchemaType) {\n super(ctx);\n this.validateObjectEntry(shapeSchema);\n this[ctxSymbol].object = shapeSchema;\n }\n\n private validateObjectEntry(shapeSchema: ObjectShapeSchemaType) {\n if (!shapeSchema) throw new BuildSchemaError('Missing schema in object method');\n if (shapeSchema instanceof CommonSchema) throw new BuildSchemaError('Invalid schema in object');\n for (const [key, value] of Object.entries(shapeSchema)) {\n if (!(value instanceof CommonSchema))\n throw new BuildSchemaError(`Invalid schema in object method for property '${key}'`);\n }\n }\n\n /**\n * Allows unrecognized properties in the validated object.\n * When this method is called, the validation will not fail\n * if the received object contains properties not specified\n * in the validation schema.\n *\n * @returns {this} The current ObjectSchema instance.\n *\n * @example\n * const userSchema = object({\n * name: string(),\n * age: number(),\n * }).allowUnrecognized();\n *\n * parseOrFail(userSchema, ({ name: 'John', age: 30, extra: 'value' }););\n * // No error thrown\n */\n public allowUnrecognized(): this {\n this[ctxSymbol].allowUnrecognizedObjectProps = true;\n return this;\n }\n}\n\nexport type WithObject<Y extends ObjectShapeSchemaType> = ObjectSchema & { validation_object: Y };\n"],"mappings":";;;;;;;;;;;AAIO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACV,YAAY,KAAuB,aAAoC;AACrE,UAAM,GAAG;AACT,SAAK,oBAAoB,WAAW;AACpC,SAAK,SAAS,EAAE,SAAS;AAAA,EAC3B;AAAA,EAEQ,oBAAoB,aAAoC;AAC9D,QAAI,CAAC,YAAa,OAAM,IAAI,iBAAiB,iCAAiC;AAC9E,QAAI,uBAAuB,aAAc,OAAM,IAAI,iBAAiB,0BAA0B;AAC9F,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,GAAG;AACtD,UAAI,EAAE,iBAAiB;AACrB,cAAM,IAAI,iBAAiB,iDAAiD,GAAG,GAAG;AAAA,IACtF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBO,oBAA0B;AAC/B,SAAK,SAAS,EAAE,+BAA+B;AAC/C,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-QLVLZRHT.js","../src/schemas/DateSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACJO,IAAM,WAAA,YAAN,MAAA,QAAyB,8BAAa;AAAA,iBAC3C,MAAA,EAAQ,EAAA;AAAA,EAER,WAAA,CAAY,GAAA,EAAuB;AACjC,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,KAAA,EAAO,IAAA;AAAA,EACzB;AACF,UAAA;ADKA;AACA;AACE;AACF,gCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-QLVLZRHT.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class DateSchema extends CommonSchema {\n _date = 1;\n\n constructor(ctx: ValidatorContext) {\n super(ctx);\n this[ctxSymbol].date = true;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-SEIKS6G7.js","../src/schemas/BigIntSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACZO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,OAAA,CAA0B,aAAA,EAAuC;AAC/D,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,CAAA,EAAA;AACF,IAAA;AACrB,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAW8B,EAAA;AACN,IAAA;AACT,IAAA;AACb,IAAA;AACE,MAAA;AACmB,MAAA;AACrB,IAAA;AACmB,IAAA;AACrB,EAAA;AACF;ADY0B;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-SEIKS6G7.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class BigIntSchema extends CommonSchema {\n _bigint = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - bigint().equalTo(42n); // Infers the type 42n\n */\n equalTo<Y extends bigint>(expectedValue: Y): WithBigInt<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, `${expectedValue}n`);\n return this.custom(equalTo(expectedValue)) as WithBigInt<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n\n */\n oneOfValues<Y extends bigint>(expectedValue: Y[]): WithBigInt<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(\n this,\n expectedValue.map((el) => `${el}n`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithBigInt<this, Y>;\n }\n}\n\nexport type WithBigInt<T extends BigIntSchema, Y = bigint> = T & { validation_bigint: Y };\nexport type ExtractFromBigInt<T> = T extends WithBigInt<BigIntSchema, infer Y> ? Y : never;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/StringSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n _string = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - string().equalTo('hello'); // Infers the type 'hello'\n */\n equalTo<Y extends string>(expectedValue: Y): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, `'${expectedValue}'`);\n\n return this.custom(equalTo(expectedValue)) as WithString<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n oneOfValues<Y extends string>(expectedValue: Y[]): WithString<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithString<this, Y>;\n }\n}\n\nexport type WithString<T extends StringSchema, Y = string> = T & { validation_string: Y };\nexport type ExtractFromString<T> = T extends WithString<StringSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,IAAI,aAAa,GAAG;AAEzC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,IAAI,EAAE,GAAG;AAAA,IACrC;AACA,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/BigIntSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class BigIntSchema extends CommonSchema {\n _bigint = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - bigint().equalTo(42n); // Infers the type 42n\n */\n equalTo<Y extends bigint>(expectedValue: Y): WithBigInt<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, `${expectedValue}n`);\n return this.custom(equalTo(expectedValue)) as WithBigInt<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n\n */\n oneOfValues<Y extends bigint>(expectedValue: Y[]): WithBigInt<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(\n this,\n expectedValue.map((el) => `${el}n`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithBigInt<this, Y>;\n }\n}\n\nexport type WithBigInt<T extends BigIntSchema, Y = bigint> = T & { validation_bigint: Y };\nexport type ExtractFromBigInt<T> = T extends WithBigInt<BigIntSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,GAAG,aAAa,GAAG;AACxC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG;AAAA,IACpC;AACA,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-VGF3Y2EK.js","../src/parse.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACqDO,SAAS,KAAA,CACd,MAAA,EACA,aAAA,EACA,OAAA,EACgE;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,EAAwB;AAAA,MAC5B,CAAA,EAAG,qDAAA,gBAAuB,OAAA,2BAAS,KAAG,CAAA;AAAA,MACtC,WAAA,EAAa,EAAA;AAAA,MACb,YAAA,kBAAc,OAAA,6BAAS,cAAA;AAAA,MACvB,MAAA,EAAQ,CAAC;AAAA,IACX,CAAA;AAEA,IAAA,MAAM,YAAA,EAAc,yCAAA,MAAW,EAAQ,aAAA,EAAe,GAAG,CAAA;AAEzD,IAAA,GAAA,CAAI,GAAA,CAAI,aAAA,GAAgB,GAAA,CAAI,MAAA,CAAO,MAAA,EAAQ;AACzC,MAAA,OAAO,CAAC,GAAA,CAAI,MAAA,EAAQ,KAAA,CAAS,CAAA;AAAA,IAC/B;AAEA,IAAA,OAAO,CAAC,KAAA,CAAA,EAAW,WAAW,CAAA;AAAA,EAChC,EAAA,MAAA,CAAS,CAAA,EAAG;AACV,IAAA,GAAA,CAAI,EAAA,WAAa,gCAAA,EAAiB;AAChC,MAAA,OAAO,CAAA,CAAE,KAAA;AACT,MAAA,OAAO,CAAC,CAAC,CAAC,CAAA,EAAG,KAAA,CAAS,CAAA;AAAA,IACxB;AAEA,IAAA,OAAO;AAAA,MACL;AAAA,QACE;AAAA,UACE,OAAA,EAAS,+BAAA;AAAA,UACT,QAAA,EAAU,EAAA;AAAA,UACV,QAAA,EAAU,EAAA;AAAA,UACV,WAAA,EAAa;AAAA,QACf;AAAA,MACF,CAAA;AAAA,MACA,KAAA;AAAA,IACF,CAAA;AAAA,EACF;AACF;AD3DA;AACA;AACE;AACF,sBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-VGF3Y2EK.js","sourcesContent":[null,"import { InferType } from './InferType';\nimport { 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 };\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 },\n ],\n undefined,\n ];\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-WK4O3HH4.js","../src/exceptions.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,gBAAA,EAAN,MAAA,QAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAA,CAAY,QAAA,EAAmB,QAAA,EAAmB,WAAA,EAAqB,OAAA,EAAiB;AACtF,IAAA,KAAA,CAAM,CAAA;AACN,IAAA,IAAA,CAAK,SAAA,EAAW,QAAA;AAChB,IAAA,IAAA,CAAK,SAAA,EAAW,QAAA;AAChB,IAAA,IAAA,CAAK,YAAA,EAAc,WAAA;AACnB,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA;AAAA,EACjB;AACF,CAAA;AAEO,IAAM,iBAAA,EAAN,MAAA,QAA+B,MAAM;AAAC,CAAA;AAE7C,SAAS,mBAAA,CAAoB,QAAA,EAAkB,YAAA,EAA+C;AAC5F,EAAA,MAAM,MAAA,EAAQ,YAAA;AACd,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,KAAA,EAAO,CAAC,CAAA,EAAG,GAAA,EAAA,GAAQ;AACzC,IAAA,MAAM,IAAA,EAAM,IAAA,GAAO,aAAA,EAAe,CAAA,EAAA;AAC3B,IAAA;AACR,EAAA;AACH;AAIE;AAImC,EAAA;AACC,EAAA;AAEd,EAAA;AACJ,IAAA;AACd,MAAA;AACA,MAAA;AACiB,MAAA;AACjB,MAAA;AACD,IAAA;AAED,IAAA;AACF,EAAA;AACoC,EAAA;AACtC;ADTuC;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-WK4O3HH4.js","sourcesContent":[null,"import type { ExceptionContext } from './commonTypes';\n\nexport class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nfunction replacePlaceholders(template: string, replacements: Record<string, unknown>): string {\n const regex = /{{(.*?)}}/g;\n return template.replace(regex, (_, key) => {\n const vvv = key in replacements ? `${replacements[key] as string}` : `{{${key}}}`;\n return vvv;\n });\n}\n\nexport function guardException(\n expected: unknown,\n received: unknown,\n ctx: ExceptionContext,\n messageKey: string,\n): never | void {\n const rawMessage = ctx.t[messageKey] ?? messageKey;\n const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: ctx.pathToError });\n\n if (ctx.getAllErrors) {\n ctx.errors.push({\n expected,\n received,\n pathToError: ctx.pathToError,\n message,\n });\n\n return;\n }\n throw new ValidationError(expected, received, ctx.pathToError, message);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/DateSchema.ts"],"sourcesContent":["import { ctxSymbol } from '../helpers/core';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class DateSchema extends CommonSchema {\n _date = 1;\n\n constructor(ctx: ValidatorContext) {\n super(ctx);\n this[ctxSymbol].date = true;\n }\n}\n"],"mappings":";;;;;;;;AAGO,IAAM,aAAN,cAAyB,aAAa;AAAA,EAC3C,QAAQ;AAAA,EAER,YAAY,KAAuB;AACjC,UAAM,GAAG;AACT,SAAK,SAAS,EAAE,OAAO;AAAA,EACzB;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/helpers/core.ts"],"sourcesContent":["export const ctxSymbol = Symbol('contextSymbol');\n\nimport { ExceptionContext } from '../commonTypes';\nimport { guardException } from '../exceptions';\nimport type { CommonSchema } from '../schemas/CommonSchema';\nimport { isValidDate } from './isValidDate';\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, exCtx: ExceptionContext) {\n const commonTmap = exCtx.t;\n const schemaData = schema[ctxSymbol];\n if (receivedValue === undefined) {\n if (!schemaData.isOptional) guardException('Required', receivedValue, exCtx, commonTmap['c:optional']);\n return receivedValue;\n }\n\n if (receivedValue === null) {\n if (!schemaData.isNullable) guardException('Not null', receivedValue, exCtx, commonTmap['c:nullable']);\n return receivedValue;\n }\n\n if (schemaData.date) {\n if (!isValidDate(receivedValue)) guardException('Date', receivedValue, exCtx, commonTmap['c:date']);\n }\n\n if (schemaData.array) {\n if (!Array.isArray(receivedValue)) return guardException('Array', receivedValue, exCtx, commonTmap['c:array']);\n const schema = schemaData.array;\n const pathToError = exCtx.pathToError;\n receivedValue.forEach((elem, i) => {\n innerCheck(schema, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });\n });\n\n return receivedValue;\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (schemaData.object) {\n if (typeOfVal !== 'object') guardException('Object', receivedValue, exCtx, commonTmap['c:objectType']);\n if (Array.isArray(receivedValue)) guardException('Object', receivedValue, exCtx, commonTmap['c:objectTypeAsArray']);\n const shapeSchema = schemaData.object;\n\n if (!schemaData.allowUnrecognizedObjectProps) {\n for (const keyPerReceivedValue of Object.keys(receivedValue)) {\n if (shapeSchema[keyPerReceivedValue] === undefined)\n guardException('Unrecognized property', keyPerReceivedValue, exCtx, commonTmap['c:unrecognizedProperty']);\n }\n }\n\n const pathToError = exCtx.pathToError;\n for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {\n const receivedObjectValuePropery = (receivedValue as Record<string, unknown>)[keyOfSchema];\n if (receivedObjectValuePropery === undefined) {\n if (!valueOfSchema[ctxSymbol].isOptional)\n guardException('Required', receivedObjectValuePropery, exCtx, commonTmap['c:requiredProperty']);\n }\n\n innerCheck(valueOfSchema, receivedObjectValuePropery, { ...exCtx, pathToError: `${pathToError}.${keyOfSchema}` });\n }\n\n return receivedValue;\n }\n\n if (schemaData.type.length) {\n if (!schemaData.type.includes(typeOfVal))\n guardException(schemaData.type, typeOfVal, exCtx, commonTmap['c:invalidType']);\n }\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\n return receivedValue;\n}\n"],"mappings":";;;;;;;;AAAO,IAAM,YAAY,OAAO,eAAe;AAOxC,SAAS,WAAW,QAAsB,eAAwB,OAAyB;AAChG,QAAM,aAAa,MAAM;AACzB,QAAM,aAAa,OAAO,SAAS;AACnC,MAAI,kBAAkB,QAAW;AAC/B,QAAI,CAAC,WAAW,WAAY,gBAAe,YAAY,eAAe,OAAO,WAAW,YAAY,CAAC;AACrG,WAAO;AAAA,EACT;AAEA,MAAI,kBAAkB,MAAM;AAC1B,QAAI,CAAC,WAAW,WAAY,gBAAe,YAAY,eAAe,OAAO,WAAW,YAAY,CAAC;AACrG,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,MAAM;AACnB,QAAI,CAAC,YAAY,aAAa,EAAG,gBAAe,QAAQ,eAAe,OAAO,WAAW,QAAQ,CAAC;AAAA,EACpG;AAEA,MAAI,WAAW,OAAO;AACpB,QAAI,CAAC,MAAM,QAAQ,aAAa,EAAG,QAAO,eAAe,SAAS,eAAe,OAAO,WAAW,SAAS,CAAC;AAC7G,UAAMA,UAAS,WAAW;AAC1B,UAAM,cAAc,MAAM;AAC1B,kBAAc,QAAQ,CAAC,MAAM,MAAM;AACjC,iBAAWA,SAAQ,MAAM,EAAE,GAAG,OAAO,aAAa,GAAG,WAAW,IAAI,CAAC,IAAI,CAAC;AAAA,IAC5E,CAAC;AAED,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,OAAO;AAEzB,MAAI,WAAW,QAAQ;AACrB,QAAI,cAAc,SAAU,gBAAe,UAAU,eAAe,OAAO,WAAW,cAAc,CAAC;AACrG,QAAI,MAAM,QAAQ,aAAa,EAAG,gBAAe,UAAU,eAAe,OAAO,WAAW,qBAAqB,CAAC;AAClH,UAAM,cAAc,WAAW;AAE/B,QAAI,CAAC,WAAW,8BAA8B;AAC5C,iBAAW,uBAAuB,OAAO,KAAK,aAAa,GAAG;AAC5D,YAAI,YAAY,mBAAmB,MAAM;AACvC,yBAAe,yBAAyB,qBAAqB,OAAO,WAAW,wBAAwB,CAAC;AAAA,MAC5G;AAAA,IACF;AAEA,UAAM,cAAc,MAAM;AAC1B,eAAW,CAAC,aAAa,aAAa,KAAK,OAAO,QAAQ,WAAW,GAAG;AACtE,YAAM,6BAA8B,cAA0C,WAAW;AACzF,UAAI,+BAA+B,QAAW;AAC5C,YAAI,CAAC,cAAc,SAAS,EAAE;AAC5B,yBAAe,YAAY,4BAA4B,OAAO,WAAW,oBAAoB,CAAC;AAAA,MAClG;AAEA,iBAAW,eAAe,4BAA4B,EAAE,GAAG,OAAO,aAAa,GAAG,WAAW,IAAI,WAAW,GAAG,CAAC;AAAA,IAClH;AAEA,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,KAAK,QAAQ;AAC1B,QAAI,CAAC,WAAW,KAAK,SAAS,SAAS;AACrC,qBAAe,WAAW,MAAM,WAAW,OAAO,WAAW,eAAe,CAAC;AAAA,EACjF;AAEA,aAAW,oBAAoB,QAAQ,CAAC,uBAAuB;AAC7D,uBAAmB,eAAe,KAAK;AAAA,EACzC,CAAC;AAED,SAAO;AACT;","names":["schema"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/NumberSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n _number = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - number().equalTo(42); // Infers the type 42\n */\n equalTo<Y extends number>(expectedValue: Y): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(equalTo(expectedValue)) as WithNumber<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * number().oneOfValues([5, 7]); // Infers the type 5 | 7\n */\n oneOfValues<Y extends number>(expectedValue: Y[]): WithNumber<this, Y> {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n _setStrictType(this, expectedValue);\n return this.custom(oneOfValues(expectedValue)) as WithNumber<this, Y>;\n }\n}\n\nexport type WithNumber<T extends NumberSchema, Y = number> = T & { validation_number: Y };\nexport type ExtractFromNumber<T> = T extends WithNumber<NumberSchema, infer Y> ? Y : never;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOO,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,UAAU;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUR,QAA0B,eAAuC;AAC/D,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,YAA8B,eAAyC;AACrE,QAAI,KAAK,MAAO,OAAM,IAAI,iBAAiB,SAAS;AACpD,SAAK,QAAQ;AACb,mBAAe,MAAM,aAAa;AAClC,WAAO,KAAK,OAAO,YAAY,aAAa,CAAC;AAAA,EAC/C;AACF;","names":[]}
@@ -1,3 +0,0 @@
1
- declare function isValidDate(d: unknown): boolean;
2
-
3
- export { isValidDate };
@@ -1,3 +0,0 @@
1
- declare function isValidDate(d: unknown): boolean;
2
-
3
- export { isValidDate };
@@ -1,7 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunk356HMXOPjs = require('../chunk-356HMXOP.js');
4
-
5
-
6
- exports.isValidDate = _chunk356HMXOPjs.isValidDate;
7
- //# sourceMappingURL=isValidDate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/helpers/isValidDate.js"],"names":[],"mappings":"AAAA;AACE;AACF,uDAA6B;AAC7B;AACE;AACF,mDAAC","file":"/home/runner/work/bguard/bguard/lib/helpers/isValidDate.js"}
@@ -1,7 +0,0 @@
1
- import {
2
- isValidDate
3
- } from "../chunk-GDSB7CDN.mjs";
4
- export {
5
- isValidDate
6
- };
7
- //# sourceMappingURL=isValidDate.mjs.map