bguard 0.1.1 → 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 (383) hide show
  1. package/README.md +561 -175
  2. package/lib/{CommonSchema-CjsYE4dC.d.mts → CommonSchema-CiY7spmg.d.mts} +12 -3
  3. package/lib/{CommonSchema-BbGNki0L.d.ts → CommonSchema-D9QVJBJe.d.ts} +12 -3
  4. package/lib/InferType.d.mts +5 -2
  5. package/lib/InferType.d.ts +5 -2
  6. package/lib/asserts/array/index.d.mts +4 -4
  7. package/lib/asserts/array/index.d.ts +4 -4
  8. package/lib/asserts/array/index.js +13 -6
  9. package/lib/asserts/array/index.js.map +1 -1
  10. package/lib/asserts/array/index.mjs +13 -6
  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.d.mts +22 -0
  25. package/lib/asserts/bigint/bigintMax.d.ts +22 -0
  26. package/lib/asserts/bigint/bigintMax.js +20 -0
  27. package/lib/asserts/bigint/bigintMax.js.map +1 -0
  28. package/lib/asserts/bigint/bigintMax.mjs +20 -0
  29. package/lib/asserts/bigint/bigintMax.mjs.map +1 -0
  30. package/lib/asserts/bigint/bigintMaxExcluded.d.mts +22 -0
  31. package/lib/asserts/bigint/bigintMaxExcluded.d.ts +22 -0
  32. package/lib/asserts/bigint/bigintMaxExcluded.js +20 -0
  33. package/lib/asserts/bigint/bigintMaxExcluded.js.map +1 -0
  34. package/lib/asserts/bigint/bigintMaxExcluded.mjs +20 -0
  35. package/lib/asserts/bigint/bigintMaxExcluded.mjs.map +1 -0
  36. package/lib/asserts/bigint/bigintMin.d.mts +22 -0
  37. package/lib/asserts/bigint/bigintMin.d.ts +22 -0
  38. package/lib/asserts/bigint/bigintMin.js +20 -0
  39. package/lib/asserts/bigint/bigintMin.js.map +1 -0
  40. package/lib/asserts/bigint/bigintMin.mjs +20 -0
  41. package/lib/asserts/bigint/bigintMin.mjs.map +1 -0
  42. package/lib/asserts/bigint/bigintMinExcluded.d.mts +22 -0
  43. package/lib/asserts/bigint/bigintMinExcluded.d.ts +22 -0
  44. package/lib/asserts/bigint/bigintMinExcluded.js +20 -0
  45. package/lib/asserts/bigint/bigintMinExcluded.js.map +1 -0
  46. package/lib/asserts/bigint/bigintMinExcluded.mjs +20 -0
  47. package/lib/asserts/bigint/bigintMinExcluded.mjs.map +1 -0
  48. package/lib/asserts/bigint/index.d.mts +18 -0
  49. package/lib/asserts/bigint/index.d.ts +18 -0
  50. package/lib/asserts/bigint/index.js +22 -0
  51. package/lib/asserts/bigint/index.js.map +1 -0
  52. package/lib/asserts/bigint/index.mjs +22 -0
  53. package/lib/asserts/bigint/index.mjs.map +1 -0
  54. package/lib/asserts/boolean/index.d.mts +4 -4
  55. package/lib/asserts/boolean/index.d.ts +4 -4
  56. package/lib/asserts/boolean/index.js +14 -7
  57. package/lib/asserts/boolean/index.js.map +1 -1
  58. package/lib/asserts/boolean/index.mjs +14 -7
  59. package/lib/asserts/boolean/index.mjs.map +1 -1
  60. package/lib/asserts/date/dateMax.d.mts +22 -0
  61. package/lib/asserts/date/dateMax.d.ts +22 -0
  62. package/lib/asserts/date/dateMax.js +28 -0
  63. package/lib/asserts/date/dateMax.js.map +1 -0
  64. package/lib/asserts/date/dateMax.mjs +28 -0
  65. package/lib/asserts/date/dateMax.mjs.map +1 -0
  66. package/lib/asserts/date/dateMin.d.mts +22 -0
  67. package/lib/asserts/date/dateMin.d.ts +22 -0
  68. package/lib/asserts/date/dateMin.js +28 -0
  69. package/lib/asserts/date/dateMin.js.map +1 -0
  70. package/lib/asserts/date/dateMin.mjs +28 -0
  71. package/lib/asserts/date/dateMin.mjs.map +1 -0
  72. package/lib/asserts/date/index.d.mts +17 -0
  73. package/lib/asserts/date/index.d.ts +17 -0
  74. package/lib/asserts/date/index.js +18 -0
  75. package/lib/asserts/date/index.js.map +1 -0
  76. package/lib/asserts/date/index.mjs +18 -0
  77. package/lib/asserts/date/index.mjs.map +1 -0
  78. package/lib/asserts/mix/equalTo.d.mts +1 -1
  79. package/lib/asserts/mix/equalTo.d.ts +1 -1
  80. package/lib/asserts/mix/equalTo.js +4 -4
  81. package/lib/asserts/mix/equalTo.mjs +3 -3
  82. package/lib/asserts/mix/index.d.mts +4 -3
  83. package/lib/asserts/mix/index.d.ts +4 -3
  84. package/lib/asserts/mix/index.js +12 -5
  85. package/lib/asserts/mix/index.js.map +1 -1
  86. package/lib/asserts/mix/index.mjs +12 -5
  87. package/lib/asserts/mix/index.mjs.map +1 -1
  88. package/lib/asserts/mix/oneOfValues.d.mts +1 -1
  89. package/lib/asserts/mix/oneOfValues.d.ts +1 -1
  90. package/lib/asserts/mix/oneOfValues.js +4 -4
  91. package/lib/asserts/mix/oneOfValues.mjs +3 -3
  92. package/lib/asserts/number/index.d.mts +4 -4
  93. package/lib/asserts/number/index.d.ts +4 -4
  94. package/lib/asserts/number/index.js +16 -10
  95. package/lib/asserts/number/index.js.map +1 -1
  96. package/lib/asserts/number/index.mjs +16 -10
  97. package/lib/asserts/number/index.mjs.map +1 -1
  98. package/lib/asserts/number/max.js +4 -4
  99. package/lib/asserts/number/max.mjs +2 -2
  100. package/lib/asserts/number/maxExcluded.js +4 -4
  101. package/lib/asserts/number/maxExcluded.mjs +2 -2
  102. package/lib/asserts/number/min.js +4 -4
  103. package/lib/asserts/number/min.mjs +2 -2
  104. package/lib/asserts/number/minExcluded.js +4 -4
  105. package/lib/asserts/number/minExcluded.mjs +2 -2
  106. package/lib/asserts/number/negative.js +4 -4
  107. package/lib/asserts/number/negative.mjs +2 -2
  108. package/lib/asserts/number/positive.js +4 -4
  109. package/lib/asserts/number/positive.mjs +2 -2
  110. package/lib/asserts/object/index.d.mts +4 -4
  111. package/lib/asserts/object/index.d.ts +4 -4
  112. package/lib/asserts/object/index.js +13 -6
  113. package/lib/asserts/object/index.js.map +1 -1
  114. package/lib/asserts/object/index.mjs +13 -6
  115. package/lib/asserts/object/index.mjs.map +1 -1
  116. package/lib/asserts/string/atLeastOneDigit.js +4 -4
  117. package/lib/asserts/string/atLeastOneDigit.mjs +2 -2
  118. package/lib/asserts/string/atLeastOneLowerChar.js +4 -4
  119. package/lib/asserts/string/atLeastOneLowerChar.mjs +2 -2
  120. package/lib/asserts/string/atLeastOneSpecialChar.js +4 -4
  121. package/lib/asserts/string/atLeastOneSpecialChar.mjs +2 -2
  122. package/lib/asserts/string/atLeastOneUpperChar.js +4 -4
  123. package/lib/asserts/string/atLeastOneUpperChar.mjs +2 -2
  124. package/lib/asserts/string/contains.js +4 -4
  125. package/lib/asserts/string/contains.mjs +2 -2
  126. package/lib/asserts/string/email.js +4 -4
  127. package/lib/asserts/string/email.mjs +2 -2
  128. package/lib/asserts/string/endsWith.js +4 -4
  129. package/lib/asserts/string/endsWith.mjs +2 -2
  130. package/lib/asserts/string/index.d.mts +4 -4
  131. package/lib/asserts/string/index.d.ts +4 -4
  132. package/lib/asserts/string/index.js +16 -10
  133. package/lib/asserts/string/index.js.map +1 -1
  134. package/lib/asserts/string/index.mjs +16 -10
  135. package/lib/asserts/string/index.mjs.map +1 -1
  136. package/lib/asserts/string/isValidDate.d.mts +21 -0
  137. package/lib/asserts/string/isValidDate.d.ts +21 -0
  138. package/lib/asserts/string/isValidDate.js +25 -0
  139. package/lib/asserts/string/isValidDate.js.map +1 -0
  140. package/lib/asserts/string/isValidDate.mjs +25 -0
  141. package/lib/asserts/string/isValidDate.mjs.map +1 -0
  142. package/lib/asserts/string/isValidDateTime.d.mts +35 -0
  143. package/lib/asserts/string/isValidDateTime.d.ts +35 -0
  144. package/lib/asserts/string/isValidDateTime.js +32 -0
  145. package/lib/asserts/string/isValidDateTime.js.map +1 -0
  146. package/lib/asserts/string/isValidDateTime.mjs +32 -0
  147. package/lib/asserts/string/isValidDateTime.mjs.map +1 -0
  148. package/lib/asserts/string/isValidTime.d.mts +29 -0
  149. package/lib/asserts/string/isValidTime.d.ts +29 -0
  150. package/lib/asserts/string/isValidTime.js +32 -0
  151. package/lib/asserts/string/isValidTime.js.map +1 -0
  152. package/lib/asserts/string/isValidTime.mjs +32 -0
  153. package/lib/asserts/string/isValidTime.mjs.map +1 -0
  154. package/lib/asserts/string/lowerCase.js +4 -4
  155. package/lib/asserts/string/lowerCase.mjs +2 -2
  156. package/lib/asserts/string/maxLength.js +4 -4
  157. package/lib/asserts/string/maxLength.mjs +2 -2
  158. package/lib/asserts/string/minLength.js +4 -4
  159. package/lib/asserts/string/minLength.mjs +2 -2
  160. package/lib/asserts/string/regExp.js +4 -4
  161. package/lib/asserts/string/regExp.mjs +2 -2
  162. package/lib/asserts/string/startsWith.js +4 -4
  163. package/lib/asserts/string/startsWith.mjs +2 -2
  164. package/lib/asserts/string/upperCase.js +4 -4
  165. package/lib/asserts/string/upperCase.mjs +2 -2
  166. package/lib/asserts/string/uuid.js +4 -4
  167. package/lib/asserts/string/uuid.mjs +2 -2
  168. package/lib/asserts/string/uuidV1.js +4 -4
  169. package/lib/asserts/string/uuidV1.mjs +2 -2
  170. package/lib/asserts/string/uuidV2.js +4 -4
  171. package/lib/asserts/string/uuidV2.mjs +2 -2
  172. package/lib/asserts/string/uuidV3.js +4 -4
  173. package/lib/asserts/string/uuidV3.mjs +2 -2
  174. package/lib/asserts/string/uuidV4.js +4 -4
  175. package/lib/asserts/string/uuidV4.mjs +2 -2
  176. package/lib/asserts/string/uuidV5.js +4 -4
  177. package/lib/asserts/string/uuidV5.mjs +2 -2
  178. package/lib/asserts/string/validUrl.js +4 -4
  179. package/lib/asserts/string/validUrl.mjs +2 -2
  180. package/lib/{chunk-LEQCDD66.js → chunk-2D5QE7F4.js} +17 -15
  181. package/lib/chunk-2D5QE7F4.js.map +1 -0
  182. package/lib/chunk-2MFBOVP2.mjs +20 -0
  183. package/lib/chunk-2MFBOVP2.mjs.map +1 -0
  184. package/lib/chunk-3IOQH3K4.js +74 -0
  185. package/lib/chunk-3IOQH3K4.js.map +1 -0
  186. package/lib/chunk-3ZPLJ5KC.js +14 -0
  187. package/lib/{chunk-JSGZ7DKT.js.map → chunk-3ZPLJ5KC.js.map} +1 -1
  188. package/lib/{chunk-3HTYHE2X.mjs → chunk-4GDBM5LP.mjs} +4 -3
  189. package/lib/chunk-4GDBM5LP.mjs.map +1 -0
  190. package/lib/{chunk-TCQY2R3U.mjs → chunk-5HT3PYSG.mjs} +4 -4
  191. package/lib/chunk-5HT3PYSG.mjs.map +1 -0
  192. package/lib/{chunk-PH2PMUZP.mjs → chunk-5LLJ22IG.mjs} +28 -14
  193. package/lib/chunk-5LLJ22IG.mjs.map +1 -0
  194. package/lib/{chunk-PG2R7P7G.mjs → chunk-ADSMWGDJ.mjs} +4 -4
  195. package/lib/{chunk-H7CPKW53.js → chunk-AN3VHQEQ.js} +7 -7
  196. package/lib/{chunk-H7CPKW53.js.map → chunk-AN3VHQEQ.js.map} +1 -1
  197. package/lib/chunk-AOUFWACR.mjs +74 -0
  198. package/lib/chunk-AOUFWACR.mjs.map +1 -0
  199. package/lib/{chunk-WK4O3HH4.js → chunk-AY7HKAG2.js} +2 -3
  200. package/lib/chunk-AY7HKAG2.js.map +1 -0
  201. package/lib/{chunk-NNFYXHLU.mjs → chunk-BUXOCPHI.mjs} +3 -3
  202. package/lib/chunk-BUXOCPHI.mjs.map +1 -0
  203. package/lib/{chunk-RYVUYVEE.mjs → chunk-D42ISCFK.mjs} +2 -2
  204. package/lib/{chunk-KQKJASVB.js → chunk-EU3ZZF7Y.js} +13 -13
  205. package/lib/chunk-EU3ZZF7Y.js.map +1 -0
  206. package/lib/{chunk-NDQM5OL4.mjs → chunk-KBZUNXJB.mjs} +4 -4
  207. package/lib/chunk-KBZUNXJB.mjs.map +1 -0
  208. package/lib/chunk-LYNVPN3R.js +28 -0
  209. package/lib/chunk-LYNVPN3R.js.map +1 -0
  210. package/lib/{chunk-7XFLH6R2.mjs → chunk-NP64RC7B.mjs} +2 -3
  211. package/lib/chunk-NP64RC7B.mjs.map +1 -0
  212. package/lib/{chunk-3O4WCRC2.mjs → chunk-OHEMRF7Y.mjs} +3 -3
  213. package/lib/chunk-OHEMRF7Y.mjs.map +1 -0
  214. package/lib/chunk-OJSTQQ3N.js +20 -0
  215. package/lib/chunk-OJSTQQ3N.js.map +1 -0
  216. package/lib/{chunk-YUESB2WV.mjs → chunk-OKF3BVUD.mjs} +4 -4
  217. package/lib/{chunk-6TH3DBDK.js → chunk-OO6BTBVP.js} +11 -11
  218. package/lib/chunk-OO6BTBVP.js.map +1 -0
  219. package/lib/chunk-P6V6S6TZ.js +65 -0
  220. package/lib/chunk-P6V6S6TZ.js.map +1 -0
  221. package/lib/{chunk-DJSLA2ZV.js → chunk-PESVL5YJ.js} +7 -7
  222. package/lib/{chunk-DJSLA2ZV.js.map → chunk-PESVL5YJ.js.map} +1 -1
  223. package/lib/{chunk-IRG4OQAB.js → chunk-PIBDJJUU.js} +35 -21
  224. package/lib/chunk-PIBDJJUU.js.map +1 -0
  225. package/lib/{chunk-J4VKFJQK.js → chunk-SPWF5IFU.js} +5 -5
  226. package/lib/chunk-SPWF5IFU.js.map +1 -0
  227. package/lib/{chunk-P7IXNCJG.mjs → chunk-TQWUSDQD.mjs} +6 -6
  228. package/lib/chunk-TQWUSDQD.mjs.map +1 -0
  229. package/lib/{chunk-5BVJ6YMH.js → chunk-UZ2PWO4O.js} +6 -5
  230. package/lib/chunk-UZ2PWO4O.js.map +1 -0
  231. package/lib/chunk-VBTWYDEM.js +12 -0
  232. package/lib/chunk-VBTWYDEM.js.map +1 -0
  233. package/lib/{chunk-4CYIMDP2.js → chunk-W2GOLG3K.js} +5 -5
  234. package/lib/chunk-W2GOLG3K.js.map +1 -0
  235. package/lib/chunk-YBVMP4EI.mjs +12 -0
  236. package/lib/chunk-YBVMP4EI.mjs.map +1 -0
  237. package/lib/{chunk-CCBCDJXS.mjs → chunk-YPAFWVDL.mjs} +4 -4
  238. package/lib/chunk-YPAFWVDL.mjs.map +1 -0
  239. package/lib/chunk-ZMEQCIRN.mjs +65 -0
  240. package/lib/chunk-ZMEQCIRN.mjs.map +1 -0
  241. package/lib/{chunk-WBERBAL4.js → chunk-ZVW3IHBW.js} +8 -8
  242. package/lib/chunk-ZVW3IHBW.js.map +1 -0
  243. package/lib/{chunk-JPRCULRQ.mjs → chunk-ZWE5Q37U.mjs} +12 -10
  244. package/lib/chunk-ZWE5Q37U.mjs.map +1 -0
  245. package/lib/codeGen.d.mts +1 -1
  246. package/lib/codeGen.d.ts +1 -1
  247. package/lib/codeGen.js +5 -3
  248. package/lib/codeGen.js.map +1 -1
  249. package/lib/codeGen.mjs +4 -2
  250. package/lib/codeGen.mjs.map +1 -1
  251. package/lib/commonTypes.d.mts +1 -0
  252. package/lib/commonTypes.d.ts +1 -0
  253. package/lib/exceptions.js +2 -2
  254. package/lib/exceptions.mjs +1 -1
  255. package/lib/helpers/core.d.mts +1 -1
  256. package/lib/helpers/core.d.ts +1 -1
  257. package/lib/helpers/core.js +4 -3
  258. package/lib/helpers/core.js.map +1 -1
  259. package/lib/helpers/core.mjs +3 -2
  260. package/lib/helpers/isValidDateInner.d.mts +3 -0
  261. package/lib/helpers/isValidDateInner.d.ts +3 -0
  262. package/lib/helpers/isValidDateInner.js +7 -0
  263. package/lib/helpers/isValidDateInner.js.map +1 -0
  264. package/lib/helpers/isValidDateInner.mjs +7 -0
  265. package/lib/helpers/isValidDateInner.mjs.map +1 -0
  266. package/lib/helpers/setStrictType.d.mts +1 -1
  267. package/lib/helpers/setStrictType.d.ts +1 -1
  268. package/lib/helpers/setStrictType.js +5 -4
  269. package/lib/helpers/setStrictType.js.map +1 -1
  270. package/lib/helpers/setStrictType.mjs +4 -3
  271. package/lib/index.d.mts +3 -7
  272. package/lib/index.d.ts +3 -7
  273. package/lib/index.js +7 -40
  274. package/lib/index.js.map +1 -1
  275. package/lib/index.mjs +7 -40
  276. package/lib/parse.d.mts +3 -1
  277. package/lib/parse.d.ts +3 -1
  278. package/lib/parse.js +6 -5
  279. package/lib/parse.js.map +1 -1
  280. package/lib/parse.mjs +5 -4
  281. package/lib/parseOrFail.d.mts +3 -1
  282. package/lib/parseOrFail.d.ts +3 -1
  283. package/lib/parseOrFail.js +6 -5
  284. package/lib/parseOrFail.js.map +1 -1
  285. package/lib/parseOrFail.mjs +5 -4
  286. package/lib/schemas/ArraySchema.d.mts +2 -2
  287. package/lib/schemas/ArraySchema.d.ts +2 -2
  288. package/lib/schemas/ArraySchema.js +8 -5
  289. package/lib/schemas/ArraySchema.js.map +1 -1
  290. package/lib/schemas/ArraySchema.mjs +7 -4
  291. package/lib/schemas/BigIntSchema.d.mts +33 -0
  292. package/lib/schemas/BigIntSchema.d.ts +33 -0
  293. package/lib/schemas/BigIntSchema.js +17 -0
  294. package/lib/schemas/BigIntSchema.js.map +1 -0
  295. package/lib/schemas/BigIntSchema.mjs +17 -0
  296. package/lib/schemas/BigIntSchema.mjs.map +1 -0
  297. package/lib/schemas/BooleanSchema.d.mts +2 -2
  298. package/lib/schemas/BooleanSchema.d.ts +2 -2
  299. package/lib/schemas/BooleanSchema.js +9 -6
  300. package/lib/schemas/BooleanSchema.js.map +1 -1
  301. package/lib/schemas/BooleanSchema.mjs +8 -5
  302. package/lib/schemas/CommonSchema.d.mts +1 -1
  303. package/lib/schemas/CommonSchema.d.ts +1 -1
  304. package/lib/schemas/CommonSchema.js +7 -4
  305. package/lib/schemas/CommonSchema.js.map +1 -1
  306. package/lib/schemas/CommonSchema.mjs +6 -3
  307. package/lib/schemas/DateSchema.d.mts +9 -0
  308. package/lib/schemas/DateSchema.d.ts +9 -0
  309. package/lib/schemas/DateSchema.js +13 -0
  310. package/lib/schemas/DateSchema.js.map +1 -0
  311. package/lib/schemas/DateSchema.mjs +13 -0
  312. package/lib/schemas/DateSchema.mjs.map +1 -0
  313. package/lib/schemas/NumberSchema.d.mts +2 -2
  314. package/lib/schemas/NumberSchema.d.ts +2 -2
  315. package/lib/schemas/NumberSchema.js +11 -9
  316. package/lib/schemas/NumberSchema.js.map +1 -1
  317. package/lib/schemas/NumberSchema.mjs +10 -8
  318. package/lib/schemas/ObjectSchema.d.mts +2 -2
  319. package/lib/schemas/ObjectSchema.d.ts +2 -2
  320. package/lib/schemas/ObjectSchema.js +8 -5
  321. package/lib/schemas/ObjectSchema.js.map +1 -1
  322. package/lib/schemas/ObjectSchema.mjs +7 -4
  323. package/lib/schemas/StringSchema.d.mts +3 -2
  324. package/lib/schemas/StringSchema.d.ts +3 -2
  325. package/lib/schemas/StringSchema.js +11 -9
  326. package/lib/schemas/StringSchema.js.map +1 -1
  327. package/lib/schemas/StringSchema.mjs +10 -8
  328. package/lib/translationMap.js +3 -3
  329. package/lib/translationMap.mjs +2 -2
  330. package/package.json +6 -1
  331. package/lib/chunk-2PM3K3OE.mjs +0 -13
  332. package/lib/chunk-2PM3K3OE.mjs.map +0 -1
  333. package/lib/chunk-32RSTOZ4.mjs +0 -13
  334. package/lib/chunk-32RSTOZ4.mjs.map +0 -1
  335. package/lib/chunk-3HTYHE2X.mjs.map +0 -1
  336. package/lib/chunk-3O4WCRC2.mjs.map +0 -1
  337. package/lib/chunk-4CYIMDP2.js.map +0 -1
  338. package/lib/chunk-5BVJ6YMH.js.map +0 -1
  339. package/lib/chunk-6TH3DBDK.js.map +0 -1
  340. package/lib/chunk-7XFLH6R2.mjs.map +0 -1
  341. package/lib/chunk-CCBCDJXS.mjs.map +0 -1
  342. package/lib/chunk-DPBE7TAQ.mjs +0 -42
  343. package/lib/chunk-DPBE7TAQ.mjs.map +0 -1
  344. package/lib/chunk-EGEHSELT.js +0 -42
  345. package/lib/chunk-EGEHSELT.js.map +0 -1
  346. package/lib/chunk-HDSGCAHH.js +0 -13
  347. package/lib/chunk-HDSGCAHH.js.map +0 -1
  348. package/lib/chunk-IEUXIOL6.js +0 -13
  349. package/lib/chunk-IEUXIOL6.js.map +0 -1
  350. package/lib/chunk-IRG4OQAB.js.map +0 -1
  351. package/lib/chunk-J4VKFJQK.js.map +0 -1
  352. package/lib/chunk-JDGZCBXF.mjs +0 -13
  353. package/lib/chunk-JDGZCBXF.mjs.map +0 -1
  354. package/lib/chunk-JPRCULRQ.mjs.map +0 -1
  355. package/lib/chunk-JSGZ7DKT.js +0 -14
  356. package/lib/chunk-KQKJASVB.js.map +0 -1
  357. package/lib/chunk-LEQCDD66.js.map +0 -1
  358. package/lib/chunk-MRISXZQ4.mjs +0 -13
  359. package/lib/chunk-MRISXZQ4.mjs.map +0 -1
  360. package/lib/chunk-NDQM5OL4.mjs.map +0 -1
  361. package/lib/chunk-NNFYXHLU.mjs.map +0 -1
  362. package/lib/chunk-P7IXNCJG.mjs.map +0 -1
  363. package/lib/chunk-PH2PMUZP.mjs.map +0 -1
  364. package/lib/chunk-PXBAS3GA.mjs +0 -13
  365. package/lib/chunk-PXBAS3GA.mjs.map +0 -1
  366. package/lib/chunk-QQNQ4IDN.js +0 -13
  367. package/lib/chunk-QQNQ4IDN.js.map +0 -1
  368. package/lib/chunk-RD6TBCPQ.js +0 -13
  369. package/lib/chunk-RD6TBCPQ.js.map +0 -1
  370. package/lib/chunk-RRQOET3X.js +0 -28
  371. package/lib/chunk-RRQOET3X.js.map +0 -1
  372. package/lib/chunk-TCQY2R3U.mjs.map +0 -1
  373. package/lib/chunk-TKZ6FLLR.js +0 -13
  374. package/lib/chunk-TKZ6FLLR.js.map +0 -1
  375. package/lib/chunk-VHEA4JZ5.js +0 -13
  376. package/lib/chunk-VHEA4JZ5.js.map +0 -1
  377. package/lib/chunk-WBERBAL4.js.map +0 -1
  378. package/lib/chunk-WK4O3HH4.js.map +0 -1
  379. package/lib/chunk-YML32TPA.mjs +0 -13
  380. package/lib/chunk-YML32TPA.mjs.map +0 -1
  381. /package/lib/{chunk-PG2R7P7G.mjs.map → chunk-ADSMWGDJ.mjs.map} +0 -0
  382. /package/lib/{chunk-RYVUYVEE.mjs.map → chunk-D42ISCFK.mjs.map} +0 -0
  383. /package/lib/{chunk-YUESB2WV.mjs.map → chunk-OKF3BVUD.mjs.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-OO6BTBVP.js","../src/schemas/ObjectSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBACnC,QAAA,EAAU,EAAA;AAAA,EACpB,WAAA,CAAY,GAAA,EAAuB,WAAA,EAAoC;AACrE,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,mBAAA,CAAoB,WAAW,CAAA;AACpC,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,OAAA,EAAS,WAAA;AAAA,EAC3B;AAAA,EAEQ,mBAAA,CAAoB,WAAA,EAAoC;AAC9D,IAAA,GAAA,CAAI,CAAC,WAAA,EAAa,MAAM,IAAI,sCAAA,CAAiB,iCAAiC,CAAA;AAC9E,IAAA,GAAA,CAAI,YAAA,WAAuB,6BAAA,EAAc,MAAM,IAAI,sCAAA,CAAiB,0BAA0B,CAAA;AAC9F,IAAA,IAAA,CAAA,MAAW,CAAC,GAAA,EAAK,KAAK,EAAA,GAAK,MAAA,CAAO,OAAA,CAAQ,WAAW,CAAA,EAAG;AACtD,MAAA,GAAA,CAAI,CAAA,CAAE,MAAA,WAAiB,6BAAA,CAAA;AACrB,QAAA,MAAM,IAAI,sCAAA,CAAiB,CAAA,8CAAA,EAAiD,GAAG,CAAA,CAAA,CAAG,CAAA;AAAA,IACtF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBO,iBAAA,CAAA,EAA0B;AAC/B,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,6BAAA,EAA+B,IAAA;AAC/C,IAAA,OAAO,IAAA;AAAA,EACT;AACF,UAAA;ADMA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-OO6BTBVP.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ObjectShapeSchemaType, ValidatorContext } from './CommonSchema';\n\nexport class ObjectSchema extends CommonSchema {\n protected _object = 1;\n constructor(ctx: ValidatorContext, shapeSchema: ObjectShapeSchemaType) {\n super(ctx);\n this.validateObjectEntry(shapeSchema);\n this[ctxSymbol].object = shapeSchema;\n }\n\n private validateObjectEntry(shapeSchema: ObjectShapeSchemaType) {\n if (!shapeSchema) throw new BuildSchemaError('Missing schema in object method');\n if (shapeSchema instanceof CommonSchema) throw new BuildSchemaError('Invalid schema in object');\n for (const [key, value] of Object.entries(shapeSchema)) {\n if (!(value instanceof CommonSchema))\n throw new BuildSchemaError(`Invalid schema in object method for property '${key}'`);\n }\n }\n\n /**\n * Allows unrecognized properties in the validated object.\n * When this method is called, the validation will not fail\n * if the received object contains properties not specified\n * in the validation schema.\n *\n * @returns {this} The current ObjectSchema instance.\n *\n * @example\n * const userSchema = object({\n * name: string(),\n * age: number(),\n * }).allowUnrecognized();\n *\n * parseOrFail(userSchema, ({ name: 'John', age: 30, extra: 'value' }););\n * // No error thrown\n */\n public allowUnrecognized(): this {\n this[ctxSymbol].allowUnrecognizedObjectProps = true;\n return this;\n }\n}\n\nexport type WithObject<Y extends ObjectShapeSchemaType> = ObjectSchema & { validation_object: Y };\n"]}
