bguard 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/README.md +562 -380
  2. package/lib/{CommonSchema-DJmQ3F_9.d.mts → CommonSchema-CiY7spmg.d.mts} +9 -1
  3. package/lib/{CommonSchema-9RtxTxdX.d.ts → CommonSchema-D9QVJBJe.d.ts} +9 -1
  4. package/lib/InferType.d.mts +1 -1
  5. package/lib/InferType.d.ts +1 -1
  6. package/lib/asserts/array/index.d.mts +1 -1
  7. package/lib/asserts/array/index.d.ts +1 -1
  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 +1 -1
  33. package/lib/asserts/bigint/index.d.ts +1 -1
  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 +1 -1
  39. package/lib/asserts/boolean/index.d.ts +1 -1
  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 +1 -1
  53. package/lib/asserts/date/index.d.ts +1 -1
  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 +1 -1
  61. package/lib/asserts/mix/index.d.ts +1 -1
  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 +1 -1
  69. package/lib/asserts/number/index.d.ts +1 -1
  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 +1 -1
  87. package/lib/asserts/object/index.d.ts +1 -1
  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/string/atLeastOneDigit.js +4 -4
  93. package/lib/asserts/string/atLeastOneDigit.mjs +2 -2
  94. package/lib/asserts/string/atLeastOneLowerChar.js +4 -4
  95. package/lib/asserts/string/atLeastOneLowerChar.mjs +2 -2
  96. package/lib/asserts/string/atLeastOneSpecialChar.js +4 -4
  97. package/lib/asserts/string/atLeastOneSpecialChar.mjs +2 -2
  98. package/lib/asserts/string/atLeastOneUpperChar.js +4 -4
  99. package/lib/asserts/string/atLeastOneUpperChar.mjs +2 -2
  100. package/lib/asserts/string/contains.js +4 -4
  101. package/lib/asserts/string/contains.mjs +2 -2
  102. package/lib/asserts/string/email.js +4 -4
  103. package/lib/asserts/string/email.mjs +2 -2
  104. package/lib/asserts/string/endsWith.js +4 -4
  105. package/lib/asserts/string/endsWith.mjs +2 -2
  106. package/lib/asserts/string/index.d.mts +1 -1
  107. package/lib/asserts/string/index.d.ts +1 -1
  108. package/lib/asserts/string/index.js +11 -10
  109. package/lib/asserts/string/index.js.map +1 -1
  110. package/lib/asserts/string/index.mjs +10 -9
  111. package/lib/asserts/string/index.mjs.map +1 -1
  112. package/lib/asserts/string/isValidDate.d.mts +21 -0
  113. package/lib/asserts/string/isValidDate.d.ts +21 -0
  114. package/lib/asserts/string/isValidDate.js +25 -0
  115. package/lib/asserts/string/isValidDate.js.map +1 -0
  116. package/lib/asserts/string/isValidDate.mjs +25 -0
  117. package/lib/asserts/string/isValidDate.mjs.map +1 -0
  118. package/lib/asserts/string/isValidDateTime.d.mts +35 -0
  119. package/lib/asserts/string/isValidDateTime.d.ts +35 -0
  120. package/lib/asserts/string/isValidDateTime.js +32 -0
  121. package/lib/asserts/string/isValidDateTime.js.map +1 -0
  122. package/lib/asserts/string/isValidDateTime.mjs +32 -0
  123. package/lib/asserts/string/isValidDateTime.mjs.map +1 -0
  124. package/lib/asserts/string/isValidTime.d.mts +29 -0
  125. package/lib/asserts/string/isValidTime.d.ts +29 -0
  126. package/lib/asserts/string/isValidTime.js +32 -0
  127. package/lib/asserts/string/isValidTime.js.map +1 -0
  128. package/lib/asserts/string/isValidTime.mjs +32 -0
  129. package/lib/asserts/string/isValidTime.mjs.map +1 -0
  130. package/lib/asserts/string/lowerCase.js +4 -4
  131. package/lib/asserts/string/lowerCase.mjs +2 -2
  132. package/lib/asserts/string/maxLength.js +4 -4
  133. package/lib/asserts/string/maxLength.mjs +2 -2
  134. package/lib/asserts/string/minLength.js +4 -4
  135. package/lib/asserts/string/minLength.mjs +2 -2
  136. package/lib/asserts/string/regExp.js +4 -4
  137. package/lib/asserts/string/regExp.mjs +2 -2
  138. package/lib/asserts/string/startsWith.js +4 -4
  139. package/lib/asserts/string/startsWith.mjs +2 -2
  140. package/lib/asserts/string/upperCase.js +4 -4
  141. package/lib/asserts/string/upperCase.mjs +2 -2
  142. package/lib/asserts/string/uuid.js +4 -4
  143. package/lib/asserts/string/uuid.mjs +2 -2
  144. package/lib/asserts/string/uuidV1.js +4 -4
  145. package/lib/asserts/string/uuidV1.mjs +2 -2
  146. package/lib/asserts/string/uuidV2.js +4 -4
  147. package/lib/asserts/string/uuidV2.mjs +2 -2
  148. package/lib/asserts/string/uuidV3.js +4 -4
  149. package/lib/asserts/string/uuidV3.mjs +2 -2
  150. package/lib/asserts/string/uuidV4.js +4 -4
  151. package/lib/asserts/string/uuidV4.mjs +2 -2
  152. package/lib/asserts/string/uuidV5.js +4 -4
  153. package/lib/asserts/string/uuidV5.mjs +2 -2
  154. package/lib/asserts/string/validUrl.js +4 -4
  155. package/lib/asserts/string/validUrl.mjs +2 -2
  156. package/lib/{chunk-32J4WVLE.js → chunk-2D5QE7F4.js} +17 -15
  157. package/lib/chunk-2D5QE7F4.js.map +1 -0
  158. package/lib/{chunk-XFR7Y4XX.mjs → chunk-2MFBOVP2.mjs} +3 -3
  159. package/lib/chunk-2MFBOVP2.mjs.map +1 -0
  160. package/lib/chunk-3IOQH3K4.js +74 -0
  161. package/lib/chunk-3IOQH3K4.js.map +1 -0
  162. package/lib/chunk-3ZPLJ5KC.js +14 -0
  163. package/lib/{chunk-LWAEUS2F.js.map → chunk-3ZPLJ5KC.js.map} +1 -1
  164. package/lib/{chunk-QV4JDW3T.mjs → chunk-4GDBM5LP.mjs} +2 -2
  165. package/lib/{chunk-PVOHKGBW.mjs → chunk-5HT3PYSG.mjs} +4 -4
  166. package/lib/chunk-5HT3PYSG.mjs.map +1 -0
  167. package/lib/{chunk-XZTZC73V.mjs → chunk-5LLJ22IG.mjs} +25 -17
  168. package/lib/chunk-5LLJ22IG.mjs.map +1 -0
  169. package/lib/{chunk-MRWZVTNH.mjs → chunk-ADSMWGDJ.mjs} +4 -4
  170. package/lib/{chunk-VGF3Y2EK.js → chunk-AN3VHQEQ.js} +7 -7
  171. package/lib/{chunk-VGF3Y2EK.js.map → chunk-AN3VHQEQ.js.map} +1 -1
  172. package/lib/chunk-AOUFWACR.mjs +74 -0
  173. package/lib/chunk-AOUFWACR.mjs.map +1 -0
  174. package/lib/{chunk-WK4O3HH4.js → chunk-AY7HKAG2.js} +2 -3
  175. package/lib/chunk-AY7HKAG2.js.map +1 -0
  176. package/lib/{chunk-M6OCVAUD.mjs → chunk-BUXOCPHI.mjs} +3 -3
  177. package/lib/{chunk-54RHVQFA.mjs → chunk-D42ISCFK.mjs} +2 -2
  178. package/lib/{chunk-5EIBKBYS.js → chunk-EU3ZZF7Y.js} +13 -13
  179. package/lib/chunk-EU3ZZF7Y.js.map +1 -0
  180. package/lib/{chunk-PEWNA24X.mjs → chunk-KBZUNXJB.mjs} +4 -4
  181. package/lib/chunk-KBZUNXJB.mjs.map +1 -0
  182. package/lib/chunk-LYNVPN3R.js +28 -0
  183. package/lib/chunk-LYNVPN3R.js.map +1 -0
  184. package/lib/{chunk-7XFLH6R2.mjs → chunk-NP64RC7B.mjs} +2 -3
  185. package/lib/chunk-NP64RC7B.mjs.map +1 -0
  186. package/lib/{chunk-YPAUFM3S.mjs → chunk-OHEMRF7Y.mjs} +3 -3
  187. package/lib/{chunk-QLVLZRHT.js → chunk-OJSTQQ3N.js} +5 -5
  188. package/lib/chunk-OJSTQQ3N.js.map +1 -0
  189. package/lib/{chunk-5AO66YV5.mjs → chunk-OKF3BVUD.mjs} +4 -4
  190. package/lib/{chunk-N6YMNLXG.js → chunk-OO6BTBVP.js} +11 -11
  191. package/lib/chunk-OO6BTBVP.js.map +1 -0
  192. package/lib/{chunk-SEIKS6G7.js → chunk-P6V6S6TZ.js} +19 -15
  193. package/lib/chunk-P6V6S6TZ.js.map +1 -0
  194. package/lib/{chunk-MTJJKWTP.js → chunk-PESVL5YJ.js} +7 -7
  195. package/lib/{chunk-MTJJKWTP.js.map → chunk-PESVL5YJ.js.map} +1 -1
  196. package/lib/{chunk-7GIRQ5EA.js → chunk-PIBDJJUU.js} +31 -23
  197. package/lib/chunk-PIBDJJUU.js.map +1 -0
  198. package/lib/{chunk-WPHJ4QTB.js → chunk-SPWF5IFU.js} +5 -5
  199. package/lib/{chunk-WPHJ4QTB.js.map → chunk-SPWF5IFU.js.map} +1 -1
  200. package/lib/{chunk-Z7OEFOAD.mjs → chunk-TQWUSDQD.mjs} +8 -8
  201. package/lib/chunk-TQWUSDQD.mjs.map +1 -0
  202. package/lib/{chunk-CQWI6YRI.js → chunk-UZ2PWO4O.js} +4 -4
  203. package/lib/{chunk-CQWI6YRI.js.map → chunk-UZ2PWO4O.js.map} +1 -1
  204. package/lib/{chunk-356HMXOP.js → chunk-VBTWYDEM.js} +4 -4
  205. package/lib/chunk-VBTWYDEM.js.map +1 -0
  206. package/lib/{chunk-4SPM2CSQ.js → chunk-W2GOLG3K.js} +5 -5
  207. package/lib/{chunk-4SPM2CSQ.js.map → chunk-W2GOLG3K.js.map} +1 -1
  208. package/lib/{chunk-GDSB7CDN.mjs → chunk-YBVMP4EI.mjs} +4 -4
  209. package/lib/chunk-YBVMP4EI.mjs.map +1 -0
  210. package/lib/{chunk-PJI3DRGP.mjs → chunk-YPAFWVDL.mjs} +4 -4
  211. package/lib/chunk-YPAFWVDL.mjs.map +1 -0
  212. package/lib/{chunk-UV4I7JZR.mjs → chunk-ZMEQCIRN.mjs} +16 -12
  213. package/lib/chunk-ZMEQCIRN.mjs.map +1 -0
  214. package/lib/{chunk-4SR7J2I4.js → chunk-ZVW3IHBW.js} +8 -8
  215. package/lib/chunk-ZVW3IHBW.js.map +1 -0
  216. package/lib/{chunk-TP5I237J.mjs → chunk-ZWE5Q37U.mjs} +14 -12
  217. package/lib/chunk-ZWE5Q37U.mjs.map +1 -0
  218. package/lib/codeGen.d.mts +1 -1
  219. package/lib/codeGen.d.ts +1 -1
  220. package/lib/codeGen.js +4 -4
  221. package/lib/codeGen.mjs +3 -3
  222. package/lib/exceptions.js +2 -2
  223. package/lib/exceptions.mjs +1 -1
  224. package/lib/helpers/core.d.mts +1 -1
  225. package/lib/helpers/core.d.ts +1 -1
  226. package/lib/helpers/core.js +4 -4
  227. package/lib/helpers/core.mjs +3 -3
  228. package/lib/helpers/isValidDateInner.d.mts +3 -0
  229. package/lib/helpers/isValidDateInner.d.ts +3 -0
  230. package/lib/helpers/isValidDateInner.js +7 -0
  231. package/lib/helpers/isValidDateInner.js.map +1 -0
  232. package/lib/helpers/isValidDateInner.mjs +7 -0
  233. package/lib/helpers/setStrictType.d.mts +1 -1
  234. package/lib/helpers/setStrictType.d.ts +1 -1
  235. package/lib/helpers/setStrictType.js +5 -5
  236. package/lib/helpers/setStrictType.mjs +4 -4
  237. package/lib/index.d.mts +1 -1
  238. package/lib/index.d.ts +1 -1
  239. package/lib/index.js +7 -7
  240. package/lib/index.mjs +6 -6
  241. package/lib/parse.d.mts +1 -1
  242. package/lib/parse.d.ts +1 -1
  243. package/lib/parse.js +6 -6
  244. package/lib/parse.mjs +5 -5
  245. package/lib/parseOrFail.d.mts +1 -1
  246. package/lib/parseOrFail.d.ts +1 -1
  247. package/lib/parseOrFail.js +6 -6
  248. package/lib/parseOrFail.mjs +5 -5
  249. package/lib/schemas/ArraySchema.d.mts +2 -2
  250. package/lib/schemas/ArraySchema.d.ts +2 -2
  251. package/lib/schemas/ArraySchema.js +8 -6
  252. package/lib/schemas/ArraySchema.js.map +1 -1
  253. package/lib/schemas/ArraySchema.mjs +7 -5
  254. package/lib/schemas/BigIntSchema.d.mts +3 -2
  255. package/lib/schemas/BigIntSchema.d.ts +3 -2
  256. package/lib/schemas/BigIntSchema.js +11 -10
  257. package/lib/schemas/BigIntSchema.js.map +1 -1
  258. package/lib/schemas/BigIntSchema.mjs +10 -9
  259. package/lib/schemas/BooleanSchema.d.mts +2 -2
  260. package/lib/schemas/BooleanSchema.d.ts +2 -2
  261. package/lib/schemas/BooleanSchema.js +9 -7
  262. package/lib/schemas/BooleanSchema.js.map +1 -1
  263. package/lib/schemas/BooleanSchema.mjs +8 -6
  264. package/lib/schemas/CommonSchema.d.mts +1 -1
  265. package/lib/schemas/CommonSchema.d.ts +1 -1
  266. package/lib/schemas/CommonSchema.js +7 -5
  267. package/lib/schemas/CommonSchema.js.map +1 -1
  268. package/lib/schemas/CommonSchema.mjs +6 -4
  269. package/lib/schemas/DateSchema.d.mts +2 -2
  270. package/lib/schemas/DateSchema.d.ts +2 -2
  271. package/lib/schemas/DateSchema.js +8 -6
  272. package/lib/schemas/DateSchema.js.map +1 -1
  273. package/lib/schemas/DateSchema.mjs +7 -5
  274. package/lib/schemas/NumberSchema.d.mts +2 -2
  275. package/lib/schemas/NumberSchema.d.ts +2 -2
  276. package/lib/schemas/NumberSchema.js +11 -10
  277. package/lib/schemas/NumberSchema.js.map +1 -1
  278. package/lib/schemas/NumberSchema.mjs +10 -9
  279. package/lib/schemas/ObjectSchema.d.mts +2 -2
  280. package/lib/schemas/ObjectSchema.d.ts +2 -2
  281. package/lib/schemas/ObjectSchema.js +8 -6
  282. package/lib/schemas/ObjectSchema.js.map +1 -1
  283. package/lib/schemas/ObjectSchema.mjs +7 -5
  284. package/lib/schemas/StringSchema.d.mts +3 -2
  285. package/lib/schemas/StringSchema.d.ts +3 -2
  286. package/lib/schemas/StringSchema.js +11 -10
  287. package/lib/schemas/StringSchema.js.map +1 -1
  288. package/lib/schemas/StringSchema.mjs +10 -9
  289. package/lib/translationMap.js +3 -3
  290. package/lib/translationMap.mjs +2 -2
  291. package/package.json +1 -1
  292. package/lib/chunk-2OINKFOA.js +0 -28
  293. package/lib/chunk-2OINKFOA.js.map +0 -1
  294. package/lib/chunk-32J4WVLE.js.map +0 -1
  295. package/lib/chunk-356HMXOP.js.map +0 -1
  296. package/lib/chunk-4SR7J2I4.js.map +0 -1
  297. package/lib/chunk-4UF67IQ2.mjs +0 -42
  298. package/lib/chunk-4UF67IQ2.mjs.map +0 -1
  299. package/lib/chunk-5EIBKBYS.js.map +0 -1
  300. package/lib/chunk-7GIRQ5EA.js.map +0 -1
  301. package/lib/chunk-7XFLH6R2.mjs.map +0 -1
  302. package/lib/chunk-EQNVYAKS.js +0 -42
  303. package/lib/chunk-EQNVYAKS.js.map +0 -1
  304. package/lib/chunk-GDSB7CDN.mjs.map +0 -1
  305. package/lib/chunk-LWAEUS2F.js +0 -14
  306. package/lib/chunk-N6YMNLXG.js.map +0 -1
  307. package/lib/chunk-PEWNA24X.mjs.map +0 -1
  308. package/lib/chunk-PJI3DRGP.mjs.map +0 -1
  309. package/lib/chunk-PVOHKGBW.mjs.map +0 -1
  310. package/lib/chunk-QLVLZRHT.js.map +0 -1
  311. package/lib/chunk-SEIKS6G7.js.map +0 -1
  312. package/lib/chunk-TP5I237J.mjs.map +0 -1
  313. package/lib/chunk-UV4I7JZR.mjs.map +0 -1
  314. package/lib/chunk-WK4O3HH4.js.map +0 -1
  315. package/lib/chunk-XFR7Y4XX.mjs.map +0 -1
  316. package/lib/chunk-XZTZC73V.mjs.map +0 -1
  317. package/lib/chunk-Z7OEFOAD.mjs.map +0 -1
  318. package/lib/helpers/isValidDate.d.mts +0 -3
  319. package/lib/helpers/isValidDate.d.ts +0 -3
  320. package/lib/helpers/isValidDate.js +0 -7
  321. package/lib/helpers/isValidDate.js.map +0 -1
  322. package/lib/helpers/isValidDate.mjs +0 -7
  323. /package/lib/{chunk-QV4JDW3T.mjs.map → chunk-4GDBM5LP.mjs.map} +0 -0
  324. /package/lib/{chunk-MRWZVTNH.mjs.map → chunk-ADSMWGDJ.mjs.map} +0 -0
  325. /package/lib/{chunk-M6OCVAUD.mjs.map → chunk-BUXOCPHI.mjs.map} +0 -0
  326. /package/lib/{chunk-54RHVQFA.mjs.map → chunk-D42ISCFK.mjs.map} +0 -0
  327. /package/lib/{chunk-YPAUFM3S.mjs.map → chunk-OHEMRF7Y.mjs.map} +0 -0
  328. /package/lib/{chunk-5AO66YV5.mjs.map → chunk-OKF3BVUD.mjs.map} +0 -0
  329. /package/lib/helpers/{isValidDate.mjs.map → isValidDateInner.mjs.map} +0 -0