@@ -0,0 +1,65 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
+
3
+ var _chunkSPWF5IFUjs = require('./chunk-SPWF5IFU.js');
4
+
5
+
6
+ var _chunkW2GOLG3Kjs = require('./chunk-W2GOLG3K.js');
7
+
8
+
9
+ var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
10
+
11
+
12
+ var _chunk3ZPLJ5KCjs = require('./chunk-3ZPLJ5KC.js');
13
+
14
+
15
+ var _chunk3IOQH3K4js = require('./chunk-3IOQH3K4.js');
16
+
17
+
18
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
19
+
20
+ // src/schemas/BigIntSchema.ts
21
+ var BigIntSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
22
+ __init() {this._bigint = 1}
23
+
24
+ /**
25
+ * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
26
+ *
27
+ * @param expectedValue - The value that the schema must exactly match.
28
+ * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type
29
+ *
30
+ * @example - bigint().equalTo(42n); // Infers the type 42n
31
+ */
32
+ equalTo(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
+ }
38
+ /**
39
+ * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
40
+ *
41
+ * @param expectedValues - An array of values that the schema can match.
42
+ * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.
43
+ *
44
+ * @example
45
+ * bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n
46
+ */
47
+ oneOfValues(expectedValue) {
48
+ this.defaultValueCheck();
49
+ this.limitCheck();
50
+ _chunk3ZPLJ5KCjs._setStrictType.call(void 0,
51
+ this,
52
+ expectedValue.map((el) => `${el}n`)
53
+ );
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;
59
+ }
60
+ }, _class);
61
+
62
+
63
+
64
+ exports.BigIntSchema = BigIntSchema;
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 _chunkIRG4OQABjs = require('./chunk-IRG4OQAB.js');
3
+ var _chunkPIBDJJUUjs = require('./chunk-PIBDJJUU.js');
4
4
 