@@ -1,24 +1,24 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
2
 
3
- var _chunk4SPM2CSQjs = require('./chunk-4SPM2CSQ.js');
3
+ var _chunkSPWF5IFUjs = require('./chunk-SPWF5IFU.js');
4
4
 
5
5
 
6
- var _chunkWPHJ4QTBjs = require('./chunk-WPHJ4QTB.js');
6
+ var _chunkW2GOLG3Kjs = require('./chunk-W2GOLG3K.js');
7
7
 
8
8
 
9
9
  var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
10
10
 
11
11
 
12
- var _chunkLWAEUS2Fjs = require('./chunk-LWAEUS2F.js');
12
+ var _chunk3ZPLJ5KCjs = require('./chunk-3ZPLJ5KC.js');
13
13
 
14
14
 
15
- var _chunkEQNVYAKSjs = require('./chunk-EQNVYAKS.js');
15
+ var _chunk3IOQH3K4js = require('./chunk-3IOQH3K4.js');
16
16
 
17
17
 
18
- var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
18
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
19
19
 
20
20
  // src/schemas/BigIntSchema.ts
21
- var BigIntSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
21
+ var BigIntSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
22
22
  __init() {this._bigint = 1}
23
23
 
24
24
  /**
@@ -30,10 +30,10 @@ var BigIntSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constr
30
30
  * @example - bigint().equalTo(42n); // Infers the type 42n
31
31
  */