5
5
 
6
- var _chunk5BVJ6YMHjs = require('./chunk-5BVJ6YMH.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 _chunkIRG4OQABjs.innerCheck.call(void 0, schema, receivedValue, {
15
- t: _chunk5BVJ6YMHjs.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-DJSLA2ZV.js.map
27
+ //# sourceMappingURL=chunk-PESVL5YJ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-DJSLA2ZV.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-DJSLA2ZV.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,6 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
3
+ var _chunkVBTWYDEMjs = require('./chunk-VBTWYDEM.js');
4
+
5
+
6
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
4
7
 
5
8
  // src/helpers/core.ts
6
9
  var ctxSymbol = Symbol("contextSymbol");
@@ -8,31 +11,45 @@ function innerCheck(schema, receivedValue, exCtx) {
8
11
  const commonTmap = exCtx.t;
9
12
  const schemaData = schema[ctxSymbol];
10
13
  if (receivedValue === void 0) {
11
- 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"]);
12
16
  return receivedValue;
13
17
  }
14
18
  if (receivedValue === null) {
15
- 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"]);
16
20
  return receivedValue;
17
21
  }
22
+ if (schemaData.date) {
23
+ if (!_chunkVBTWYDEMjs.isValidDateInner.call(void 0, receivedValue)) _chunkAY7HKAG2js.guardException.call(void 0, "Date", receivedValue, exCtx, commonTmap["c:date"]);
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
+ });
18
33
  if (schemaData.array) {
19
- 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"]);
20
35
  const schema2 = schemaData.array;
21
36
  const pathToError = exCtx.pathToError;
37
+ const parsedReceivedValue = [];
22
38
  receivedValue.forEach((elem, i) => {
23
- innerCheck(schema2, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });
39
+ const parsedElement = innerCheck(schema2, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });
40
+ parsedReceivedValue.push(parsedElement);
24
41
  });
25
- return receivedValue;
42
+ return parsedReceivedValue;
26
43
  }
27
- const typeOfVal = typeof receivedValue;
28
44
  if (schemaData.object) {
29
- if (typeOfVal !== "object") _chunkWK4O3HH4js.guardException.call(void 0, "Object", receivedValue, exCtx, commonTmap["c:objectType"]);
30
- 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"]);
31
47
  const shapeSchema = schemaData.object;
48
+ const parsedReceivedValue = {};
32
49
  if (!schemaData.allowUnrecognizedObjectProps) {
33
50
  for (const keyPerReceivedValue of Object.keys(receivedValue)) {
34
51
  if (shapeSchema[keyPerReceivedValue] === void 0)
35
- _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"]);
36
53
  }
37
54
  }
38
55
  const pathToError = exCtx.pathToError;
@@ -40,19 +57,16 @@ function innerCheck(schema, receivedValue, exCtx) {
40
57
  const receivedObjectValuePropery = receivedValue[keyOfSchema];
41
58
  if (receivedObjectValuePropery === void 0) {
42
59
  if (!valueOfSchema[ctxSymbol].isOptional)
43
- _chunkWK4O3HH4js.guardException.call(void 0, "Required", receivedObjectValuePropery, exCtx, commonTmap["c:requiredProperty"]);
60
+ _chunkAY7HKAG2js.guardException.call(void 0, "Required", receivedObjectValuePropery, exCtx, commonTmap["c:requiredProperty"]);
44
61
  }
45
- innerCheck(valueOfSchema, receivedObjectValuePropery, { ...exCtx, pathToError: `${pathToError}.${keyOfSchema}` });
62
+ const parsedReceivedObjectValuePropery = innerCheck(valueOfSchema, receivedObjectValuePropery, {
63
+ ...exCtx,
64
+ pathToError: `${pathToError}.${keyOfSchema}`
65
+ });
66
+ parsedReceivedValue[keyOfSchema] = parsedReceivedObjectValuePropery;
46
67
  }
47
- return receivedValue;
68
+ return parsedReceivedValue;
48
69
  }