32
32
  equalTo(expectedValue) {
33
- if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
34
- this.limit = true;
35
- _chunkLWAEUS2Fjs._setStrictType.call(void 0, this, `${expectedValue}n`);
36
- return this.custom(_chunkWPHJ4QTBjs.equalTo.call(void 0, expectedValue));
33
+ this.defaultValueCheck();
34
+ this.limitCheck();
35
+ _chunk3ZPLJ5KCjs._setStrictType.call(void 0, this, `${expectedValue}n`);
36
+ return this.custom(_chunkSPWF5IFUjs.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,17 +45,21 @@ var BigIntSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constr
45
45
  * bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n
46
46
  */
47
47
  oneOfValues(expectedValue) {
48
- if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
49
- this.limit = true;
50
- _chunkLWAEUS2Fjs._setStrictType.call(void 0,
48
+ this.defaultValueCheck();
49
+ this.limitCheck();
50
+ _chunk3ZPLJ5KCjs._setStrictType.call(void 0,
51
51
  this,
52
52
  expectedValue.map((el) => `${el}n`)
53
53
  );
54
- return this.custom(_chunk4SPM2CSQjs.oneOfValues.call(void 0, expectedValue));
54
+ return this.custom(_chunkW2GOLG3Kjs.oneOfValues.call(void 0, expectedValue));
55
+ }
56
+ limitCheck() {
57
+ if (this.limit) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
58
+ this.limit = true;
55
59
  }
56
60
  }, _class);
57
61
 
58
62
 
59
63
 
60
64
  exports.BigIntSchema = BigIntSchema;
61
- //# sourceMappingURL=chunk-SEIKS6G7.js.map
65
+ //# sourceMappingURL=chunk-P6V6S6TZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-P6V6S6TZ.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,iBACnC,QAAA,EAAU,EAAA;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,OAAA,CAA0B,aAAA,EAAuC;AACtE,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;ADW0B;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-P6V6S6TZ.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 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): WithBigInt<this, Y> {\n this.defaultValueCheck();\n this.limitCheck();\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 public oneOfValues<Y extends bigint>(expectedValue: Y[]): WithBigInt<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 WithBigInt<this, Y>;\n }\n\n private limitCheck() {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\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,22 +1,22 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunk7GIRQ5EAjs = require('./chunk-7GIRQ5EA.js');
3
+ var _chunkPIBDJJUUjs = require('./chunk-PIBDJJUU.js');
4
4
 
5
5
 
6
- var _chunkCQWI6YRIjs = require('./chunk-CQWI6YRI.js');
6
+ var _chunkUZ2PWO4Ojs = require('./chunk-UZ2PWO4O.js');
7
7
 
8
8
 
9
- var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
9
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
10
10
 
11
11
  // src/parseOrFail.ts
12
12
  function parseOrFail(schema, receivedValue, options) {
13
13
  try {
14
- return _chunk7GIRQ5EAjs.innerCheck.call(void 0, schema, receivedValue, {
15
- t: _chunkCQWI6YRIjs.getTranslationByLocale.call(void 0, _optionalChain([options, 'optionalAccess', _ => _.lng])),
14
+ return _chunkPIBDJJUUjs.innerCheck.call(void 0, schema, receivedValue, {
15
+ t: _chunkUZ2PWO4Ojs.getTranslationByLocale.call(void 0, _optionalChain([options, 'optionalAccess', _ => _.lng])),
16
16
  pathToError: ""
17
17
  });
18
18
  } catch (e) {
19
- if (e instanceof _chunkWK4O3HH4js.ValidationError) throw e;
19
+ if (e instanceof _chunkAY7HKAG2js.ValidationError) throw e;
20
20
  throw new Error("Something unexpected happened");
21
21
  }
22
22
  }
@@ -24,4 +24,4 @@ function parseOrFail(schema, receivedValue, options) {
24
24
 
25
25
 
26
26
  exports.parseOrFail = parseOrFail;
27
- //# sourceMappingURL=chunk-MTJJKWTP.js.map
27
+ //# sourceMappingURL=chunk-PESVL5YJ.js.map
@@ -1 +1 @@
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
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-PESVL5YJ.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-PESVL5YJ.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,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk356HMXOPjs = require('./chunk-356HMXOP.js');
3
+ var _chunkVBTWYDEMjs = require('./chunk-VBTWYDEM.js');
4
4
 
5
5
 
6
- var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
6
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
7
7
 
8
8
  // src/helpers/core.ts
9
9
  var ctxSymbol = Symbol("contextSymbol");
@@ -11,34 +11,45 @@ function innerCheck(schema, receivedValue, exCtx) {
11
11
  const commonTmap = exCtx.t;
12
12
  const schemaData = schema[ctxSymbol];
13
13
  if (receivedValue === void 0) {
14
- if (!schemaData.isOptional) _chunkWK4O3HH4js.guardException.call(void 0, "Required", receivedValue, exCtx, commonTmap["c:optional"]);
14
+ if (schemaData.defaultValue !== void 0) return schemaData.defaultValue;
15
+ if (!schemaData.isOptional) _chunkAY7HKAG2js.guardException.call(void 0, "Required", receivedValue, exCtx, commonTmap["c:optional"]);
15
16
  return receivedValue;
16
17
  }
17
18
  if (receivedValue === null) {
18
- if (!schemaData.isNullable) _chunkWK4O3HH4js.guardException.call(void 0, "Not null", receivedValue, exCtx, commonTmap["c:nullable"]);
19
+ if (!schemaData.isNullable) _chunkAY7HKAG2js.guardException.call(void 0, "Not null", receivedValue, exCtx, commonTmap["c:nullable"]);
19
20
  return receivedValue;
20
21
  }
21
22
  if (schemaData.date) {
22
- if (!_chunk356HMXOPjs.isValidDate.call(void 0, receivedValue)) _chunkWK4O3HH4js.guardException.call(void 0, "Date", receivedValue, exCtx, commonTmap["c:date"]);
23
+ if (!_chunkVBTWYDEMjs.isValidDateInner.call(void 0, receivedValue)) _chunkAY7HKAG2js.guardException.call(void 0, "Date", receivedValue, exCtx, commonTmap["c:date"]);
23
24
  }
25
+ const typeOfVal = typeof receivedValue;
26
+ if (schemaData.type.length) {
27
+ if (!schemaData.type.includes(typeOfVal))
28
+ _chunkAY7HKAG2js.guardException.call(void 0, schemaData.type, typeOfVal, exCtx, commonTmap["c:invalidType"]);
29
+ }
30
+ schemaData.requiredValidations.forEach((requiredValidation) => {
31
+ requiredValidation(receivedValue, exCtx);
32
+ });
24
33
  if (schemaData.array) {
25
- if (!Array.isArray(receivedValue)) return _chunkWK4O3HH4js.guardException.call(void 0, "Array", receivedValue, exCtx, commonTmap["c:array"]);
34
+ if (!Array.isArray(receivedValue)) return _chunkAY7HKAG2js.guardException.call(void 0, "Array", receivedValue, exCtx, commonTmap["c:array"]);
26
35
  const schema2 = schemaData.array;
27
36
  const pathToError = exCtx.pathToError;
37
+ const parsedReceivedValue = [];
28
38
  receivedValue.forEach((elem, i) => {
29
- innerCheck(schema2, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });
39
+ const parsedElement = innerCheck(schema2, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });
40
+ parsedReceivedValue.push(parsedElement);
30
41
  });
31
- return receivedValue;
42
+ return parsedReceivedValue;
32
43
  }
33
- const typeOfVal = typeof receivedValue;
34
44
  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"]);
45
+ if (typeOfVal !== "object") _chunkAY7HKAG2js.guardException.call(void 0, "Object", receivedValue, exCtx, commonTmap["c:objectType"]);
46
+ if (Array.isArray(receivedValue)) _chunkAY7HKAG2js.guardException.call(void 0, "Object", receivedValue, exCtx, commonTmap["c:objectTypeAsArray"]);
37
47
  const shapeSchema = schemaData.object;
48
+ const parsedReceivedValue = {};
38
49
  if (!schemaData.allowUnrecognizedObjectProps) {
39
50
  for (const keyPerReceivedValue of Object.keys(receivedValue)) {
40
51
  if (shapeSchema[keyPerReceivedValue] === void 0)
41
- _chunkWK4O3HH4js.guardException.call(void 0, "Unrecognized property", keyPerReceivedValue, exCtx, commonTmap["c:unrecognizedProperty"]);
52
+ _chunkAY7HKAG2js.guardException.call(void 0, "Unrecognized property", keyPerReceivedValue, exCtx, commonTmap["c:unrecognizedProperty"]);
42
53
  }
43
54
  }
44
55
  const pathToError = exCtx.pathToError;
@@ -46,19 +57,16 @@ function innerCheck(schema, receivedValue, exCtx) {
46
57
  const receivedObjectValuePropery = receivedValue[keyOfSchema];
47
58
  if (receivedObjectValuePropery === void 0) {
48
59
  if (!valueOfSchema[ctxSymbol].isOptional)
49
- _chunkWK4O3HH4js.guardException.call(void 0, "Required", receivedObjectValuePropery, exCtx, commonTmap["c:requiredProperty"]);
60
+ _chunkAY7HKAG2js.guardException.call(void 0, "Required", receivedObjectValuePropery, exCtx, commonTmap["c:requiredProperty"]);
50
61
  }
51
- innerCheck(valueOfSchema, receivedObjectValuePropery, { ...exCtx, pathToError: `${pathToError}.${keyOfSchema}` });
62
+ const parsedReceivedObjectValuePropery = innerCheck(valueOfSchema, receivedObjectValuePropery, {
63
+ ...exCtx,
64
+ pathToError: `${pathToError}.${keyOfSchema}`
65
+ });
66
+ parsedReceivedValue[keyOfSchema] = parsedReceivedObjectValuePropery;
52
67
  }
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"]);
68
+ return parsedReceivedValue;
58
69
  }
59
- schemaData.requiredValidations.forEach((requiredValidation) => {
60
- requiredValidation(receivedValue, exCtx);
61
- });
62
70
  return receivedValue;
63
71
  }
64
72
 
@@ -66,4 +74,4 @@ function innerCheck(schema, receivedValue, exCtx) {
66
74
 
67
75
 
68
76
  exports.ctxSymbol = ctxSymbol; exports.innerCheck = innerCheck;
69
- //# sourceMappingURL=chunk-7GIRQ5EA.js.map
77
+ //# sourceMappingURL=chunk-PIBDJJUU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-PIBDJJUU.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,EAAkC;AACzG,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,UAAA,CAAW,aAAA,IAAiB,KAAA,CAAA,EAAW,OAAO,UAAA,CAAW,YAAA;AAC7D,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,+CAAA,aAA8B,CAAA,EAAG,6CAAA,MAAe,EAAQ,aAAA,EAAe,KAAA,EAAO,UAAA,CAAW,QAAQ,CAAC,CAAA;AAAA,EACzG;AAEA,EAAA,MAAM,UAAA,EAAY,OAAO,aAAA;AAEzB,EAAA,GAAA,CAAI,UAAA,CAAW,IAAA,CAAK,MAAA,EAAQ;AAC1B,IAAA,GAAA,CAAI,CAAC,UAAA,CAAW,IAAA,CAAK,QAAA,CAAS,SAAS,CAAA;AACrC,MAAA,6CAAA,UAAe,CAAW,IAAA,EAAM,SAAA,EAAW,KAAA,EAAO,UAAA,CAAW,eAAe,CAAC,CAAA;AAAA,EACjF;AAEA,EAAA,UAAA,CAAW,mBAAA,CAAoB,OAAA,CAAQ,CAAC,kBAAA,EAAA,GAAuB;AAC7D,IAAA,kBAAA,CAAmB,aAAA,EAAe,KAAK,CAAA;AAAA,EACzC,CAAC,CAAA;AAED,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,MAAM,oBAAA,EAAiC,CAAC,CAAA;AACxC,IAAA,aAAA,CAAc,OAAA,CAAQ,CAAC,IAAA,EAAM,CAAA,EAAA,GAAM;AACjC,MAAA,MAAM,cAAA,EAAgB,UAAA,CAAWA,OAAAA,EAAQ,IAAA,EAAM,EAAE,GAAG,KAAA,EAAO,WAAA,EAAa,CAAA,EAAA;AAClC,MAAA;AACvC,IAAA;AAEM,IAAA;AACT,EAAA;AAEuB,EAAA;AACsD,IAAA;AACD,IAAA;AAC3C,IAAA;AACuB,IAAA;AAER,IAAA;AACkB,MAAA;AACnB,QAAA;AAC6B,UAAA;AACxE,MAAA;AACF,IAAA;AAE0B,IAAA;AAC8C,IAAA;AACmB,MAAA;AAC3C,MAAA;AACd,QAAA;AACkC,UAAA;AAClE,MAAA;AAEmE,MAAA;AAC9D,QAAA;AACuC,QAAA;AAC3C,MAAA;AAEkC,MAAA;AACrC,IAAA;AAEO,IAAA;AACT,EAAA;AAEO,EAAA;AACT;ADXgF;AACA;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-PIBDJJUU.js","sourcesContent":[null,"export const ctxSymbol = Symbol('contextSymbol');\n\nimport { ExceptionContext } from '../commonTypes';\nimport { guardException } from '../exceptions';\nimport type { CommonSchema } from '../schemas/CommonSchema';\nimport { isValidDateInner } from './isValidDateInner';\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, exCtx: ExceptionContext): unknown {\n const commonTmap = exCtx.t;\n const schemaData = schema[ctxSymbol];\n if (receivedValue === undefined) {\n if (schemaData.defaultValue !== undefined) return schemaData.defaultValue;\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 (!isValidDateInner(receivedValue)) guardException('Date', receivedValue, exCtx, commonTmap['c:date']);\n }\n\n const typeOfVal = typeof receivedValue;\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 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 const parsedReceivedValue: unknown[] = [];\n receivedValue.forEach((elem, i) => {\n const parsedElement = innerCheck(schema, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });\n parsedReceivedValue.push(parsedElement);\n });\n\n return parsedReceivedValue;\n }\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 const parsedReceivedValue: Record<string, unknown> = {};\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 const parsedReceivedObjectValuePropery = innerCheck(valueOfSchema, receivedObjectValuePropery, {\n ...exCtx,\n pathToError: `${pathToError}.${keyOfSchema}`,\n });\n\n parsedReceivedValue[keyOfSchema] = parsedReceivedObjectValuePropery;\n }\n\n return parsedReceivedValue;\n }\n\n return receivedValue;\n}\n"]}
@@ -1,21 +1,21 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkCQWI6YRIjs = require('./chunk-CQWI6YRI.js');
3
+ var _chunkUZ2PWO4Ojs = require('./chunk-UZ2PWO4O.js');
4
4
 
5
5
 
6
- var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
6
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
7
7
 
8
8
  // src/asserts/mix/equalTo.ts
9
9
  var equalToErrorMessage = "The received value is not equal to expected";
10
10
  var equalToErrorKey = "m:equalTo";
11
11
  var equalTo = (expected) => (received, ctx) => {
12
- if (expected !== received) _chunkWK4O3HH4js.guardException.call(void 0, expected, received, ctx, equalToErrorKey);
12
+ if (expected !== received) _chunkAY7HKAG2js.guardException.call(void 0, expected, received, ctx, equalToErrorKey);
13
13
  };
14
14
  equalTo.key = equalToErrorKey;
15
15
  equalTo.message = equalToErrorMessage;
16
- _chunkCQWI6YRIjs.setToDefaultLocale.call(void 0, equalTo);
16
+ _chunkUZ2PWO4Ojs.setToDefaultLocale.call(void 0, equalTo);
17
17
 
18
18
 
19
19
 
20
20
  exports.equalTo = equalTo;
21
- //# sourceMappingURL=chunk-WPHJ4QTB.js.map
21
+ //# sourceMappingURL=chunk-SPWF5IFU.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-WPHJ4QTB.js","../src/asserts/mix/equalTo.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACHA,IAAM,oBAAA,EAAsB,6CAAA;AAC5B,IAAM,gBAAA,EAAkB,WAAA;AAejB,IAAM,QAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AAC5C,EAAA,GAAA,CAAI,SAAA,IAAa,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,eAAe,CAAA;AACpF,CAAA;AAEF,OAAA,CAAQ,IAAA,EAAM,eAAA;AACd,OAAA,CAAQ,QAAA,EAAU,mBAAA;AAClB,iDAAA,OAA0B,CAAA;ADZ1B;AACA;AACE;AACF,0BAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-WPHJ4QTB.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst equalToErrorMessage = 'The received value is not equal to expected';\nconst equalToErrorKey = 'm:equalTo';\n\n/**\n * @description Creates a custom assertion that checks if a value is equal to the expected value.\n * @notice It has already been implemented in the number, bigint and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match the expected value.\n * @example\n * const schema = number().custom(equalTo(5)); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:equalTo'\n */\nexport const equalTo =\n (expected: unknown): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (expected !== received) guardException(expected, received, ctx, equalToErrorKey);\n };\n\nequalTo.key = equalToErrorKey;\nequalTo.message = equalToErrorMessage;\nsetToDefaultLocale(equalTo);\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-SPWF5IFU.js","../src/asserts/mix/equalTo.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACHA,IAAM,oBAAA,EAAsB,6CAAA;AAC5B,IAAM,gBAAA,EAAkB,WAAA;AAejB,IAAM,QAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AAC5C,EAAA,GAAA,CAAI,SAAA,IAAa,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,eAAe,CAAA;AACpF,CAAA;AAEF,OAAA,CAAQ,IAAA,EAAM,eAAA;AACd,OAAA,CAAQ,QAAA,EAAU,mBAAA;AAClB,iDAAA,OAA0B,CAAA;ADZ1B;AACA;AACE;AACF,0BAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-SPWF5IFU.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst equalToErrorMessage = 'The received value is not equal to expected';\nconst equalToErrorKey = 'm:equalTo';\n\n/**\n * @description Creates a custom assertion that checks if a value is equal to the expected value.\n * @notice It has already been implemented in the number, bigint and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match the expected value.\n * @example\n * const schema = number().custom(equalTo(5)); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:equalTo'\n */\nexport const equalTo =\n (expected: unknown): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (expected !== received) guardException(expected, received, ctx, equalToErrorKey);\n };\n\nequalTo.key = equalToErrorKey;\nequalTo.message = equalToErrorMessage;\nsetToDefaultLocale(equalTo);\n"]}
@@ -1,21 +1,21 @@
1
- import {
2
- oneOfValues
3
- } from "./chunk-YPAUFM3S.mjs";
4
1
  import {
5
2
  equalTo
6
- } from "./chunk-M6OCVAUD.mjs";
3
+ } from "./chunk-BUXOCPHI.mjs";
4
+ import {
5
+ oneOfValues
6
+ } from "./chunk-OHEMRF7Y.mjs";
7
7
  import {
8
8
  ONLY_ONCE
9
9
  } from "./chunk-ASZW6XRM.mjs";
10
10
  import {
11
11
  _setStrictType
12
- } from "./chunk-54RHVQFA.mjs";
12
+ } from "./chunk-D42ISCFK.mjs";
13
13
  import {
14
14
  CommonSchema
15
- } from "./chunk-4UF67IQ2.mjs";
15
+ } from "./chunk-AOUFWACR.mjs";
16
16
  import {
17
17
  BuildSchemaError
18
- } from "./chunk-7XFLH6R2.mjs";
18
+ } from "./chunk-NP64RC7B.mjs";
19
19
 