49
- if (schemaData.type.length) {
50
- if (!schemaData.type.includes(typeOfVal))
51
- _chunkWK4O3HH4js.guardException.call(void 0, schemaData.type, typeOfVal, exCtx, commonTmap["c:invalidType"]);
52
- }
53
- schemaData.requiredValidations.forEach((requiredValidation) => {
54
- requiredValidation(receivedValue, exCtx);
55
- });
56
70
  return receivedValue;
57
71
  }
58
72
 
@@ -60,4 +74,4 @@ function innerCheck(schema, receivedValue, exCtx) {
60
74
 
61
75
 
62
76
  exports.ctxSymbol = ctxSymbol; exports.innerCheck = innerCheck;
63
- //# sourceMappingURL=chunk-IRG4OQAB.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 _chunk5BVJ6YMHjs = require('./chunk-5BVJ6YMH.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
- _chunk5BVJ6YMHjs.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-J4VKFJQK.js.map
21
+ //# sourceMappingURL=chunk-SPWF5IFU.js.map
@@ -0,0 +1 @@
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
1
  import {
2
2
  equalTo
3
- } from "./chunk-NNFYXHLU.mjs";
3
+ } from "./chunk-BUXOCPHI.mjs";
4
4
  import {
5
5
  oneOfValues
6
- } from "./chunk-3O4WCRC2.mjs";
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-RYVUYVEE.mjs";
12
+ } from "./chunk-D42ISCFK.mjs";
13
13
  import {
14
14
  CommonSchema
15
- } from "./chunk-DPBE7TAQ.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-P7IXNCJG.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 = {
@@ -13,7 +13,8 @@ var defaultErrorMap = {
13
13
  "c:unrecognizedProperty": "This property is not allowed in the object",
14
14
  "c:requiredProperty": "Missing required property in the object",
15
15
  "c:invalidType": "Invalid type of data",
16
- "c:isBoolean": "The received value is not {{e}}"
16
+ "c:isBoolean": "The received value is not {{e}}",
17
+ "c:date": "The received value is not a valid instance of Date"
17
18
  //@@end
18
19
  };
19
20
  var data = {
@@ -24,11 +25,11 @@ function setToDefaultLocale({
24
25
  message
25
26
  }) {
26
27
  const defaultLocale = data.default;
27
- 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");
28
29
  defaultLocale[key] = message;
29
30
  }
30
31
  function setLocale(lng, custom) {
31
- if (lng === "default") throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Invalid language");
32
+ if (lng === "default") throw new (0, _chunkAY7HKAG2js.BuildSchemaError)("Invalid language");
32
33
  if (!data[lng]) data[lng] = { ...defaultErrorMap };
33
34
  const locale = data[lng];
34
35
  Object.entries(custom).forEach(([messageKey, messageValue]) => {
@@ -51,4 +52,4 @@ function getTranslationByLocale(lng) {
51
52
 
52
53
 
53
54
  exports.setToDefaultLocale = setToDefaultLocale; exports.setLocale = setLocale; exports.clearLocales = clearLocales; exports.getTranslationByLocale = getTranslationByLocale;
54
- //# sourceMappingURL=chunk-5BVJ6YMH.js.map
55
+ //# sourceMappingURL=chunk-UZ2PWO4O.js.map
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,12 @@
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
+ return (
4
+ // @ts-expect-error we expect d to have getTime method
5
+ Object.prototype.toString.call(d) === "[object Date]" && !isNaN(typeof _optionalChain([d, 'optionalAccess', _ => _.getTime]) === "function" && d.getTime())
6
+ );
7
+ }
8
+
9
+
10
+
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 _chunk5BVJ6YMHjs = require('./chunk-5BVJ6YMH.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
- _chunk5BVJ6YMHjs.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-4CYIMDP2.js.map
21
+ //# sourceMappingURL=chunk-W2GOLG3K.js.map
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,12 @@
1
+ // src/helpers/isValidDateInner.ts
2
+ function isValidDateInner(d) {
3
+ return (
4
+ // @ts-expect-error we expect d to have getTime method
5
+ Object.prototype.toString.call(d) === "[object Date]" && !isNaN(typeof d?.getTime === "function" && d.getTime())
6
+ );
7
+ }
8
+
9
+ export {
10
+ isValidDateInner
11
+ };
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-RYVUYVEE.mjs";
3
+ } from "./chunk-D42ISCFK.mjs";
4
4
  import {
5
5
  CommonSchema
6
- } from "./chunk-DPBE7TAQ.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-CCBCDJXS.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":[]}
@@ -0,0 +1,65 @@
1
+ import {
2
+ equalTo
3
+ } from "./chunk-BUXOCPHI.mjs";
4
+ import {
5
+ oneOfValues
6
+ } from "./chunk-OHEMRF7Y.mjs";
7
+ import {
8
+ ONLY_ONCE
9
+ } from "./chunk-ASZW6XRM.mjs";
10
+ import {
11
+ _setStrictType
12
+ } from "./chunk-D42ISCFK.mjs";
13
+ import {
14
+ CommonSchema
15
+ } from "./chunk-AOUFWACR.mjs";
16
+ import {
17
+ BuildSchemaError
18
+ } from "./chunk-NP64RC7B.mjs";
19
+
20
+ // src/schemas/BigIntSchema.ts
21
+ var BigIntSchema = class extends CommonSchema {
22
+ _bigint = 1;
23
+ limit;
24
+ /**
25
+ * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.
26
+ *
27
+ * @param expectedValue - The value that the schema must exactly match.
28
+ * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type
29
+ *
30
+ * @example - bigint().equalTo(42n); // Infers the type 42n
31
+ */
32
+ equalTo(expectedValue) {
33
+ this.defaultValueCheck();
34
+ this.limitCheck();
35
+ _setStrictType(this, `${expectedValue}n`);
36
+ return this.custom(equalTo(expectedValue));
37
+ }
38
+ /**
39
+ * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
40
+ *
41
+ * @param expectedValues - An array of values that the schema can match.
42
+ * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.
43
+ *
44
+ * @example
45
+ * bigint().oneOfValues([5n, 7n]); // Infers the type 5n | 7n
46
+ */
47
+ oneOfValues(expectedValue) {
48
+ this.defaultValueCheck();
49
+ this.limitCheck();
50
+ _setStrictType(
51
+ this,
52
+ expectedValue.map((el) => `${el}n`)
53
+ );
54
+ return this.custom(oneOfValues(expectedValue));
55
+ }
56
+ limitCheck() {
57
+ if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
58
+ this.limit = true;
59
+ }
60
+ };
61
+
62
+ export {
63
+ BigIntSchema
64
+ };
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":[]}
@@ -1,18 +1,18 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
2
 
3
- var _chunkJSGZ7DKTjs = require('./chunk-JSGZ7DKT.js');
3
+ var _chunk3ZPLJ5KCjs = require('./chunk-3ZPLJ5KC.js');
4
4
 
5
5
 
6
- var _chunkEGEHSELTjs = require('./chunk-EGEHSELT.js');
6
+ var _chunk3IOQH3K4js = require('./chunk-3IOQH3K4.js');
7
7
 
8
8
 
9
- var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
9
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
10
10
 
11
11
  // src/schemas/BooleanSchema.ts
12
12
  var isBoolean = (expected) => (received, ctx) => {
13
- if (received !== expected) _chunkWK4O3HH4js.guardException.call(void 0, expected, received, ctx, "c:isBoolean");
13
+ if (received !== expected) _chunkAY7HKAG2js.guardException.call(void 0, expected, received, ctx, "c:isBoolean");
14
14
  };
15
- var BooleanSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
15
+ var BooleanSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
16
16
  __init() {this._boolean = 1}
17
17
  /**
18
18
  * Restricts the schema to exactly match the boolean value true and infers the true value as the TypeScript type.
@@ -22,7 +22,7 @@ var BooleanSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {const
22
22
  * @example - boolean().onlyTrue(); // Infers the type true
23
23
  */
24
24
  onlyTrue() {
25
- _chunkJSGZ7DKTjs._setStrictType.call(void 0, this, true);
25
+ _chunk3ZPLJ5KCjs._setStrictType.call(void 0, this, true);
26
26
  return this.custom(isBoolean(true));
27
27
  }
28
28
  /**
@@ -33,7 +33,7 @@ var BooleanSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {const
33
33
  * @example - boolean().onlyFalse(); // Infers the type false
34
34
  */
35
35
  onlyFalse() {
36
- _chunkJSGZ7DKTjs._setStrictType.call(void 0, this, false);
36
+ _chunk3ZPLJ5KCjs._setStrictType.call(void 0, this, false);
37
37
  return this.custom(isBoolean(false));
38
38
  }
39
39
  }, _class);
@@ -41,4 +41,4 @@ var BooleanSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {const
41
41
 
42
42
 
43
43
  exports.BooleanSchema = BooleanSchema;
44
- //# sourceMappingURL=chunk-WBERBAL4.js.map
44
+ //# sourceMappingURL=chunk-ZVW3IHBW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-ZVW3IHBW.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,iBACpC,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASd,QAAA,CAAA,EAAoC;AACzC,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,EASO,SAAA,CAAA,EAAsC;AAC3C,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-ZVW3IHBW.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 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"]}