20
20
  // src/schemas/NumberSchema.ts
21
21
  var NumberSchema = class extends CommonSchema {
@@ -55,4 +55,4 @@ var NumberSchema = class extends CommonSchema {
55
55
  export {
56
56
  NumberSchema
57
57
  };
58
- //# sourceMappingURL=chunk-Z7OEFOAD.mjs.map
58
+ //# sourceMappingURL=chunk-TQWUSDQD.mjs.map
@@ -0,0 +1 @@
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 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): 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 public 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,EACnC,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,QAA0B,eAAuC;AACtE,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,EAWO,YAA8B,eAAyC;AAC5E,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,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
3
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
4
4
 
5
5
  // src/translationMap.ts
6
6
  var defaultErrorMap = {
@@ -25,11 +25,11 @@ function setToDefaultLocale({
25
25
  message
26
26
  }) {
27
27
  const defaultLocale = data.default;
28
- if (defaultLocale[key]) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Duplicate default message key");
28
+ if (defaultLocale[key]) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)("Duplicate default message key");
29
29
  defaultLocale[key] = message;
30
30
  }
31
31
  function setLocale(lng, custom) {
32
- if (lng === "default") throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Invalid language");
32
+ if (lng === "default") throw new (0, _chunkAY7HKAG2js.BuildSchemaError)("Invalid language");
33
33
  if (!data[lng]) data[lng] = { ...defaultErrorMap };
34
34
  const locale = data[lng];
35
35
  Object.entries(custom).forEach(([messageKey, messageValue]) => {
@@ -52,4 +52,4 @@ function getTranslationByLocale(lng) {
52
52
 
53
53
 
54
54
  exports.setToDefaultLocale = setToDefaultLocale; exports.setLocale = setLocale; exports.clearLocales = clearLocales; exports.getTranslationByLocale = getTranslationByLocale;
55
- //# sourceMappingURL=chunk-CQWI6YRI.js.map
55
+ //# sourceMappingURL=chunk-UZ2PWO4O.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-CQWI6YRI.js","../src/translationMap.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACAA,IAAM,gBAAA,EAAuC;AAAA;AAAA,EAE3C,YAAA,EAAc,+BAAA;AAAA,EACd,YAAA,EAAc,0BAAA;AAAA,EACd,SAAA,EAAW,iDAAA;AAAA,EACX,cAAA,EAAgB,kDAAA;AAAA,EAChB,qBAAA,EAAuB,gEAAA;AAAA,EACvB,wBAAA,EAA0B,4CAAA;AAAA,EAC1B,oBAAA,EAAsB,yCAAA;AAAA,EACtB,eAAA,EAAiB,sBAAA;AAAA,EACjB,aAAA,EAAe,iCAAA;AAAA,EACf,QAAA,EAAU;AAAA;AAEZ,CAAA;AAEA,IAAI,KAAA,EAA+C;AAAA,EACjD,OAAA,EAAS,EAAE,GAAG,gBAAgB;AAChC,CAAA;AAEO,SAAS,kBAAA,CAAmB;AAAA,EACjC,GAAA;AAAA,EACA;AACF,CAAA,EAKG;AACD,EAAA,MAAM,cAAA,EAAgB,IAAA,CAAK,OAAA;AAC3B,EAAA,GAAA,CAAI,aAAA,CAAc,GAAG,CAAA,EAAG,MAAM,IAAI,sCAAA,CAAiB,+BAA+B,CAAA;AAClF,EAAA,aAAA,CAAc,GAAG,EAAA,EAAI,OAAA;AACvB;AAEO,SAAS,SAAA,CAAU,GAAA,EAAa,MAAA,EAAsC;AAC3E,EAAA,GAAA,CAAI,IAAA,IAAQ,SAAA,EAAW,MAAM,IAAI,sCAAA,CAAiB,kBAAkB,CAAA;AACpE,EAAA,GAAA,CAAI,CAAC,IAAA,CAAK,GAAG,CAAA,EAAG,IAAA,CAAK,GAAG,EAAA,EAAI,EAAE,GAAG,gBAAgB,CAAA;AACjD,EAAA,MAAM,OAAA,EAAS,IAAA,CAAK,GAAG,CAAA;AACvB,EAAA,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAC,UAAA,EAAY,YAAY,CAAA,EAAA,GAAM;AAC7D,IAAA,MAAA,CAAO,UAAU,EAAA,EAAI,YAAA;AAAA,EACvB,CAAC,CAAA;AACH;AAEO,SAAS,YAAA,CAAA,EAAe;AAC7B,EAAA,KAAA,EAAO;AAAA,IACL,OAAA,EAAS,EAAE,GAAG,gBAAgB;AAAA,EAChC,CAAA;AACF;AAEO,SAAS,sBAAA,CAAuB,GAAA,EAAmC;AACxE,EAAA,GAAA,CAAI,CAAC,GAAA,EAAK,OAAO,IAAA,CAAK,SAAS,CAAA;AAC/B,EAAA,wBAAQ,IAAA,CAAK,GAAG,CAAA,UAAK,IAAA,CAAK,SAAS,GAAA;AACrC;ADRA;AACA;AACE;AACA;AACA;AACA;AACF,6KAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-CQWI6YRI.js","sourcesContent":[null,"import { BuildSchemaError } from './exceptions';\nimport { RequiredValidation, TranslationErrorMap } from './commonTypes';\n\n// c: stands for common\nconst defaultErrorMap: TranslationErrorMap = {\n //@@start\n 'c:optional': 'The required value is missing',\n 'c:nullable': 'Value should not be null',\n 'c:array': 'Expected an array but received a different type',\n 'c:objectType': 'Expected an object but received a different type',\n 'c:objectTypeAsArray': 'Expected an object but received an array. Invalid type of data',\n 'c:unrecognizedProperty': 'This property is not allowed in the object',\n 'c:requiredProperty': 'Missing required property in the object',\n 'c:invalidType': 'Invalid type of data',\n 'c:isBoolean': 'The received value is not {{e}}',\n 'c:date': 'The received value is not a valid instance of Date',\n //@@end\n};\n\nlet data: Record<string, Record<string, string>> = {\n default: { ...defaultErrorMap },\n};\n\nexport function setToDefaultLocale({\n key,\n message,\n}: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (expected: any): RequiredValidation;\n key: string;\n message: string;\n}) {\n const defaultLocale = data.default!;\n if (defaultLocale[key]) throw new BuildSchemaError('Duplicate default message key');\n defaultLocale[key] = message;\n}\n\nexport function setLocale(lng: string, custom: Partial<TranslationErrorMap>) {\n if (lng === 'default') throw new BuildSchemaError('Invalid language');\n if (!data[lng]) data[lng] = { ...defaultErrorMap };\n const locale = data[lng]!;\n Object.entries(custom).forEach(([messageKey, messageValue]) => {\n locale[messageKey] = messageValue!;\n });\n}\n\nexport function clearLocales() {\n data = {\n default: { ...defaultErrorMap },\n };\n}\n\nexport function getTranslationByLocale(lng?: string): TranslationErrorMap {\n if (!lng) return data['default'] as TranslationErrorMap;\n return (data[lng] ?? data['default']) as TranslationErrorMap;\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-UZ2PWO4O.js","../src/translationMap.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACAA,IAAM,gBAAA,EAAuC;AAAA;AAAA,EAE3C,YAAA,EAAc,+BAAA;AAAA,EACd,YAAA,EAAc,0BAAA;AAAA,EACd,SAAA,EAAW,iDAAA;AAAA,EACX,cAAA,EAAgB,kDAAA;AAAA,EAChB,qBAAA,EAAuB,gEAAA;AAAA,EACvB,wBAAA,EAA0B,4CAAA;AAAA,EAC1B,oBAAA,EAAsB,yCAAA;AAAA,EACtB,eAAA,EAAiB,sBAAA;AAAA,EACjB,aAAA,EAAe,iCAAA;AAAA,EACf,QAAA,EAAU;AAAA;AAEZ,CAAA;AAEA,IAAI,KAAA,EAA+C;AAAA,EACjD,OAAA,EAAS,EAAE,GAAG,gBAAgB;AAChC,CAAA;AAEO,SAAS,kBAAA,CAAmB;AAAA,EACjC,GAAA;AAAA,EACA;AACF,CAAA,EAKG;AACD,EAAA,MAAM,cAAA,EAAgB,IAAA,CAAK,OAAA;AAC3B,EAAA,GAAA,CAAI,aAAA,CAAc,GAAG,CAAA,EAAG,MAAM,IAAI,sCAAA,CAAiB,+BAA+B,CAAA;AAClF,EAAA,aAAA,CAAc,GAAG,EAAA,EAAI,OAAA;AACvB;AAEO,SAAS,SAAA,CAAU,GAAA,EAAa,MAAA,EAAsC;AAC3E,EAAA,GAAA,CAAI,IAAA,IAAQ,SAAA,EAAW,MAAM,IAAI,sCAAA,CAAiB,kBAAkB,CAAA;AACpE,EAAA,GAAA,CAAI,CAAC,IAAA,CAAK,GAAG,CAAA,EAAG,IAAA,CAAK,GAAG,EAAA,EAAI,EAAE,GAAG,gBAAgB,CAAA;AACjD,EAAA,MAAM,OAAA,EAAS,IAAA,CAAK,GAAG,CAAA;AACvB,EAAA,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAC,UAAA,EAAY,YAAY,CAAA,EAAA,GAAM;AAC7D,IAAA,MAAA,CAAO,UAAU,EAAA,EAAI,YAAA;AAAA,EACvB,CAAC,CAAA;AACH;AAEO,SAAS,YAAA,CAAA,EAAe;AAC7B,EAAA,KAAA,EAAO;AAAA,IACL,OAAA,EAAS,EAAE,GAAG,gBAAgB;AAAA,EAChC,CAAA;AACF;AAEO,SAAS,sBAAA,CAAuB,GAAA,EAAmC;AACxE,EAAA,GAAA,CAAI,CAAC,GAAA,EAAK,OAAO,IAAA,CAAK,SAAS,CAAA;AAC/B,EAAA,wBAAQ,IAAA,CAAK,GAAG,CAAA,UAAK,IAAA,CAAK,SAAS,GAAA;AACrC;ADRA;AACA;AACE;AACA;AACA;AACA;AACF,6KAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-UZ2PWO4O.js","sourcesContent":[null,"import { BuildSchemaError } from './exceptions';\nimport { RequiredValidation, TranslationErrorMap } from './commonTypes';\n\n// c: stands for common\nconst defaultErrorMap: TranslationErrorMap = {\n //@@start\n 'c:optional': 'The required value is missing',\n 'c:nullable': 'Value should not be null',\n 'c:array': 'Expected an array but received a different type',\n 'c:objectType': 'Expected an object but received a different type',\n 'c:objectTypeAsArray': 'Expected an object but received an array. Invalid type of data',\n 'c:unrecognizedProperty': 'This property is not allowed in the object',\n 'c:requiredProperty': 'Missing required property in the object',\n 'c:invalidType': 'Invalid type of data',\n 'c:isBoolean': 'The received value is not {{e}}',\n 'c:date': 'The received value is not a valid instance of Date',\n //@@end\n};\n\nlet data: Record<string, Record<string, string>> = {\n default: { ...defaultErrorMap },\n};\n\nexport function setToDefaultLocale({\n key,\n message,\n}: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (expected: any): RequiredValidation;\n key: string;\n message: string;\n}) {\n const defaultLocale = data.default!;\n if (defaultLocale[key]) throw new BuildSchemaError('Duplicate default message key');\n defaultLocale[key] = message;\n}\n\nexport function setLocale(lng: string, custom: Partial<TranslationErrorMap>) {\n if (lng === 'default') throw new BuildSchemaError('Invalid language');\n if (!data[lng]) data[lng] = { ...defaultErrorMap };\n const locale = data[lng]!;\n Object.entries(custom).forEach(([messageKey, messageValue]) => {\n locale[messageKey] = messageValue!;\n });\n}\n\nexport function clearLocales() {\n data = {\n default: { ...defaultErrorMap },\n };\n}\n\nexport function getTranslationByLocale(lng?: string): TranslationErrorMap {\n if (!lng) return data['default'] as TranslationErrorMap;\n return (data[lng] ?? data['default']) as TranslationErrorMap;\n}\n"]}
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/helpers/isValidDate.ts
2
- function isValidDate(d) {
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/helpers/isValidDateInner.ts
2
+ function isValidDateInner(d) {
3
3
  return (
4
4
  // @ts-expect-error we expect d to have getTime method
5
5
  Object.prototype.toString.call(d) === "[object Date]" && !isNaN(typeof _optionalChain([d, 'optionalAccess', _ => _.getTime]) === "function" && d.getTime())
@@ -8,5 +8,5 @@ function isValidDate(d) {
8
8
 
9
9
 
10
10
 
11
- exports.isValidDate = isValidDate;
12
- //# sourceMappingURL=chunk-356HMXOP.js.map
11
+ exports.isValidDateInner = isValidDateInner;
12
+ //# sourceMappingURL=chunk-VBTWYDEM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-VBTWYDEM.js","../src/helpers/isValidDateInner.ts"],"names":[],"mappings":"AAAA;ACAO,SAAS,gBAAA,CAAiB,CAAA,EAAY;AAC3C,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,4CAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-VBTWYDEM.js","sourcesContent":[null,"export function isValidDateInner(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,21 +1,21 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkCQWI6YRIjs = require('./chunk-CQWI6YRI.js');
3
+ var _chunkUZ2PWO4Ojs = require('./chunk-UZ2PWO4O.js');
4
4
 
5
5
 
6
- var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
6
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
7
7
 
8
8
  // src/asserts/mix/oneOfValues.ts
9
9
  var oneOfValuesErrorMessage = "The received value is not equal to expected";
10
10
  var oneOfValuesErrorKey = "m:oneOfValues";
11
11
  var oneOfValues = (expected) => (received, ctx) => {
12
- if (!expected.includes(received)) _chunkWK4O3HH4js.guardException.call(void 0, expected, received, ctx, oneOfValuesErrorKey);
12
+ if (!expected.includes(received)) _chunkAY7HKAG2js.guardException.call(void 0, expected, received, ctx, oneOfValuesErrorKey);
13
13
  };
14
14
  oneOfValues.key = oneOfValuesErrorKey;
15
15
  oneOfValues.message = oneOfValuesErrorMessage;
16
- _chunkCQWI6YRIjs.setToDefaultLocale.call(void 0, oneOfValues);
16
+ _chunkUZ2PWO4Ojs.setToDefaultLocale.call(void 0, oneOfValues);
17
17
 
18
18
 
19
19
 
20
20
  exports.oneOfValues = oneOfValues;
21
- //# sourceMappingURL=chunk-4SPM2CSQ.js.map
21
+ //# sourceMappingURL=chunk-W2GOLG3K.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-4SPM2CSQ.js","../src/asserts/mix/oneOfValues.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACHA,IAAM,wBAAA,EAA0B,6CAAA;AAChC,IAAM,oBAAA,EAAsB,eAAA;AAgBrB,IAAM,YAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AAC5C,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,QAAA,CAAS,QAAQ,CAAA,EAAG,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,mBAAmB,CAAA;AAC/F,CAAA;AAEF,WAAA,CAAY,IAAA,EAAM,mBAAA;AAClB,WAAA,CAAY,QAAA,EAAU,uBAAA;AACtB,iDAAA,WAA8B,CAAA;ADb9B;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-4SPM2CSQ.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst oneOfValuesErrorMessage = 'The received value is not equal to expected';\nconst oneOfValuesErrorKey = 'm:oneOfValues';\n\n/**\n * @description Creates a custom assertion that checks if a value is equal to the one of expected values.\n * @notice It has already been implemented in the number, bigint and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match at least one of the expected values.\n * @example\n * const schema = number().custom(oneOfValues([5, 4])); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 4); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:oneOfValues'\n */\nexport const oneOfValues =\n (expected: unknown[]): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (!expected.includes(received)) guardException(expected, received, ctx, oneOfValuesErrorKey);\n };\n\noneOfValues.key = oneOfValuesErrorKey;\noneOfValues.message = oneOfValuesErrorMessage;\nsetToDefaultLocale(oneOfValues);\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-W2GOLG3K.js","../src/asserts/mix/oneOfValues.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACHA,IAAM,wBAAA,EAA0B,6CAAA;AAChC,IAAM,oBAAA,EAAsB,eAAA;AAgBrB,IAAM,YAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AAC5C,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,QAAA,CAAS,QAAQ,CAAA,EAAG,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,mBAAmB,CAAA;AAC/F,CAAA;AAEF,WAAA,CAAY,IAAA,EAAM,mBAAA;AAClB,WAAA,CAAY,QAAA,EAAU,uBAAA;AACtB,iDAAA,WAA8B,CAAA;ADb9B;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-W2GOLG3K.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst oneOfValuesErrorMessage = 'The received value is not equal to expected';\nconst oneOfValuesErrorKey = 'm:oneOfValues';\n\n/**\n * @description Creates a custom assertion that checks if a value is equal to the one of expected values.\n * @notice It has already been implemented in the number, bigint and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match at least one of the expected values.\n * @example\n * const schema = number().custom(oneOfValues([5, 4])); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 4); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:oneOfValues'\n */\nexport const oneOfValues =\n (expected: unknown[]): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (!expected.includes(received)) guardException(expected, received, ctx, oneOfValuesErrorKey);\n };\n\noneOfValues.key = oneOfValuesErrorKey;\noneOfValues.message = oneOfValuesErrorMessage;\nsetToDefaultLocale(oneOfValues);\n"]}
@@ -1,5 +1,5 @@
1
- // src/helpers/isValidDate.ts
2
- function isValidDate(d) {
1
+ // src/helpers/isValidDateInner.ts
2
+ function isValidDateInner(d) {
3
3
  return (
4
4
  // @ts-expect-error we expect d to have getTime method
5
5
  Object.prototype.toString.call(d) === "[object Date]" && !isNaN(typeof d?.getTime === "function" && d.getTime())
@@ -7,6 +7,6 @@ function isValidDate(d) {
7
7
  }
8
8
 
9
9
  export {
10
- isValidDate
10
+ isValidDateInner
11
11
  };
12
- //# sourceMappingURL=chunk-GDSB7CDN.mjs.map
12
+ //# sourceMappingURL=chunk-YBVMP4EI.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers/isValidDateInner.ts"],"sourcesContent":["export function isValidDateInner(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,iBAAiB,GAAY;AAC3C;AAAA;AAAA,IAEE,OAAO,UAAU,SAAS,KAAK,CAAC,MAAM,mBAAmB,CAAC,MAAM,OAAO,GAAG,YAAY,cAAc,EAAE,QAAQ,CAAC;AAAA;AAEnH;","names":[]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  _setStrictType
3
- } from "./chunk-54RHVQFA.mjs";
3
+ } from "./chunk-D42ISCFK.mjs";
4
4
  import {
5
5
  CommonSchema
6
- } from "./chunk-4UF67IQ2.mjs";
6
+ } from "./chunk-AOUFWACR.mjs";
7
7
  import {
8
8
  guardException
9
- } from "./chunk-7XFLH6R2.mjs";
9
+ } from "./chunk-NP64RC7B.mjs";
10
10
 
11
11
  // src/schemas/BooleanSchema.ts
12
12
  var isBoolean = (expected) => (received, ctx) => {
@@ -41,4 +41,4 @@ var BooleanSchema = class extends CommonSchema {
41
41
  export {
42
42
  BooleanSchema
43
43
  };
44
- //# sourceMappingURL=chunk-PJI3DRGP.mjs.map
44
+ //# sourceMappingURL=chunk-YPAFWVDL.mjs.map
@@ -0,0 +1 @@
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 protected _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 public 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 public 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,EACpC,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASd,WAAoC;AACzC,mBAAe,MAAM,IAAI;AACzB,WAAO,KAAK,OAAO,UAAU,IAAI,CAAC;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,YAAsC;AAC3C,mBAAe,MAAM,KAAK;AAC1B,WAAO,KAAK,OAAO,UAAU,KAAK,CAAC;AAAA,EACrC;AACF;","names":[]}
@@ -1,21 +1,21 @@
1
- import {
2
- oneOfValues
3
- } from "./chunk-YPAUFM3S.mjs";
4
1
  import {
5
2
  equalTo
6
- } from "./chunk-M6OCVAUD.mjs";
3
+ } from "./chunk-BUXOCPHI.mjs";
4
+ import {
5
+ oneOfValues
6
+ } from "./chunk-OHEMRF7Y.mjs";
7
7
  import {
8
8
  ONLY_ONCE
9
9
  } from "./chunk-ASZW6XRM.mjs";
10
10
  import {
11
11
  _setStrictType
12
- } from "./chunk-54RHVQFA.mjs";
12
+ } from "./chunk-D42ISCFK.mjs";
13
13
  import {
14
14
  CommonSchema
15
- } from "./chunk-4UF67IQ2.mjs";
15
+ } from "./chunk-AOUFWACR.mjs";
16
16
  import {
17
17
  BuildSchemaError
18
- } from "./chunk-7XFLH6R2.mjs";
18
+ } from "./chunk-NP64RC7B.mjs";
19
19
 
20
20
  // src/schemas/BigIntSchema.ts
21
21
  var BigIntSchema = class extends CommonSchema {
@@ -30,8 +30,8 @@ var BigIntSchema = class extends CommonSchema {
30
30
  * @example - bigint().equalTo(42n); // Infers the type 42n
31
31
  */
32
32
  equalTo(expectedValue) {
33
- if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
34
- this.limit = true;
33
+ this.defaultValueCheck();
34
+ this.limitCheck();
35
35
  _setStrictType(this, `${expectedValue}n`);
36
36
  return this.custom(equalTo(expectedValue));
37
37
  }
@@ -45,17 +45,21 @@ var BigIntSchema = class extends CommonSchema {
45
45
  * bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n
46
46
  */
47
47
  oneOfValues(expectedValue) {
48
- if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
49
- this.limit = true;
48
+ this.defaultValueCheck();
49
+ this.limitCheck();
50
50
  _setStrictType(
51
51
  this,
52
52
  expectedValue.map((el) => `${el}n`)
53
53
  );
54
54
  return this.custom(oneOfValues(expectedValue));
55
55
  }
56
+ limitCheck() {
57
+ if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
58
+ this.limit = true;
59
+ }
56
60
  };
57
61
 
58
62
  export {
59
63
  BigIntSchema
60
64
  };
61
- //# sourceMappingURL=chunk-UV4I7JZR.mjs.map
65
+ //# sourceMappingURL=chunk-ZMEQCIRN.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 { 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): WithBigInt<this, Y> {\n this.defaultValueCheck();\n this.limitCheck();\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 public oneOfValues<Y extends bigint>(expectedValue: Y[]): WithBigInt<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 WithBigInt<this, Y>;\n }\n\n private limitCheck() {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\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,EACnC,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,QAA0B,eAAuC;AACtE,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,eAAyC;AAC5E,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":[]}