bguard 0.5.0 → 0.6.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 (651) hide show
  1. package/README.md +72 -2
  2. package/lib/InferType.d.mts +1 -1
  3. package/lib/InferType.d.ts +1 -1
  4. package/lib/asserts/array/index.d.mts +7 -3
  5. package/lib/asserts/array/index.d.ts +7 -3
  6. package/lib/asserts/array/index.js +5 -11
  7. package/lib/asserts/array/index.js.map +1 -1
  8. package/lib/asserts/array/index.mjs +5 -11
  9. package/lib/asserts/array/index.mjs.map +1 -1
  10. package/lib/asserts/array/maxArrayLength.d.mts +3 -1
  11. package/lib/asserts/array/maxArrayLength.d.ts +3 -1
  12. package/lib/asserts/array/maxArrayLength.js +3 -12
  13. package/lib/asserts/array/maxArrayLength.js.map +1 -1
  14. package/lib/asserts/array/maxArrayLength.mjs +3 -12
  15. package/lib/asserts/array/maxArrayLength.mjs.map +1 -1
  16. package/lib/asserts/array/minArrayLength.d.mts +3 -1
  17. package/lib/asserts/array/minArrayLength.d.ts +3 -1
  18. package/lib/asserts/array/minArrayLength.js +3 -12
  19. package/lib/asserts/array/minArrayLength.js.map +1 -1
  20. package/lib/asserts/array/minArrayLength.mjs +3 -12
  21. package/lib/asserts/array/minArrayLength.mjs.map +1 -1
  22. package/lib/asserts/bigint/bigintMax.d.mts +3 -1
  23. package/lib/asserts/bigint/bigintMax.d.ts +3 -1
  24. package/lib/asserts/bigint/bigintMax.js +3 -12
  25. package/lib/asserts/bigint/bigintMax.js.map +1 -1
  26. package/lib/asserts/bigint/bigintMax.mjs +3 -12
  27. package/lib/asserts/bigint/bigintMax.mjs.map +1 -1
  28. package/lib/asserts/bigint/bigintMaxExcluded.d.mts +3 -1
  29. package/lib/asserts/bigint/bigintMaxExcluded.d.ts +3 -1
  30. package/lib/asserts/bigint/bigintMaxExcluded.js +3 -12
  31. package/lib/asserts/bigint/bigintMaxExcluded.js.map +1 -1
  32. package/lib/asserts/bigint/bigintMaxExcluded.mjs +3 -12
  33. package/lib/asserts/bigint/bigintMaxExcluded.mjs.map +1 -1
  34. package/lib/asserts/bigint/bigintMin.d.mts +3 -1
  35. package/lib/asserts/bigint/bigintMin.d.ts +3 -1
  36. package/lib/asserts/bigint/bigintMin.js +3 -12
  37. package/lib/asserts/bigint/bigintMin.js.map +1 -1
  38. package/lib/asserts/bigint/bigintMin.mjs +3 -12
  39. package/lib/asserts/bigint/bigintMin.mjs.map +1 -1
  40. package/lib/asserts/bigint/bigintMinExcluded.d.mts +3 -1
  41. package/lib/asserts/bigint/bigintMinExcluded.d.ts +3 -1
  42. package/lib/asserts/bigint/bigintMinExcluded.js +3 -12
  43. package/lib/asserts/bigint/bigintMinExcluded.js.map +1 -1
  44. package/lib/asserts/bigint/bigintMinExcluded.mjs +3 -12
  45. package/lib/asserts/bigint/bigintMinExcluded.mjs.map +1 -1
  46. package/lib/asserts/bigint/index.d.mts +30 -4
  47. package/lib/asserts/bigint/index.d.ts +30 -4
  48. package/lib/asserts/bigint/index.js +8 -15
  49. package/lib/asserts/bigint/index.js.map +1 -1
  50. package/lib/asserts/bigint/index.mjs +8 -15
  51. package/lib/asserts/bigint/index.mjs.map +1 -1
  52. package/lib/asserts/boolean/index.d.mts +25 -3
  53. package/lib/asserts/boolean/index.d.ts +25 -3
  54. package/lib/asserts/boolean/index.js +6 -12
  55. package/lib/asserts/boolean/index.js.map +1 -1
  56. package/lib/asserts/boolean/index.mjs +6 -12
  57. package/lib/asserts/boolean/index.mjs.map +1 -1
  58. package/lib/asserts/date/dateMax.d.mts +3 -1
  59. package/lib/asserts/date/dateMax.d.ts +3 -1
  60. package/lib/asserts/date/dateMax.js +5 -22
  61. package/lib/asserts/date/dateMax.js.map +1 -1
  62. package/lib/asserts/date/dateMax.mjs +5 -22
  63. package/lib/asserts/date/dateMax.mjs.map +1 -1
  64. package/lib/asserts/date/dateMin.d.mts +3 -1
  65. package/lib/asserts/date/dateMin.d.ts +3 -1
  66. package/lib/asserts/date/dateMin.js +5 -22
  67. package/lib/asserts/date/dateMin.js.map +1 -1
  68. package/lib/asserts/date/dateMin.mjs +5 -22
  69. package/lib/asserts/date/dateMin.mjs.map +1 -1
  70. package/lib/asserts/date/index.d.mts +6 -3
  71. package/lib/asserts/date/index.d.ts +6 -3
  72. package/lib/asserts/date/index.js +5 -11
  73. package/lib/asserts/date/index.js.map +1 -1
  74. package/lib/asserts/date/index.mjs +5 -11
  75. package/lib/asserts/date/index.mjs.map +1 -1
  76. package/lib/asserts/mix/equalTo.d.mts +3 -1
  77. package/lib/asserts/mix/equalTo.d.ts +3 -1
  78. package/lib/asserts/mix/equalTo.js +3 -3
  79. package/lib/asserts/mix/equalTo.mjs +2 -2
  80. package/lib/asserts/mix/index.d.mts +3 -4
  81. package/lib/asserts/mix/index.d.ts +3 -4
  82. package/lib/asserts/mix/index.js +5 -10
  83. package/lib/asserts/mix/index.js.map +1 -1
  84. package/lib/asserts/mix/index.mjs +5 -10
  85. package/lib/asserts/mix/index.mjs.map +1 -1
  86. package/lib/asserts/mix/oneOfValues.d.mts +3 -1
  87. package/lib/asserts/mix/oneOfValues.d.ts +3 -1
  88. package/lib/asserts/mix/oneOfValues.js +3 -3
  89. package/lib/asserts/mix/oneOfValues.mjs +2 -2
  90. package/lib/asserts/number/index.d.mts +28 -3
  91. package/lib/asserts/number/index.d.ts +28 -3
  92. package/lib/asserts/number/index.js +8 -15
  93. package/lib/asserts/number/index.js.map +1 -1
  94. package/lib/asserts/number/index.mjs +8 -15
  95. package/lib/asserts/number/index.mjs.map +1 -1
  96. package/lib/asserts/number/max.d.mts +3 -1
  97. package/lib/asserts/number/max.d.ts +3 -1
  98. package/lib/asserts/number/max.js +3 -12
  99. package/lib/asserts/number/max.js.map +1 -1
  100. package/lib/asserts/number/max.mjs +3 -12
  101. package/lib/asserts/number/max.mjs.map +1 -1
  102. package/lib/asserts/number/maxExcluded.d.mts +3 -1
  103. package/lib/asserts/number/maxExcluded.d.ts +3 -1
  104. package/lib/asserts/number/maxExcluded.js +3 -12
  105. package/lib/asserts/number/maxExcluded.js.map +1 -1
  106. package/lib/asserts/number/maxExcluded.mjs +3 -12
  107. package/lib/asserts/number/maxExcluded.mjs.map +1 -1
  108. package/lib/asserts/number/min.d.mts +3 -1
  109. package/lib/asserts/number/min.d.ts +3 -1
  110. package/lib/asserts/number/min.js +3 -12
  111. package/lib/asserts/number/min.js.map +1 -1
  112. package/lib/asserts/number/min.mjs +3 -12
  113. package/lib/asserts/number/min.mjs.map +1 -1
  114. package/lib/asserts/number/minExcluded.d.mts +3 -1
  115. package/lib/asserts/number/minExcluded.d.ts +3 -1
  116. package/lib/asserts/number/minExcluded.js +3 -12
  117. package/lib/asserts/number/minExcluded.js.map +1 -1
  118. package/lib/asserts/number/minExcluded.mjs +3 -12
  119. package/lib/asserts/number/minExcluded.mjs.map +1 -1
  120. package/lib/asserts/number/negative.d.mts +3 -1
  121. package/lib/asserts/number/negative.d.ts +3 -1
  122. package/lib/asserts/number/negative.js +3 -12
  123. package/lib/asserts/number/negative.js.map +1 -1
  124. package/lib/asserts/number/negative.mjs +3 -12
  125. package/lib/asserts/number/negative.mjs.map +1 -1
  126. package/lib/asserts/number/positive.d.mts +3 -1
  127. package/lib/asserts/number/positive.d.ts +3 -1
  128. package/lib/asserts/number/positive.js +3 -12
  129. package/lib/asserts/number/positive.js.map +1 -1
  130. package/lib/asserts/number/positive.mjs +3 -12
  131. package/lib/asserts/number/positive.mjs.map +1 -1
  132. package/lib/asserts/object/index.d.mts +26 -3
  133. package/lib/asserts/object/index.d.ts +26 -3
  134. package/lib/asserts/object/index.js +5 -11
  135. package/lib/asserts/object/index.js.map +1 -1
  136. package/lib/asserts/object/index.mjs +5 -11
  137. package/lib/asserts/object/index.mjs.map +1 -1
  138. package/lib/asserts/object/maxKeys.d.mts +3 -1
  139. package/lib/asserts/object/maxKeys.d.ts +3 -1
  140. package/lib/asserts/object/maxKeys.js +3 -15
  141. package/lib/asserts/object/maxKeys.js.map +1 -1
  142. package/lib/asserts/object/maxKeys.mjs +3 -15
  143. package/lib/asserts/object/maxKeys.mjs.map +1 -1
  144. package/lib/asserts/string/atLeastOneDigit.d.mts +3 -1
  145. package/lib/asserts/string/atLeastOneDigit.d.ts +3 -1
  146. package/lib/asserts/string/atLeastOneDigit.js +3 -13
  147. package/lib/asserts/string/atLeastOneDigit.js.map +1 -1
  148. package/lib/asserts/string/atLeastOneDigit.mjs +3 -13
  149. package/lib/asserts/string/atLeastOneDigit.mjs.map +1 -1
  150. package/lib/asserts/string/atLeastOneLowerChar.d.mts +3 -1
  151. package/lib/asserts/string/atLeastOneLowerChar.d.ts +3 -1
  152. package/lib/asserts/string/atLeastOneLowerChar.js +3 -14
  153. package/lib/asserts/string/atLeastOneLowerChar.js.map +1 -1
  154. package/lib/asserts/string/atLeastOneLowerChar.mjs +3 -14
  155. package/lib/asserts/string/atLeastOneLowerChar.mjs.map +1 -1
  156. package/lib/asserts/string/atLeastOneSpecialChar.d.mts +3 -1
  157. package/lib/asserts/string/atLeastOneSpecialChar.d.ts +3 -1
  158. package/lib/asserts/string/atLeastOneSpecialChar.js +4 -18
  159. package/lib/asserts/string/atLeastOneSpecialChar.js.map +1 -1
  160. package/lib/asserts/string/atLeastOneSpecialChar.mjs +3 -17
  161. package/lib/asserts/string/atLeastOneSpecialChar.mjs.map +1 -1
  162. package/lib/asserts/string/atLeastOneUpperChar.d.mts +3 -1
  163. package/lib/asserts/string/atLeastOneUpperChar.d.ts +3 -1
  164. package/lib/asserts/string/atLeastOneUpperChar.js +3 -14
  165. package/lib/asserts/string/atLeastOneUpperChar.js.map +1 -1
  166. package/lib/asserts/string/atLeastOneUpperChar.mjs +3 -14
  167. package/lib/asserts/string/atLeastOneUpperChar.mjs.map +1 -1
  168. package/lib/asserts/string/contains.d.mts +3 -1
  169. package/lib/asserts/string/contains.d.ts +3 -1
  170. package/lib/asserts/string/contains.js +3 -14
  171. package/lib/asserts/string/contains.js.map +1 -1
  172. package/lib/asserts/string/contains.mjs +3 -14
  173. package/lib/asserts/string/contains.mjs.map +1 -1
  174. package/lib/asserts/string/email.d.mts +3 -1
  175. package/lib/asserts/string/email.d.ts +3 -1
  176. package/lib/asserts/string/email.js +3 -13
  177. package/lib/asserts/string/email.js.map +1 -1
  178. package/lib/asserts/string/email.mjs +3 -13
  179. package/lib/asserts/string/email.mjs.map +1 -1
  180. package/lib/asserts/string/endsWith.d.mts +3 -1
  181. package/lib/asserts/string/endsWith.d.ts +3 -1
  182. package/lib/asserts/string/endsWith.js +3 -14
  183. package/lib/asserts/string/endsWith.js.map +1 -1
  184. package/lib/asserts/string/endsWith.mjs +3 -14
  185. package/lib/asserts/string/endsWith.mjs.map +1 -1
  186. package/lib/asserts/string/index.d.mts +29 -3
  187. package/lib/asserts/string/index.d.ts +29 -3
  188. package/lib/asserts/string/index.js +8 -15
  189. package/lib/asserts/string/index.js.map +1 -1
  190. package/lib/asserts/string/index.mjs +8 -15
  191. package/lib/asserts/string/index.mjs.map +1 -1
  192. package/lib/asserts/string/isValidDate.d.mts +3 -1
  193. package/lib/asserts/string/isValidDate.d.ts +3 -1
  194. package/lib/asserts/string/isValidDate.js +3 -17
  195. package/lib/asserts/string/isValidDate.js.map +1 -1
  196. package/lib/asserts/string/isValidDate.mjs +3 -17
  197. package/lib/asserts/string/isValidDate.mjs.map +1 -1
  198. package/lib/asserts/string/isValidDateTime.d.mts +3 -1
  199. package/lib/asserts/string/isValidDateTime.d.ts +3 -1
  200. package/lib/asserts/string/isValidDateTime.js +3 -24
  201. package/lib/asserts/string/isValidDateTime.js.map +1 -1
  202. package/lib/asserts/string/isValidDateTime.mjs +3 -24
  203. package/lib/asserts/string/isValidDateTime.mjs.map +1 -1
  204. package/lib/asserts/string/isValidTime.d.mts +3 -1
  205. package/lib/asserts/string/isValidTime.d.ts +3 -1
  206. package/lib/asserts/string/isValidTime.js +3 -24
  207. package/lib/asserts/string/isValidTime.js.map +1 -1
  208. package/lib/asserts/string/isValidTime.mjs +3 -24
  209. package/lib/asserts/string/isValidTime.mjs.map +1 -1
  210. package/lib/asserts/string/lowerCase.d.mts +3 -1
  211. package/lib/asserts/string/lowerCase.d.ts +3 -1
  212. package/lib/asserts/string/lowerCase.js +3 -12
  213. package/lib/asserts/string/lowerCase.js.map +1 -1
  214. package/lib/asserts/string/lowerCase.mjs +3 -12
  215. package/lib/asserts/string/lowerCase.mjs.map +1 -1
  216. package/lib/asserts/string/maxLength.d.mts +3 -1
  217. package/lib/asserts/string/maxLength.d.ts +3 -1
  218. package/lib/asserts/string/maxLength.js +3 -12
  219. package/lib/asserts/string/maxLength.js.map +1 -1
  220. package/lib/asserts/string/maxLength.mjs +3 -12
  221. package/lib/asserts/string/maxLength.mjs.map +1 -1
  222. package/lib/asserts/string/minLength.d.mts +3 -1
  223. package/lib/asserts/string/minLength.d.ts +3 -1
  224. package/lib/asserts/string/minLength.js +3 -12
  225. package/lib/asserts/string/minLength.js.map +1 -1
  226. package/lib/asserts/string/minLength.mjs +3 -12
  227. package/lib/asserts/string/minLength.mjs.map +1 -1
  228. package/lib/asserts/string/regExp.d.mts +3 -1
  229. package/lib/asserts/string/regExp.d.ts +3 -1
  230. package/lib/asserts/string/regExp.js +3 -12
  231. package/lib/asserts/string/regExp.js.map +1 -1
  232. package/lib/asserts/string/regExp.mjs +3 -12
  233. package/lib/asserts/string/regExp.mjs.map +1 -1
  234. package/lib/asserts/string/startsWith.d.mts +3 -1
  235. package/lib/asserts/string/startsWith.d.ts +3 -1
  236. package/lib/asserts/string/startsWith.js +3 -14
  237. package/lib/asserts/string/startsWith.js.map +1 -1
  238. package/lib/asserts/string/startsWith.mjs +3 -14
  239. package/lib/asserts/string/startsWith.mjs.map +1 -1
  240. package/lib/asserts/string/upperCase.d.mts +3 -1
  241. package/lib/asserts/string/upperCase.d.ts +3 -1
  242. package/lib/asserts/string/upperCase.js +3 -14
  243. package/lib/asserts/string/upperCase.js.map +1 -1
  244. package/lib/asserts/string/upperCase.mjs +3 -14
  245. package/lib/asserts/string/upperCase.mjs.map +1 -1
  246. package/lib/asserts/string/uuid.d.mts +3 -1
  247. package/lib/asserts/string/uuid.d.ts +3 -1
  248. package/lib/asserts/string/uuid.js +3 -15
  249. package/lib/asserts/string/uuid.js.map +1 -1
  250. package/lib/asserts/string/uuid.mjs +3 -15
  251. package/lib/asserts/string/uuid.mjs.map +1 -1
  252. package/lib/asserts/string/uuidV1.d.mts +3 -1
  253. package/lib/asserts/string/uuidV1.d.ts +3 -1
  254. package/lib/asserts/string/uuidV1.js +3 -15
  255. package/lib/asserts/string/uuidV1.js.map +1 -1
  256. package/lib/asserts/string/uuidV1.mjs +3 -15
  257. package/lib/asserts/string/uuidV1.mjs.map +1 -1
  258. package/lib/asserts/string/uuidV2.d.mts +3 -1
  259. package/lib/asserts/string/uuidV2.d.ts +3 -1
  260. package/lib/asserts/string/uuidV2.js +3 -15
  261. package/lib/asserts/string/uuidV2.js.map +1 -1
  262. package/lib/asserts/string/uuidV2.mjs +3 -15
  263. package/lib/asserts/string/uuidV2.mjs.map +1 -1
  264. package/lib/asserts/string/uuidV3.d.mts +3 -1
  265. package/lib/asserts/string/uuidV3.d.ts +3 -1
  266. package/lib/asserts/string/uuidV3.js +3 -15
  267. package/lib/asserts/string/uuidV3.js.map +1 -1
  268. package/lib/asserts/string/uuidV3.mjs +3 -15
  269. package/lib/asserts/string/uuidV3.mjs.map +1 -1
  270. package/lib/asserts/string/uuidV4.d.mts +3 -1
  271. package/lib/asserts/string/uuidV4.d.ts +3 -1
  272. package/lib/asserts/string/uuidV4.js +3 -15
  273. package/lib/asserts/string/uuidV4.js.map +1 -1
  274. package/lib/asserts/string/uuidV4.mjs +3 -15
  275. package/lib/asserts/string/uuidV4.mjs.map +1 -1
  276. package/lib/asserts/string/uuidV5.d.mts +3 -1
  277. package/lib/asserts/string/uuidV5.d.ts +3 -1
  278. package/lib/asserts/string/uuidV5.js +3 -15
  279. package/lib/asserts/string/uuidV5.js.map +1 -1
  280. package/lib/asserts/string/uuidV5.mjs +3 -15
  281. package/lib/asserts/string/uuidV5.mjs.map +1 -1
  282. package/lib/asserts/string/validUrl.d.mts +3 -1
  283. package/lib/asserts/string/validUrl.d.ts +3 -1
  284. package/lib/asserts/string/validUrl.js +3 -19
  285. package/lib/asserts/string/validUrl.js.map +1 -1
  286. package/lib/asserts/string/validUrl.mjs +3 -19
  287. package/lib/asserts/string/validUrl.mjs.map +1 -1
  288. package/lib/chunk-22254THF.mjs +21 -0
  289. package/lib/chunk-22254THF.mjs.map +1 -0
  290. package/lib/chunk-22VHHJSS.js +28 -0
  291. package/lib/chunk-22VHHJSS.js.map +1 -0
  292. package/lib/chunk-23QTSXPQ.js +18 -0
  293. package/lib/chunk-23QTSXPQ.js.map +1 -0
  294. package/lib/chunk-24LO7MNY.js +18 -0
  295. package/lib/chunk-24LO7MNY.js.map +1 -0
  296. package/lib/{chunk-ASZW6XRM.mjs → chunk-2ANPCB4O.mjs} +4 -2
  297. package/lib/{chunk-ASZW6XRM.mjs.map → chunk-2ANPCB4O.mjs.map} +1 -1
  298. package/lib/chunk-2D3HCTJV.js +18 -0
  299. package/lib/chunk-2D3HCTJV.js.map +1 -0
  300. package/lib/chunk-2ESDKTV4.js +18 -0
  301. package/lib/chunk-2ESDKTV4.js.map +1 -0
  302. package/lib/chunk-2HGS4STD.js +48 -0
  303. package/lib/chunk-2HGS4STD.js.map +1 -0
  304. package/lib/chunk-2IPGGARK.mjs +21 -0
  305. package/lib/chunk-2IPGGARK.mjs.map +1 -0
  306. package/lib/chunk-3W2COCXV.js +18 -0
  307. package/lib/chunk-3W2COCXV.js.map +1 -0
  308. package/lib/chunk-4N5J426R.mjs +20 -0
  309. package/lib/chunk-4N5J426R.mjs.map +1 -0
  310. package/lib/chunk-4UPXP4I3.js +25 -0
  311. package/lib/chunk-4UPXP4I3.js.map +1 -0
  312. package/lib/{chunk-EMOOEIPZ.mjs → chunk-4ZKU4RJL.mjs} +2 -2
  313. package/lib/chunk-4ZKU4RJL.mjs.map +1 -0
  314. package/lib/chunk-5NYVRFG3.mjs +48 -0
  315. package/lib/chunk-5NYVRFG3.mjs.map +1 -0
  316. package/lib/chunk-62EKGBXF.js +21 -0
  317. package/lib/chunk-62EKGBXF.js.map +1 -0
  318. package/lib/chunk-6JPYR2TS.js +23 -0
  319. package/lib/chunk-6JPYR2TS.js.map +1 -0
  320. package/lib/chunk-6LPQRAFN.js +30 -0
  321. package/lib/chunk-6LPQRAFN.js.map +1 -0
  322. package/lib/{chunk-XG6K6N3A.mjs → chunk-6WKSLMJG.mjs} +10 -7
  323. package/lib/chunk-6WKSLMJG.mjs.map +1 -0
  324. package/lib/chunk-7JL66G7G.mjs +20 -0
  325. package/lib/chunk-7JL66G7G.mjs.map +1 -0
  326. package/lib/chunk-AJHBPMZT.mjs +19 -0
  327. package/lib/chunk-AJHBPMZT.mjs.map +1 -0
  328. package/lib/chunk-AQCV7PB4.mjs +28 -0
  329. package/lib/chunk-AQCV7PB4.mjs.map +1 -0
  330. package/lib/chunk-ARIYSQMH.js +20 -0
  331. package/lib/chunk-ARIYSQMH.js.map +1 -0
  332. package/lib/{chunk-42J6CHIO.js → chunk-AXKX5BGH.js} +4 -2
  333. package/lib/chunk-AXKX5BGH.js.map +1 -0
  334. package/lib/chunk-BRFUFNU4.js +18 -0
  335. package/lib/chunk-BRFUFNU4.js.map +1 -0
  336. package/lib/chunk-C2VSTWID.js +18 -0
  337. package/lib/chunk-C2VSTWID.js.map +1 -0
  338. package/lib/chunk-C44KAKMR.js +21 -0
  339. package/lib/chunk-C44KAKMR.js.map +1 -0
  340. package/lib/chunk-D6G32F2K.js +69 -0
  341. package/lib/chunk-D6G32F2K.js.map +1 -0
  342. package/lib/chunk-DCPRPCZ3.js +20 -0
  343. package/lib/chunk-DCPRPCZ3.js.map +1 -0
  344. package/lib/{chunk-BURPSYZ3.js → chunk-DED5KDLM.js} +18 -14
  345. package/lib/chunk-DED5KDLM.js.map +1 -0
  346. package/lib/chunk-DFYP4GKE.js +21 -0
  347. package/lib/chunk-DFYP4GKE.js.map +1 -0
  348. package/lib/chunk-ENZ5WDUQ.js +18 -0
  349. package/lib/chunk-ENZ5WDUQ.js.map +1 -0
  350. package/lib/chunk-FI737YZJ.js +19 -0
  351. package/lib/chunk-FI737YZJ.js.map +1 -0
  352. package/lib/chunk-GFWZQ4XW.mjs +30 -0
  353. package/lib/chunk-GFWZQ4XW.mjs.map +1 -0
  354. package/lib/chunk-GGWJJFXY.mjs +20 -0
  355. package/lib/chunk-GGWJJFXY.mjs.map +1 -0
  356. package/lib/chunk-H2M4FCRZ.mjs +21 -0
  357. package/lib/chunk-H2M4FCRZ.mjs.map +1 -0
  358. package/lib/chunk-H4OW6OUF.js +21 -0
  359. package/lib/chunk-H4OW6OUF.js.map +1 -0
  360. package/lib/chunk-HD37VXPZ.mjs +19 -0
  361. package/lib/chunk-HD37VXPZ.mjs.map +1 -0
  362. package/lib/chunk-HPIF2CMT.js +18 -0
  363. package/lib/chunk-HPIF2CMT.js.map +1 -0
  364. package/lib/chunk-HUWO5UKU.js +64 -0
  365. package/lib/chunk-HUWO5UKU.js.map +1 -0
  366. package/lib/chunk-HWVM4SYU.mjs +18 -0
  367. package/lib/chunk-HWVM4SYU.mjs.map +1 -0
  368. package/lib/chunk-IDDU6B6T.js +20 -0
  369. package/lib/chunk-IDDU6B6T.js.map +1 -0
  370. package/lib/chunk-KRCOKWAB.mjs +18 -0
  371. package/lib/chunk-KRCOKWAB.mjs.map +1 -0
  372. package/lib/chunk-LXZTBF7F.js +18 -0
  373. package/lib/chunk-LXZTBF7F.js.map +1 -0
  374. package/lib/chunk-M2GOQ7TZ.mjs +21 -0
  375. package/lib/chunk-M2GOQ7TZ.mjs.map +1 -0
  376. package/lib/{chunk-CCNK27CX.mjs → chunk-M3HYPZLE.mjs} +14 -10
  377. package/lib/chunk-M3HYPZLE.mjs.map +1 -0
  378. package/lib/chunk-MCQHWS3E.mjs +18 -0
  379. package/lib/chunk-MCQHWS3E.mjs.map +1 -0
  380. package/lib/chunk-MHWPSQB3.js +20 -0
  381. package/lib/chunk-MHWPSQB3.js.map +1 -0
  382. package/lib/chunk-N3EHGKZV.mjs +25 -0
  383. package/lib/chunk-N3EHGKZV.mjs.map +1 -0
  384. package/lib/chunk-NBR3QGKW.js +23 -0
  385. package/lib/chunk-NBR3QGKW.js.map +1 -0
  386. package/lib/{chunk-U3DJ354I.mjs → chunk-NFD7D5GZ.mjs} +25 -19
  387. package/lib/chunk-NFD7D5GZ.mjs.map +1 -0
  388. package/lib/chunk-NOJB5GBZ.mjs +18 -0
  389. package/lib/chunk-NOJB5GBZ.mjs.map +1 -0
  390. package/lib/chunk-NS4GXUCA.mjs +18 -0
  391. package/lib/chunk-NS4GXUCA.mjs.map +1 -0
  392. package/lib/chunk-NY2TPU6O.mjs +18 -0
  393. package/lib/chunk-NY2TPU6O.mjs.map +1 -0
  394. package/lib/{chunk-QWPHP26D.mjs → chunk-OE3L7EKN.mjs} +2 -2
  395. package/lib/chunk-OE3L7EKN.mjs.map +1 -0
  396. package/lib/chunk-OFZMO7PB.mjs +18 -0
  397. package/lib/chunk-OFZMO7PB.mjs.map +1 -0
  398. package/lib/chunk-OHUOBIHX.mjs +52 -0
  399. package/lib/chunk-OHUOBIHX.mjs.map +1 -0
  400. package/lib/chunk-OMSHZITC.js +20 -0
  401. package/lib/chunk-OMSHZITC.js.map +1 -0
  402. package/lib/chunk-OQYS7JVF.js +28 -0
  403. package/lib/chunk-OQYS7JVF.js.map +1 -0
  404. package/lib/chunk-OSFIPFQ3.mjs +28 -0
  405. package/lib/chunk-OSFIPFQ3.mjs.map +1 -0
  406. package/lib/chunk-OU5BTUDV.mjs +23 -0
  407. package/lib/chunk-OU5BTUDV.mjs.map +1 -0
  408. package/lib/chunk-OZ3BTSSQ.mjs +64 -0
  409. package/lib/chunk-OZ3BTSSQ.mjs.map +1 -0
  410. package/lib/{chunk-32MKEBKR.js → chunk-PAV4SQQL.js} +3 -3
  411. package/lib/chunk-PAV4SQQL.js.map +1 -0
  412. package/lib/chunk-PNSDUVRE.mjs +21 -0
  413. package/lib/chunk-PNSDUVRE.mjs.map +1 -0
  414. package/lib/chunk-PVQALO2H.js +23 -0
  415. package/lib/chunk-PVQALO2H.js.map +1 -0
  416. package/lib/chunk-QEG24G7E.mjs +18 -0
  417. package/lib/chunk-QEG24G7E.mjs.map +1 -0
  418. package/lib/chunk-QIFA6S5U.mjs +18 -0
  419. package/lib/chunk-QIFA6S5U.mjs.map +1 -0
  420. package/lib/chunk-QIPGUTIG.mjs +302 -0
  421. package/lib/chunk-QIPGUTIG.mjs.map +1 -0
  422. package/lib/chunk-QMIH3A4D.js +18 -0
  423. package/lib/chunk-QMIH3A4D.js.map +1 -0
  424. package/lib/chunk-R25HSJPH.js +21 -0
  425. package/lib/chunk-R25HSJPH.js.map +1 -0
  426. package/lib/chunk-S4FWDTEW.mjs +20 -0
  427. package/lib/chunk-S4FWDTEW.mjs.map +1 -0
  428. package/lib/chunk-S5D5AFDF.js +18 -0
  429. package/lib/chunk-S5D5AFDF.js.map +1 -0
  430. package/lib/chunk-SBO6OQIX.mjs +23 -0
  431. package/lib/chunk-SBO6OQIX.mjs.map +1 -0
  432. package/lib/chunk-SFIX77W5.js +21 -0
  433. package/lib/chunk-SFIX77W5.js.map +1 -0
  434. package/lib/chunk-T2A3XXQZ.mjs +18 -0
  435. package/lib/chunk-T2A3XXQZ.mjs.map +1 -0
  436. package/lib/{chunk-P4Q22AZA.js → chunk-TCDQA2NU.js} +12 -9
  437. package/lib/chunk-TCDQA2NU.js.map +1 -0
  438. package/lib/{chunk-YSCVE4PJ.mjs → chunk-THU5VBSO.mjs} +2 -2
  439. package/lib/chunk-THU5VBSO.mjs.map +1 -0
  440. package/lib/{chunk-EXVTHIT5.js → chunk-TJQ5NVL4.js} +2 -2
  441. package/lib/chunk-TJQ5NVL4.js.map +1 -0
  442. package/lib/{chunk-UTPG4GZB.js → chunk-TLPVFRWR.js} +3 -3
  443. package/lib/chunk-TLPVFRWR.js.map +1 -0
  444. package/lib/chunk-TLRVQWCI.mjs +30 -0
  445. package/lib/chunk-TLRVQWCI.mjs.map +1 -0
  446. package/lib/chunk-TQDMUHTA.mjs +20 -0
  447. package/lib/chunk-TQDMUHTA.mjs.map +1 -0
  448. package/lib/chunk-TZBAW5OO.mjs +21 -0
  449. package/lib/chunk-TZBAW5OO.mjs.map +1 -0
  450. package/lib/chunk-UHMICS34.mjs +18 -0
  451. package/lib/chunk-UHMICS34.mjs.map +1 -0
  452. package/lib/chunk-UYQFYQQG.mjs +69 -0
  453. package/lib/chunk-UYQFYQQG.mjs.map +1 -0
  454. package/lib/chunk-V2J4TQR5.mjs +20 -0
  455. package/lib/chunk-V2J4TQR5.mjs.map +1 -0
  456. package/lib/chunk-V7C77FML.mjs +18 -0
  457. package/lib/chunk-V7C77FML.mjs.map +1 -0
  458. package/lib/chunk-VN4GLOEN.js +302 -0
  459. package/lib/chunk-VN4GLOEN.js.map +1 -0
  460. package/lib/chunk-VOFKYSJD.js +20 -0
  461. package/lib/chunk-VOFKYSJD.js.map +1 -0
  462. package/lib/chunk-VVXKATDH.js +18 -0
  463. package/lib/chunk-VVXKATDH.js.map +1 -0
  464. package/lib/{chunk-P54CF5QN.mjs → chunk-W3U7RYLP.mjs} +2 -2
  465. package/lib/chunk-W3U7RYLP.mjs.map +1 -0
  466. package/lib/chunk-WJGXVKZY.js +21 -0
  467. package/lib/chunk-WJGXVKZY.js.map +1 -0
  468. package/lib/chunk-WLPDAJB3.js +52 -0
  469. package/lib/chunk-WLPDAJB3.js.map +1 -0
  470. package/lib/chunk-WYM2TIVW.mjs +23 -0
  471. package/lib/chunk-WYM2TIVW.mjs.map +1 -0
  472. package/lib/chunk-XBE75VFX.js +13 -0
  473. package/lib/chunk-XBE75VFX.js.map +1 -0
  474. package/lib/chunk-XDVSL5B6.js +14 -0
  475. package/lib/chunk-XDVSL5B6.js.map +1 -0
  476. package/lib/chunk-XIOV4SHZ.mjs +13 -0
  477. package/lib/chunk-XIOV4SHZ.mjs.map +1 -0
  478. package/lib/chunk-Y54K6TQO.js +19 -0
  479. package/lib/chunk-Y54K6TQO.js.map +1 -0
  480. package/lib/chunk-Y5MNJGFX.js +30 -0
  481. package/lib/chunk-Y5MNJGFX.js.map +1 -0
  482. package/lib/chunk-YDTQASAY.mjs +18 -0
  483. package/lib/chunk-YDTQASAY.mjs.map +1 -0
  484. package/lib/chunk-YMPRYKNY.js +18 -0
  485. package/lib/chunk-YMPRYKNY.js.map +1 -0
  486. package/lib/chunk-Z2HZXSDA.js +18 -0
  487. package/lib/chunk-Z2HZXSDA.js.map +1 -0
  488. package/lib/chunk-Z3NPFUIA.mjs +18 -0
  489. package/lib/chunk-Z3NPFUIA.mjs.map +1 -0
  490. package/lib/chunk-Z4XOKGU3.js +71 -0
  491. package/lib/chunk-Z4XOKGU3.js.map +1 -0
  492. package/lib/chunk-ZDXO3TGZ.mjs +18 -0
  493. package/lib/chunk-ZDXO3TGZ.mjs.map +1 -0
  494. package/lib/chunk-ZEGRYDE5.mjs +18 -0
  495. package/lib/chunk-ZEGRYDE5.mjs.map +1 -0
  496. package/lib/chunk-ZGUF5ZDP.mjs +21 -0
  497. package/lib/chunk-ZGUF5ZDP.mjs.map +1 -0
  498. package/lib/chunk-ZNQHNLKW.js +18 -0
  499. package/lib/chunk-ZNQHNLKW.js.map +1 -0
  500. package/lib/codeGen.d.mts +2 -2
  501. package/lib/codeGen.d.ts +2 -2
  502. package/lib/codeGen.js +3 -45
  503. package/lib/codeGen.js.map +1 -1
  504. package/lib/codeGen.mjs +4 -46
  505. package/lib/codeGen.mjs.map +1 -1
  506. package/lib/commonTypes.d.mts +12 -1
  507. package/lib/commonTypes.d.ts +12 -1
  508. package/lib/core.d.mts +200 -0
  509. package/lib/core.d.ts +200 -0
  510. package/lib/core.js +17 -0
  511. package/lib/core.js.map +1 -0
  512. package/lib/core.mjs +17 -0
  513. package/lib/helpers/constants.d.mts +2 -1
  514. package/lib/helpers/constants.d.ts +2 -1
  515. package/lib/helpers/constants.js +4 -2
  516. package/lib/helpers/constants.js.map +1 -1
  517. package/lib/helpers/constants.mjs +5 -3
  518. package/lib/helpers/setStrictType.d.mts +2 -2
  519. package/lib/helpers/setStrictType.d.ts +2 -2
  520. package/lib/helpers/setStrictType.js +3 -4
  521. package/lib/helpers/setStrictType.js.map +1 -1
  522. package/lib/helpers/setStrictType.mjs +2 -3
  523. package/lib/index.d.mts +51 -4
  524. package/lib/index.d.ts +51 -4
  525. package/lib/index.js +205 -4
  526. package/lib/index.js.map +1 -1
  527. package/lib/index.mjs +206 -5
  528. package/lib/translationMap.d.mts +3 -1
  529. package/lib/translationMap.d.ts +3 -1
  530. package/lib/translationMap.js +2 -2
  531. package/lib/translationMap.mjs +1 -1
  532. package/package.json +46 -41
  533. package/lib/CommonSchema-BIfYCtcQ.d.mts +0 -110
  534. package/lib/CommonSchema-DIDMH9R7.d.ts +0 -110
  535. package/lib/ExceptionContext.d.mts +0 -16
  536. package/lib/ExceptionContext.d.ts +0 -16
  537. package/lib/ExceptionContext.js +0 -11
  538. package/lib/ExceptionContext.js.map +0 -1
  539. package/lib/ExceptionContext.mjs +0 -11
  540. package/lib/ExceptionContext.mjs.map +0 -1
  541. package/lib/chunk-32MKEBKR.js.map +0 -1
  542. package/lib/chunk-3ZQ4ORQH.js +0 -14
  543. package/lib/chunk-3ZQ4ORQH.js.map +0 -1
  544. package/lib/chunk-42J6CHIO.js.map +0 -1
  545. package/lib/chunk-BURPSYZ3.js.map +0 -1
  546. package/lib/chunk-CCNK27CX.mjs.map +0 -1
  547. package/lib/chunk-EMOOEIPZ.mjs.map +0 -1
  548. package/lib/chunk-EXVTHIT5.js.map +0 -1
  549. package/lib/chunk-FNBYM254.js +0 -41
  550. package/lib/chunk-FNBYM254.js.map +0 -1
  551. package/lib/chunk-IFQLPXCZ.mjs +0 -111
  552. package/lib/chunk-IFQLPXCZ.mjs.map +0 -1
  553. package/lib/chunk-MMWS3SXR.js +0 -136
  554. package/lib/chunk-MMWS3SXR.js.map +0 -1
  555. package/lib/chunk-MQRXWXHP.mjs +0 -83
  556. package/lib/chunk-MQRXWXHP.mjs.map +0 -1
  557. package/lib/chunk-MRRMV2GM.mjs +0 -63
  558. package/lib/chunk-MRRMV2GM.mjs.map +0 -1
  559. package/lib/chunk-P4Q22AZA.js.map +0 -1
  560. package/lib/chunk-P54CF5QN.mjs.map +0 -1
  561. package/lib/chunk-PE55R4KH.js +0 -83
  562. package/lib/chunk-PE55R4KH.js.map +0 -1
  563. package/lib/chunk-PGEXAFA5.js +0 -20
  564. package/lib/chunk-PGEXAFA5.js.map +0 -1
  565. package/lib/chunk-PQ4GCO3Q.js +0 -111
  566. package/lib/chunk-PQ4GCO3Q.js.map +0 -1
  567. package/lib/chunk-QWPHP26D.mjs.map +0 -1
  568. package/lib/chunk-RAJF6LMF.js +0 -63
  569. package/lib/chunk-RAJF6LMF.js.map +0 -1
  570. package/lib/chunk-RG5NYH2I.js +0 -65
  571. package/lib/chunk-RG5NYH2I.js.map +0 -1
  572. package/lib/chunk-U3DJ354I.mjs.map +0 -1
  573. package/lib/chunk-UEYMBPZN.mjs +0 -136
  574. package/lib/chunk-UEYMBPZN.mjs.map +0 -1
  575. package/lib/chunk-UTPG4GZB.js.map +0 -1
  576. package/lib/chunk-VIFJBTQO.mjs +0 -20
  577. package/lib/chunk-VIFJBTQO.mjs.map +0 -1
  578. package/lib/chunk-W2SQHSOS.mjs +0 -58
  579. package/lib/chunk-W2SQHSOS.mjs.map +0 -1
  580. package/lib/chunk-XG6K6N3A.mjs.map +0 -1
  581. package/lib/chunk-XT5E3MPI.mjs +0 -41
  582. package/lib/chunk-XT5E3MPI.mjs.map +0 -1
  583. package/lib/chunk-YSCVE4PJ.mjs.map +0 -1
  584. package/lib/chunk-ZG373PNB.js +0 -58
  585. package/lib/chunk-ZG373PNB.js.map +0 -1
  586. package/lib/helpers/core.d.mts +0 -4
  587. package/lib/helpers/core.d.ts +0 -4
  588. package/lib/helpers/core.js +0 -10
  589. package/lib/helpers/core.js.map +0 -1
  590. package/lib/helpers/core.mjs +0 -10
  591. package/lib/parse.d.mts +0 -62
  592. package/lib/parse.d.ts +0 -62
  593. package/lib/parse.js +0 -11
  594. package/lib/parse.js.map +0 -1
  595. package/lib/parse.mjs +0 -11
  596. package/lib/parse.mjs.map +0 -1
  597. package/lib/parseOrFail.d.mts +0 -44
  598. package/lib/parseOrFail.d.ts +0 -44
  599. package/lib/parseOrFail.js +0 -11
  600. package/lib/parseOrFail.js.map +0 -1
  601. package/lib/parseOrFail.mjs +0 -11
  602. package/lib/parseOrFail.mjs.map +0 -1
  603. package/lib/schemas/ArraySchema.d.mts +0 -12
  604. package/lib/schemas/ArraySchema.d.ts +0 -12
  605. package/lib/schemas/ArraySchema.js +0 -13
  606. package/lib/schemas/ArraySchema.js.map +0 -1
  607. package/lib/schemas/ArraySchema.mjs +0 -13
  608. package/lib/schemas/ArraySchema.mjs.map +0 -1
  609. package/lib/schemas/BigIntSchema.d.mts +0 -31
  610. package/lib/schemas/BigIntSchema.d.ts +0 -31
  611. package/lib/schemas/BigIntSchema.js +0 -17
  612. package/lib/schemas/BigIntSchema.js.map +0 -1
  613. package/lib/schemas/BigIntSchema.mjs +0 -17
  614. package/lib/schemas/BigIntSchema.mjs.map +0 -1
  615. package/lib/schemas/BooleanSchema.d.mts +0 -26
  616. package/lib/schemas/BooleanSchema.d.ts +0 -26
  617. package/lib/schemas/BooleanSchema.js +0 -14
  618. package/lib/schemas/BooleanSchema.js.map +0 -1
  619. package/lib/schemas/BooleanSchema.mjs +0 -14
  620. package/lib/schemas/BooleanSchema.mjs.map +0 -1
  621. package/lib/schemas/CommonSchema.d.mts +0 -4
  622. package/lib/schemas/CommonSchema.d.ts +0 -4
  623. package/lib/schemas/CommonSchema.js +0 -12
  624. package/lib/schemas/CommonSchema.js.map +0 -1
  625. package/lib/schemas/CommonSchema.mjs +0 -12
  626. package/lib/schemas/CommonSchema.mjs.map +0 -1
  627. package/lib/schemas/DateSchema.d.mts +0 -11
  628. package/lib/schemas/DateSchema.d.ts +0 -11
  629. package/lib/schemas/DateSchema.js +0 -13
  630. package/lib/schemas/DateSchema.js.map +0 -1
  631. package/lib/schemas/DateSchema.mjs +0 -13
  632. package/lib/schemas/DateSchema.mjs.map +0 -1
  633. package/lib/schemas/NumberSchema.d.mts +0 -30
  634. package/lib/schemas/NumberSchema.d.ts +0 -30
  635. package/lib/schemas/NumberSchema.js +0 -17
  636. package/lib/schemas/NumberSchema.js.map +0 -1
  637. package/lib/schemas/NumberSchema.mjs +0 -17
  638. package/lib/schemas/NumberSchema.mjs.map +0 -1
  639. package/lib/schemas/ObjectSchema.d.mts +0 -30
  640. package/lib/schemas/ObjectSchema.d.ts +0 -30
  641. package/lib/schemas/ObjectSchema.js +0 -13
  642. package/lib/schemas/ObjectSchema.js.map +0 -1
  643. package/lib/schemas/ObjectSchema.mjs +0 -13
  644. package/lib/schemas/ObjectSchema.mjs.map +0 -1
  645. package/lib/schemas/StringSchema.d.mts +0 -31
  646. package/lib/schemas/StringSchema.d.ts +0 -31
  647. package/lib/schemas/StringSchema.js +0 -17
  648. package/lib/schemas/StringSchema.js.map +0 -1
  649. package/lib/schemas/StringSchema.mjs +0 -17
  650. package/lib/schemas/StringSchema.mjs.map +0 -1
  651. /package/lib/{helpers/core.mjs.map → core.mjs.map} +0 -0
@@ -1,111 +0,0 @@
1
- import {
2
- getTranslationByLocale
3
- } from "./chunk-QWPHP26D.mjs";
4
- import {
5
- ctxSymbol,
6
- innerCheck
7
- } from "./chunk-MQRXWXHP.mjs";
8
- import {
9
- ValidationError
10
- } from "./chunk-ZTCXXAKD.mjs";
11
-
12
- // src/parseOrFail.ts
13
- function parseOrFail(schema, receivedValue, options) {
14
- try {
15
- const ctx = new ExceptionContext(
16
- receivedValue,
17
- getTranslationByLocale(options?.lng),
18
- "",
19
- void 0,
20
- schema[ctxSymbol].meta
21
- );
22
- return innerCheck(schema, receivedValue, ctx);
23
- } catch (e) {
24
- if (e instanceof ValidationError) throw e;
25
- throw new Error("Something unexpected happened");
26
- }
27
- }
28
-
29
- // src/ExceptionContext.ts
30
- var replacePlaceholdersRegex = /{{(.*?)}}/g;
31
- function replacePlaceholders(template, replacements) {
32
- return template.replace(replacePlaceholdersRegex, (_, key) => {
33
- return key in replacements ? `${replacements[key]}` : `{{${key}}}`;
34
- });
35
- }
36
- var ExceptionContext = class _ExceptionContext {
37
- constructor(initialReceived, t, pathToError, errors, meta) {
38
- this.initialReceived = initialReceived;
39
- this.t = t;
40
- this.pathToError = pathToError;
41
- this.errors = errors;
42
- this.meta = meta;
43
- }
44
- createChild(childPathToError, childMeta) {
45
- return new _ExceptionContext(this.initialReceived, this.t, childPathToError, this.errors, childMeta);
46
- }
47
- ref(path) {
48
- let ref = this.initialReceived;
49
- const parsedRefPath = path.split(".");
50
- parsedRefPath.forEach((el) => {
51
- ref = ref[el];
52
- });
53
- return ref;
54
- }
55
- addIssue(expected, received, messageKey) {
56
- const rawMessage = this.t[messageKey] ?? messageKey;
57
- const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: this.pathToError });
58
- if (this.errors) {
59
- this.errors.push({
60
- expected,
61
- received,
62
- pathToError: this.pathToError,
63
- message
64
- });
65
- return;
66
- }
67
- throw new ValidationError(expected, received, this.pathToError, message, this.meta);
68
- }
69
- };
70
-
71
- // src/parse.ts
72
- function parse(schema, receivedValue, options) {
73
- try {
74
- const ctx = new ExceptionContext(
75
- receivedValue,
76
- getTranslationByLocale(options?.lng),
77
- "",
78
- options?.getAllErrors ? [] : void 0,
79
- schema[ctxSymbol].meta
80
- );
81
- const parsedValue = innerCheck(schema, receivedValue, ctx);
82
- if (ctx.errors?.length) {
83
- return [ctx.errors, void 0];
84
- }
85
- return [void 0, parsedValue];
86
- } catch (e) {
87
- if (e instanceof ValidationError) {
88
- delete e.stack;
89
- return [[e], void 0];
90
- }
91
- return [
92
- [
93
- {
94
- message: "Something unexpected happened",
95
- expected: "",
96
- received: "",
97
- pathToError: "",
98
- meta: void 0
99
- }
100
- ],
101
- void 0
102
- ];
103
- }
104
- }
105
-
106
- export {
107
- parse,
108
- parseOrFail,
109
- ExceptionContext
110
- };
111
- //# sourceMappingURL=chunk-IFQLPXCZ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/parseOrFail.ts","../src/ExceptionContext.ts","../src/parse.ts"],"sourcesContent":["import type { InferType } from './InferType';\nimport type { CommonSchema } from './schemas/CommonSchema';\nimport { ctxSymbol, innerCheck } from './helpers/core';\nimport { getTranslationByLocale } from './translationMap';\nimport { ValidationError } from './exceptions';\nimport { ExceptionContext } from './ExceptionContext';\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 const ctx = new ExceptionContext(\n receivedValue,\n getTranslationByLocale(options?.lng),\n '',\n undefined,\n schema[ctxSymbol].meta,\n );\n return innerCheck(schema, receivedValue, ctx) 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","import { ValidationError } from '.';\nimport { MetaContext, TranslationErrorMap, ValidationErrorData } from './commonTypes';\n\nconst replacePlaceholdersRegex = /{{(.*?)}}/g;\n\nfunction replacePlaceholders(template: string, replacements: Record<string, unknown>): string {\n return template.replace(replacePlaceholdersRegex, (_, key) => {\n return key in replacements ? `${replacements[key] as string}` : `{{${key}}}`;\n });\n}\n\nexport class ExceptionContext {\n constructor(\n public readonly initialReceived: unknown,\n public readonly t: TranslationErrorMap,\n public readonly pathToError: string,\n public readonly errors?: ValidationErrorData[],\n public readonly meta?: MetaContext,\n ) {}\n\n createChild(childPathToError: string, childMeta?: MetaContext) {\n return new ExceptionContext(this.initialReceived, this.t, childPathToError, this.errors, childMeta);\n }\n\n public ref(path: string): unknown {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let ref: any = this.initialReceived;\n const parsedRefPath = path.split('.');\n parsedRefPath.forEach((el) => {\n ref = ref[el];\n });\n\n return ref;\n }\n\n public addIssue(expected: unknown, received: unknown, messageKey: string): never | void {\n const rawMessage = this.t[messageKey] ?? messageKey;\n const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: this.pathToError });\n\n if (this.errors) {\n this.errors.push({\n expected,\n received,\n pathToError: this.pathToError,\n message,\n });\n\n return;\n }\n\n throw new ValidationError(expected, received, this.pathToError, message, this.meta);\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type RequiredValidation = (received: any, ctx: ExceptionContext) => void;\n","import { InferType } from './InferType';\nimport { ctxSymbol, innerCheck } from './helpers/core';\nimport { getTranslationByLocale } from './translationMap';\nimport { ValidationError } from './exceptions';\nimport { CommonSchema } from './schemas/CommonSchema';\nimport { ValidationErrorData } from './commonTypes';\nimport { ExceptionContext } from './ExceptionContext';\n\ninterface ParseOptions {\n /**\n * Set language keyword to map error messages.\n * @default 'default'\n * @example 'sr' or 'Serbia' or any string to identify language\n */\n lng?: string;\n\n /**\n * If true, collects all validation errors and returns them.\n * If false or undefined, returns the first validation error it can find and stops looking,\n * which provides a small runtime optimization.\n * @default undefined\n */\n getAllErrors?: boolean;\n}\n\n/**\n * Parses and validates a value against the provided schema, returning a type-safe parsedValue.\n *\n * This function will throw a `ValidationError` if the value does not conform to the schema.\n * The inferred TypeScript type of the returned value will match the structure defined by the schema.\n *\n * @template T\n * @param {T} schema - The schema to validate the received value against. This schema dictates the expected structure and type of the value.\n * @param {unknown} receivedValue - The value to be validated and parsed according to the schema.\n * @param {ParseOptions} options - Options\n * @param {ParseOptions.lng} options.lng - Set language keyword to map Error messages\n * @param {ParseOptions.lng} options.getAllErrors - If `false` or `undefined` - returns the first validation error it can find and stops looking, which provides a small runtime optimization.\n * @returns {[undefined, InferType<T>]} A tuple of [undefined, InferType<T>] if parsing is successful.\n * @returns {[ValidationErrorData[], undefined]} A tuple of [ValidationErrorData[], undefined]] if errors occur.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number(),\n * });\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: 30 });\n * // parsedValue will be inferred as { name: string; age: number }\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: '30' });\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // Array 'errors' returns only one element.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { getAllErrors: true});\n * // Returns array \"errors\" with multiple errors because 'age' should be a number and 'name' a string.\n * // With provided options { getAllErrors: true}, we can expecte more than one error in 'errors' array.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { lng: 'SR'});\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // With provided options { lng: 'SR'}, errors will be translated to a language mapped with keyword 'SR'\n */\nexport function parse<T extends CommonSchema>(\n schema: T,\n receivedValue: unknown,\n options?: ParseOptions,\n): [ValidationErrorData[], undefined] | [undefined, InferType<T>] {\n try {\n const ctx = new ExceptionContext(\n receivedValue,\n getTranslationByLocale(options?.lng),\n '',\n options?.getAllErrors ? [] : undefined,\n schema[ctxSymbol].meta,\n );\n\n const parsedValue = innerCheck(schema, receivedValue, ctx) as InferType<T>;\n\n if (ctx.errors?.length) {\n return [ctx.errors, undefined];\n }\n\n return [undefined, parsedValue];\n } catch (e) {\n if (e instanceof ValidationError) {\n delete e.stack;\n return [[e], undefined];\n }\n /* istanbul ignore next */\n return [\n [\n {\n message: 'Something unexpected happened',\n expected: '',\n received: '',\n pathToError: '',\n meta: undefined,\n },\n ],\n undefined,\n ];\n }\n}\n"],"mappings":";;;;;;;;;;;;AA2CO,SAAS,YACd,QACA,eACA,SACc;AACd,MAAI;AACF,UAAM,MAAM,IAAI;AAAA,MACd;AAAA,MACA,uBAAuB,SAAS,GAAG;AAAA,MACnC;AAAA,MACA;AAAA,MACA,OAAO,SAAS,EAAE;AAAA,IACpB;AACA,WAAO,WAAW,QAAQ,eAAe,GAAG;AAAA,EAC9C,SAAS,GAAG;AACV,QAAI,aAAa,gBAAiB,OAAM;AAExC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AACF;;;AC3DA,IAAM,2BAA2B;AAEjC,SAAS,oBAAoB,UAAkB,cAA+C;AAC5F,SAAO,SAAS,QAAQ,0BAA0B,CAAC,GAAG,QAAQ;AAC5D,WAAO,OAAO,eAAe,GAAG,aAAa,GAAG,CAAW,KAAK,KAAK,GAAG;AAAA,EAC1E,CAAC;AACH;AAEO,IAAM,mBAAN,MAAM,kBAAiB;AAAA,EAC5B,YACkB,iBACA,GACA,aACA,QACA,MAChB;AALgB;AACA;AACA;AACA;AACA;AAAA,EACf;AAAA,EAEH,YAAY,kBAA0B,WAAyB;AAC7D,WAAO,IAAI,kBAAiB,KAAK,iBAAiB,KAAK,GAAG,kBAAkB,KAAK,QAAQ,SAAS;AAAA,EACpG;AAAA,EAEO,IAAI,MAAuB;AAEhC,QAAI,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";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkPQ4GCO3Qjs = require('./chunk-PQ4GCO3Q.js');
4
-
5
-
6
- var _chunkPE55R4KHjs = require('./chunk-PE55R4KH.js');
7
-
8
-
9
- var _chunkFIDPCCCWjs = require('./chunk-FIDPCCCW.js');
10
-
11
- // src/schemas/CommonSchema.ts
12
- var CommonSchema = class {
13
-
14
- constructor(ctx) {
15
- this[_chunkPE55R4KHjs.ctxSymbol] = ctx;
16
- }
17
- /**
18
- * @param validators - One or more custom validation functions.
19
- * @returns {this} The schema instance with the added custom validation.
20
- */
21
- custom(...validators) {
22
- this.defaultValueCheck();
23
- this[_chunkPE55R4KHjs.ctxSymbol].requiredValidations.push(...validators);
24
- return this;
25
- }
26
- /**
27
- * Marks the schema as nullable, allowing the value to be `null`.
28
- *
29
- * @returns {WithNull<this>} The schema instance marked as nullable.
30
- */
31
- nullable() {
32
- this.defaultValueCheck();
33
- this[_chunkPE55R4KHjs.ctxSymbol].isNullable = true;
34
- return this;
35
- }
36
- /**
37
- * Marks the schema as optional, allowing the value to be `undefined`.
38
- *
39
- * @returns {WithUndefined<this>} The schema instance marked as optional.
40
- */
41
- optional() {
42
- this.defaultValueCheck();
43
- this[_chunkPE55R4KHjs.ctxSymbol].isOptional = true;
44
- return this;
45
- }
46
- /**
47
- * Marks the schema as optional, allowing the value to be `undefined`.
48
- *
49
- * @returns {this} The schema instance. This method should be used as a last one because it does the check of previous methods and
50
- */
51
- default(defaultValue) {
52
- const ctx = this[_chunkPE55R4KHjs.ctxSymbol];
53
- if (ctx.isOptional) {
54
- throw new (0, _chunkFIDPCCCWjs.BuildSchemaError)(`Cannot call method 'default' after method 'optional'`);
55
- }
56
- try {
57
- _chunkPQ4GCO3Qjs.parseOrFail.call(void 0, this, defaultValue);
58
- } catch (e) {
59
- throw new (0, _chunkFIDPCCCWjs.BuildSchemaError)(e.message);
60
- }
61
- this[_chunkPE55R4KHjs.ctxSymbol].defaultValue = defaultValue;
62
- return this;
63
- }
64
- /**
65
- * Applies a transformation to the input value before any validation occurs.
66
- * The transformation should return a value of the same type as the inferred type of the schema,
67
- * ensuring that the overall type is not altered.
68
- *
69
- * @template In - The type of the input value before transformation (defaults to `unknown`).
70
- * @param {TransformCallback<In, InferType<this>>} cb - The callback function that performs the transformation.
71
- * @returns {this} The updated schema with the applied transformation.
72
- *
73
- * @example
74
- * const schema = string()
75
- * .nullable()
76
- * .transformBeforeValidation((val) => val + '') // Ensure the value is a string
77
- * .transformBeforeValidation((val: string) => (val === '' ? null : val)); // Convert empty strings to null
78
- *
79
- * // Parse 'test' will pass as 'test' is a valid string longer than 3 characters.
80
- * parseOrFail(schema, 'test');
81
- *
82
- * // Parsing '' will be transformed to null and will pass due to .nullable().
83
- * parseOrFail(schema, '');
84
- */
85
- transformBeforeValidation(cb) {
86
- const ctx = this[_chunkPE55R4KHjs.ctxSymbol];
87
- if (ctx.transformListBefore) {
88
- ctx.transformListBefore.push(cb);
89
- } else {
90
- ctx.transformListBefore = [cb];
91
- }
92
- return this;
93
- }
94
- /**
95
- * Assigns a unique identifier to the schema.
96
- * This ID can be used to track or map validation errors back to specific fields
97
- * in a form or other structures.
98
- *
99
- * @param {string} value - The unique identifier for the schema.
100
- * @returns {this} The updated schema with the assigned ID.
101
- *
102
- * @example
103
- * const schema = string().id('username');
104
- */
105
- id(value) {
106
- return this.meta("id", value);
107
- }
108
- /**
109
- * Provides a description for the schema, offering additional context or information.
110
- * The description can be used when displaying validation errors or for documentation purposes.
111
- *
112
- * @param {string} value - The description for the schema.
113
- * @returns {this} The updated schema with the added description.
114
- *
115
- * @example
116
- * const schema = string().description('The username of the account holder.');
117
- */
118
- description(value) {
119
- return this.meta("description", value);
120
- }
121
- meta(key, value) {
122
- const ctx = this[_chunkPE55R4KHjs.ctxSymbol];
123
- ctx.meta = { ...ctx.meta, [key]: value };
124
- return this;
125
- }
126
- defaultValueCheck() {
127
- if (this[_chunkPE55R4KHjs.ctxSymbol].defaultValue !== void 0) {
128
- throw new (0, _chunkFIDPCCCWjs.BuildSchemaError)("Default value must be the last method called in schema");
129
- }
130
- }
131
- };
132
-
133
-
134
-
135
- exports.CommonSchema = CommonSchema;
136
- //# sourceMappingURL=chunk-MMWS3SXR.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-MMWS3SXR.js","../src/schemas/CommonSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACgBO,IAAM,aAAA,EAAN,MAAmB;AAAA,EACxB;AAAU,EACV,WAAA,CAAY,GAAA,EAAuB;AACjC,IAAA,IAAA,CAAK,0BAAS,EAAA,EAAI,GAAA;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,MAAA,CAAA,GAAU,UAAA,EAAwC;AACvD,IAAA,IAAA,CAAK,iBAAA,CAAkB,CAAA;AACvB,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,mBAAA,CAAoB,IAAA,CAAK,GAAG,UAAU,CAAA;AACtD,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,QAAA,CAAA,EAA2B;AAChC,IAAA,IAAA,CAAK,iBAAA,CAAkB,CAAA;AACvB,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,QAAA,CAAA,EAAgC;AACrC,IAAA,IAAA,CAAK,iBAAA,CAAkB,CAAA;AACvB,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,WAAA,EAAa,IAAA;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,OAAA,CAAQ,YAAA,EAAqC;AAClD,IAAA,MAAM,IAAA,EAA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K,CAAA;AAAA,EACvC;AAAA,EAEQ,IAAA,CAAK,GAAA,EAAa,KAAA,EAAqB;AAC7C,IAAA,MAAM,IAAA,EAAM,IAAA,CAAK,0BAAS,CAAA;AAC1B,IAAA,GAAA,CAAI,KAAA,EAAO,EAAE,GAAG,GAAA,CAAI,IAAA,EAAM,CAAC,GAAG,CAAA,EAAG,MAAM,CAAA;AACvC,IAAA,OAAO,IAAA;AAAA,EACT;AAAA,EAEU,iBAAA,CAAA,EAAoB;AAC5B,IAAA,GAAA,CAAI,IAAA,CAAK,0BAAS,CAAA,CAAE,aAAA,IAAiB,KAAA,CAAA,EAAW;AAC9C,MAAA,MAAM,IAAI,sCAAA,CAAiB,wDAAwD,CAAA;AAAA,IACrF;AAAA,EACF;AACF,CAAA;AD1BA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-MMWS3SXR.js","sourcesContent":[null,"import type { RequiredValidation } from '../ExceptionContext';\nimport { InferType } from '../InferType';\nimport { MetaContext, BaseType, WithNull, WithUndefined, TransformCallback } from '../commonTypes';\nimport { BuildSchemaError } from '../exceptions';\nimport { ctxSymbol } from '../helpers/core';\nimport { parseOrFail } from '../parseOrFail';\n\nexport type ObjectShapeSchemaType = Record<string, CommonSchema>;\n\nexport interface ValidatorContext {\n type: BaseType[];\n isNullable?: boolean;\n isOptional?: boolean;\n requiredValidations: RequiredValidation[];\n array?: CommonSchema;\n object?: ObjectShapeSchemaType;\n allowUnrecognizedObjectProps?: boolean;\n strictType?: boolean;\n strictTypeValue?: unknown;\n date?: boolean;\n defaultValue?: unknown;\n meta?: MetaContext;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformListBefore?: TransformCallback<any, any>[];\n}\n\nexport class CommonSchema {\n [ctxSymbol]: ValidatorContext;\n constructor(ctx: ValidatorContext) {\n this[ctxSymbol] = ctx;\n }\n\n /**\n * @param validators - One or more custom validation functions.\n * @returns {this} The schema instance with the added custom validation.\n */\n public custom(...validators: RequiredValidation[]): this {\n this.defaultValueCheck();\n this[ctxSymbol].requiredValidations.push(...validators);\n return this;\n }\n\n /**\n * Marks the schema as nullable, allowing the value to be `null`.\n *\n * @returns {WithNull<this>} The schema instance marked as nullable.\n */\n public nullable(): WithNull<this> {\n this.defaultValueCheck();\n this[ctxSymbol].isNullable = true;\n return this as WithNull<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {WithUndefined<this>} The schema instance marked as optional.\n */\n public optional(): WithUndefined<this> {\n this.defaultValueCheck();\n this[ctxSymbol].isOptional = true;\n return this as WithUndefined<this>;\n }\n\n /**\n * Marks the schema as optional, allowing the value to be `undefined`.\n *\n * @returns {this} The schema instance. This method should be used as a last one because it does the check of previous methods and\n */\n public default(defaultValue: InferType<this>): this {\n const ctx = this[ctxSymbol];\n if (ctx.isOptional) {\n throw new BuildSchemaError(`Cannot call method 'default' after method 'optional'`);\n }\n\n try {\n parseOrFail(this, defaultValue);\n } catch (e) {\n throw new BuildSchemaError((e as Error).message);\n }\n\n this[ctxSymbol].defaultValue = defaultValue;\n return this;\n }\n\n /**\n * Applies a transformation to the input value before any validation occurs.\n * The transformation should return a value of the same type as the inferred type of the schema,\n * ensuring that the overall type is not altered.\n *\n * @template In - The type of the input value before transformation (defaults to `unknown`).\n * @param {TransformCallback<In, InferType<this>>} cb - The callback function that performs the transformation.\n * @returns {this} The updated schema with the applied transformation.\n *\n * @example\n * const schema = string()\n * .nullable()\n * .transformBeforeValidation((val) => val + '') // Ensure the value is a string\n * .transformBeforeValidation((val: string) => (val === '' ? null : val)); // Convert empty strings to null\n *\n * // Parse 'test' will pass as 'test' is a valid string longer than 3 characters.\n * parseOrFail(schema, 'test');\n *\n * // Parsing '' will be transformed to null and will pass due to .nullable().\n * parseOrFail(schema, '');\n */\n public transformBeforeValidation<In>(cb: TransformCallback<In, InferType<this>>): this {\n const ctx = this[ctxSymbol];\n if (ctx.transformListBefore) {\n ctx.transformListBefore.push(cb);\n } else {\n ctx.transformListBefore = [cb];\n }\n\n return this;\n }\n\n /**\n * Assigns a unique identifier to the schema.\n * This ID can be used to track or map validation errors back to specific fields\n * in a form or other structures.\n *\n * @param {string} value - The unique identifier for the schema.\n * @returns {this} The updated schema with the assigned ID.\n *\n * @example\n * const schema = string().id('username');\n */\n public id(value: string): this {\n return this.meta('id', value);\n }\n\n /**\n * Provides a description for the schema, offering additional context or information.\n * The description can be used when displaying validation errors or for documentation purposes.\n *\n * @param {string} value - The description for the schema.\n * @returns {this} The updated schema with the added description.\n *\n * @example\n * const schema = string().description('The username of the account holder.');\n */\n public description(value: string): this {\n return this.meta('description', value);\n }\n\n private meta(key: string, value: string): this {\n const ctx = this[ctxSymbol];\n ctx.meta = { ...ctx.meta, [key]: value };\n return this;\n }\n\n protected defaultValueCheck() {\n if (this[ctxSymbol].defaultValue !== undefined) {\n throw new BuildSchemaError('Default value must be the last method called in schema');\n }\n }\n}\n\ntype TypeMapping = {\n number: number;\n string: string;\n boolean: boolean;\n undefined: undefined;\n object: object;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n function: Function;\n symbol: symbol;\n bigint: bigint;\n};\n\nexport type MapMixTypes<T extends BaseType[]> = T extends (infer U)[]\n ? U extends keyof TypeMapping\n ? TypeMapping[U]\n : never\n : never;\n"]}
@@ -1,83 +0,0 @@
1
- import {
2
- isValidDateInner
3
- } from "./chunk-YBVMP4EI.mjs";
4
-
5
- // src/helpers/core.ts
6
- var ctxSymbol = Symbol("contextSymbol");
7
- function innerCheck(schema, receivedValue, exCtx) {
8
- const commonTmap = exCtx.t;
9
- const schemaData = schema[ctxSymbol];
10
- schemaData.transformListBefore?.forEach((transformCallback) => {
11
- receivedValue = transformCallback(receivedValue);
12
- });
13
- if (receivedValue === void 0) {
14
- if (schemaData.defaultValue !== void 0) return schemaData.defaultValue;
15
- if (!schemaData.isOptional) exCtx.addIssue("Required", receivedValue, commonTmap["c:optional"]);
16
- return receivedValue;
17
- }
18
- if (receivedValue === null) {
19
- if (!schemaData.isNullable) exCtx.addIssue("Not null", receivedValue, commonTmap["c:nullable"]);
20
- return receivedValue;
21
- }
22
- if (schemaData.date) {
23
- if (!isValidDateInner(receivedValue)) exCtx.addIssue("Date", receivedValue, commonTmap["c:date"]);
24
- }
25
- const typeOfVal = typeof receivedValue;
26
- if (schemaData.type.length) {
27
- if (!schemaData.type.includes(typeOfVal)) exCtx.addIssue(schemaData.type, typeOfVal, commonTmap["c:invalidType"]);
28
- }
29
- if (schemaData.array) {
30
- if (!Array.isArray(receivedValue)) return exCtx.addIssue("Array", receivedValue, commonTmap["c:array"]);
31
- schemaData.requiredValidations.forEach((requiredValidation) => {
32
- requiredValidation(receivedValue, exCtx);
33
- });
34
- const schema2 = schemaData.array;
35
- const pathToError = exCtx.pathToError;
36
- const parsedReceivedValue = [];
37
- receivedValue.forEach((elem, i) => {
38
- const parsedElement = innerCheck(schema2, elem, exCtx.createChild(`${pathToError}[${i}]`, schemaData.meta));
39
- parsedReceivedValue.push(parsedElement);
40
- });
41
- return parsedReceivedValue;
42
- }
43
- if (schemaData.object) {
44
- if (typeOfVal !== "object") exCtx.addIssue("Object", receivedValue, commonTmap["c:objectType"]);
45
- if (Array.isArray(receivedValue)) exCtx.addIssue("Object", receivedValue, commonTmap["c:objectTypeAsArray"]);
46
- schemaData.requiredValidations.forEach((requiredValidation) => {
47
- requiredValidation(receivedValue, exCtx);
48
- });
49
- const shapeSchema = schemaData.object;
50
- const parsedReceivedValue = {};
51
- if (!schemaData.allowUnrecognizedObjectProps) {
52
- for (const keyPerReceivedValue of Object.keys(receivedValue)) {
53
- if (shapeSchema[keyPerReceivedValue] === void 0)
54
- exCtx.addIssue("Unrecognized property", keyPerReceivedValue, commonTmap["c:unrecognizedProperty"]);
55
- }
56
- }
57
- const pathToError = exCtx.pathToError;
58
- for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {
59
- const receivedObjectValuePropery = receivedValue[keyOfSchema];
60
- if (receivedObjectValuePropery === void 0) {
61
- if (!valueOfSchema[ctxSymbol].isOptional)
62
- exCtx.addIssue("Required", receivedObjectValuePropery, commonTmap["c:requiredProperty"]);
63
- }
64
- const parsedReceivedObjectValuePropery = innerCheck(
65
- valueOfSchema,
66
- receivedObjectValuePropery,
67
- exCtx.createChild(`${pathToError}.${keyOfSchema}`, schemaData.meta)
68
- );
69
- parsedReceivedValue[keyOfSchema] = parsedReceivedObjectValuePropery;
70
- }
71
- return parsedReceivedValue;
72
- }
73
- schemaData.requiredValidations.forEach((requiredValidation) => {
74
- requiredValidation(receivedValue, exCtx);
75
- });
76
- return receivedValue;
77
- }
78
-
79
- export {
80
- ctxSymbol,
81
- innerCheck
82
- };
83
- //# sourceMappingURL=chunk-MQRXWXHP.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/helpers/core.ts"],"sourcesContent":["import type { CommonSchema } from '../schemas/CommonSchema';\nimport { ExceptionContext } from '../ExceptionContext';\nimport { isValidDateInner } from './isValidDateInner';\n\nexport const ctxSymbol = Symbol('contextSymbol');\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, exCtx: ExceptionContext): unknown {\n const commonTmap = exCtx.t;\n const schemaData = schema[ctxSymbol];\n\n schemaData.transformListBefore?.forEach((transformCallback) => {\n receivedValue = transformCallback(receivedValue);\n });\n\n if (receivedValue === undefined) {\n if (schemaData.defaultValue !== undefined) return schemaData.defaultValue;\n if (!schemaData.isOptional) exCtx.addIssue('Required', receivedValue, commonTmap['c:optional']);\n return receivedValue;\n }\n\n if (receivedValue === null) {\n if (!schemaData.isNullable) exCtx.addIssue('Not null', receivedValue, commonTmap['c:nullable']);\n return receivedValue;\n }\n\n if (schemaData.date) {\n if (!isValidDateInner(receivedValue)) exCtx.addIssue('Date', receivedValue, commonTmap['c:date']);\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (schemaData.type.length) {\n if (!schemaData.type.includes(typeOfVal)) exCtx.addIssue(schemaData.type, typeOfVal, commonTmap['c:invalidType']);\n }\n\n if (schemaData.array) {\n if (!Array.isArray(receivedValue)) return exCtx.addIssue('Array', receivedValue, commonTmap['c:array']);\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\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.createChild(`${pathToError}[${i}]`, schemaData.meta));\n parsedReceivedValue.push(parsedElement);\n });\n\n return parsedReceivedValue;\n }\n\n if (schemaData.object) {\n if (typeOfVal !== 'object') exCtx.addIssue('Object', receivedValue, commonTmap['c:objectType']);\n if (Array.isArray(receivedValue)) exCtx.addIssue('Object', receivedValue, commonTmap['c:objectTypeAsArray']);\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\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 exCtx.addIssue('Unrecognized property', keyPerReceivedValue, 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 exCtx.addIssue('Required', receivedObjectValuePropery, commonTmap['c:requiredProperty']);\n }\n\n const parsedReceivedObjectValuePropery = innerCheck(\n valueOfSchema,\n receivedObjectValuePropery,\n exCtx.createChild(`${pathToError}.${keyOfSchema}`, schemaData.meta),\n );\n\n parsedReceivedValue[keyOfSchema] = parsedReceivedObjectValuePropery;\n }\n\n return parsedReceivedValue;\n }\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx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
- } from "./chunk-P54CF5QN.mjs";
7
- import {
8
- ONLY_ONCE
9
- } from "./chunk-ASZW6XRM.mjs";
10
- import {
11
- _setStrictType
12
- } from "./chunk-YSCVE4PJ.mjs";
13
- import {
14
- CommonSchema
15
- } from "./chunk-UEYMBPZN.mjs";
16
- import {
17
- BuildSchemaError
18
- } from "./chunk-ZTCXXAKD.mjs";
19
-
20
- // src/schemas/StringSchema.ts
21
- var StringSchema = class extends CommonSchema {
22
- _string = 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 - string().equalTo('hello'); // Infers the type 'hello'
31
- */
32
- equalTo(expectedValue) {
33
- this.limitCheck();
34
- _setStrictType(this, `'${expectedValue}'`);
35
- return this.custom(equalTo(expectedValue));
36
- }
37
- /**
38
- * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
39
- *
40
- * @param expectedValues - An array of values that the schema can match.
41
- * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.
42
- *
43
- * @example
44
- * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'
45
- */
46
- oneOfValues(expectedValue) {
47
- this.limitCheck();
48
- _setStrictType(
49
- this,
50
- expectedValue.map((el) => `'${el}'`)
51
- );
52
- return this.custom(oneOfValues(expectedValue));
53
- }
54
- limitCheck() {
55
- if (this.limit) throw new BuildSchemaError(ONLY_ONCE);
56
- this.limit = true;
57
- }
58
- };
59
-
60
- export {
61
- StringSchema
62
- };
63
- //# sourceMappingURL=chunk-MRRMV2GM.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas/StringSchema.ts"],"sourcesContent":["import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { WithBGuardType } from '../commonTypes';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class StringSchema extends CommonSchema {\n protected _string = 1;\n private limit: boolean | undefined;\n\n /**\n * Restricts the schema to exactly match the specified value and infers the literal value as the TypeScript type.\n *\n * @param expectedValue - The value that the schema must exactly match.\n * @returns - The schema instance restricted to the specified value, with the literal value inferred as the TypeScript type\n *\n * @example - string().equalTo('hello'); // Infers the type 'hello'\n */\n public equalTo<Y extends string>(expectedValue: Y): WithBGuardType<this, Y> {\n this.limitCheck();\n _setStrictType(this, `'${expectedValue}'`);\n\n return this.custom(equalTo(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n /**\n * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.\n *\n * @param expectedValues - An array of values that the schema can match.\n * @returns - The schema instance restricted to one of the specified values, with the union of those values inferred as the TypeScript type.\n *\n * @example\n * string().oneOfValues(['foo', 'bar']); // Infers the type 'foo' | 'bar'\n */\n public oneOfValues<Y extends string>(expectedValue: Y[]): WithBGuardType<this, Y> {\n this.limitCheck();\n _setStrictType(\n this,\n expectedValue.map((el) => `'${el}'`),\n );\n return this.custom(oneOfValues(expectedValue)) as WithBGuardType<this, Y>;\n }\n\n private limitCheck() {\n if (this.limit) throw new BuildSchemaError(ONLY_ONCE);\n this.limit = true;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQO,IAAM,eAAN,cAA2B,aAAa;AAAA,EACnC,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,QAA0B,eAA2C;AAC1E,SAAK,WAAW;AAChB,mBAAe,MAAM,IAAI,aAAa,GAAG;AAEzC,WAAO,KAAK,OAAO,QAAQ,aAAa,CAAC;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWO,YAA8B,eAA6C;AAChF,SAAK,WAAW;AAChB;AAAA,MACE;AAAA,MACA,cAAc,IAAI,CAAC,OAAO,IAAI,EAAE,GAAG;AAAA,IACrC;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 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-P4Q22AZA.js","../src/schemas/ArraySchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNO,IAAM,YAAA,YAAN,MAAA,QAA0B,8BAAa;AAAA,iBAClC,OAAA,EAAS,EAAA;AAAA,EACnB,WAAA,CAAY,GAAA,EAAuB,WAAA,EAA2B;AAC5D,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,kBAAA,CAAmB,WAAW,CAAA;AACnC,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,MAAA,EAAQ,WAAA;AAAA,EAC1B;AAAA,EAEQ,kBAAA,CAAmB,WAAA,EAA2B;AACpD,IAAA,GAAA,CAAI,CAAC,WAAA,EAAa,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAC7E,IAAA,GAAA,CAAI,CAAA,CAAE,YAAA,WAAuB,6BAAA,CAAA,EAAe,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAAA,EACzG;AACF,UAAA;ADOA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-P4Q22AZA.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class ArraySchema extends CommonSchema {\n protected _array = 1;\n constructor(ctx: ValidatorContext, arraySchema: CommonSchema) {\n super(ctx);\n this.validateArrayEntry(arraySchema);\n this[ctxSymbol].array = arraySchema;\n }\n\n private validateArrayEntry(arraySchema: CommonSchema) {\n if (!arraySchema) throw new BuildSchemaError('Missing schema in array method');\n if (!(arraySchema instanceof CommonSchema)) throw new BuildSchemaError('Invalid schema in array method');\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/asserts/mix/oneOfValues.ts"],"sourcesContent":["import { ExceptionContext, RequiredValidation } from '../../ExceptionContext';\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)) ctx.addIssue(expected, received, oneOfValuesErrorKey);\n };\n\noneOfValues.key = oneOfValuesErrorKey;\noneOfValues.message = oneOfValuesErrorMessage;\nsetToDefaultLocale(oneOfValues);\n"],"mappings":";;;;;AAGA,IAAM,0BAA0B;AAChC,IAAM,sBAAsB;AAgBrB,IAAM,cACX,CAAC,aACD,CAAC,UAAmB,QAA0B;AAC5C,MAAI,CAAC,SAAS,SAAS,QAAQ,EAAG,KAAI,SAAS,UAAU,UAAU,mBAAmB;AACxF;AAEF,YAAY,MAAM;AAClB,YAAY,UAAU;AACtB,mBAAmB,WAAW;","names":[]}
@@ -1,83 +0,0 @@
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
-
3
- var _chunkVBTWYDEMjs = require('./chunk-VBTWYDEM.js');
4
-
5
- // src/helpers/core.ts
6
- var ctxSymbol = Symbol("contextSymbol");
7
- function innerCheck(schema, receivedValue, exCtx) {
8
- const commonTmap = exCtx.t;
9
- const schemaData = schema[ctxSymbol];
10
- _optionalChain([schemaData, 'access', _ => _.transformListBefore, 'optionalAccess', _2 => _2.forEach, 'call', _3 => _3((transformCallback) => {
11
- receivedValue = transformCallback(receivedValue);
12
- })]);
13
- if (receivedValue === void 0) {
14
- if (schemaData.defaultValue !== void 0) return schemaData.defaultValue;
15
- if (!schemaData.isOptional) exCtx.addIssue("Required", receivedValue, commonTmap["c:optional"]);
16
- return receivedValue;
17
- }
18
- if (receivedValue === null) {
19
- if (!schemaData.isNullable) exCtx.addIssue("Not null", receivedValue, commonTmap["c:nullable"]);
20
- return receivedValue;
21
- }
22
- if (schemaData.date) {
23
- if (!_chunkVBTWYDEMjs.isValidDateInner.call(void 0, receivedValue)) exCtx.addIssue("Date", receivedValue, commonTmap["c:date"]);
24
- }
25
- const typeOfVal = typeof receivedValue;
26
- if (schemaData.type.length) {
27
- if (!schemaData.type.includes(typeOfVal)) exCtx.addIssue(schemaData.type, typeOfVal, commonTmap["c:invalidType"]);
28
- }
29
- if (schemaData.array) {
30
- if (!Array.isArray(receivedValue)) return exCtx.addIssue("Array", receivedValue, commonTmap["c:array"]);
31
- schemaData.requiredValidations.forEach((requiredValidation) => {
32
- requiredValidation(receivedValue, exCtx);
33
- });
34
- const schema2 = schemaData.array;
35
- const pathToError = exCtx.pathToError;
36
- const parsedReceivedValue = [];
37
- receivedValue.forEach((elem, i) => {
38
- const parsedElement = innerCheck(schema2, elem, exCtx.createChild(`${pathToError}[${i}]`, schemaData.meta));
39
- parsedReceivedValue.push(parsedElement);
40
- });
41
- return parsedReceivedValue;
42
- }
43
- if (schemaData.object) {
44
- if (typeOfVal !== "object") exCtx.addIssue("Object", receivedValue, commonTmap["c:objectType"]);
45
- if (Array.isArray(receivedValue)) exCtx.addIssue("Object", receivedValue, commonTmap["c:objectTypeAsArray"]);
46
- schemaData.requiredValidations.forEach((requiredValidation) => {
47
- requiredValidation(receivedValue, exCtx);
48
- });
49
- const shapeSchema = schemaData.object;
50
- const parsedReceivedValue = {};
51
- if (!schemaData.allowUnrecognizedObjectProps) {
52
- for (const keyPerReceivedValue of Object.keys(receivedValue)) {
53
- if (shapeSchema[keyPerReceivedValue] === void 0)
54
- exCtx.addIssue("Unrecognized property", keyPerReceivedValue, commonTmap["c:unrecognizedProperty"]);
55
- }
56
- }
57
- const pathToError = exCtx.pathToError;
58
- for (const [keyOfSchema, valueOfSchema] of Object.entries(shapeSchema)) {
59
- const receivedObjectValuePropery = receivedValue[keyOfSchema];
60
- if (receivedObjectValuePropery === void 0) {
61
- if (!valueOfSchema[ctxSymbol].isOptional)
62
- exCtx.addIssue("Required", receivedObjectValuePropery, commonTmap["c:requiredProperty"]);
63
- }
64
- const parsedReceivedObjectValuePropery = innerCheck(
65
- valueOfSchema,
66
- receivedObjectValuePropery,
67
- exCtx.createChild(`${pathToError}.${keyOfSchema}`, schemaData.meta)
68
- );
69
- parsedReceivedValue[keyOfSchema] = parsedReceivedObjectValuePropery;
70
- }
71
- return parsedReceivedValue;
72
- }
73
- schemaData.requiredValidations.forEach((requiredValidation) => {
74
- requiredValidation(receivedValue, exCtx);
75
- });
76
- return receivedValue;
77
- }
78
-
79
-
80
-
81
-
82
- exports.ctxSymbol = ctxSymbol; exports.innerCheck = innerCheck;
83
- //# sourceMappingURL=chunk-PE55R4KH.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-PE55R4KH.js","../src/helpers/core.ts"],"names":["schema"],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACAO,IAAM,UAAA,EAAY,MAAA,CAAO,eAAe,CAAA;AAExC,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;AAEnC,kBAAA,UAAA,mBAAW,mBAAA,6BAAqB,OAAA,mBAAQ,CAAC,iBAAA,EAAA,GAAsB;AAC7D,IAAA,cAAA,EAAgB,iBAAA,CAAkB,aAAa,CAAA;AAAA,EACjD,CAAC,GAAA;AAED,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,KAAA,CAAM,QAAA,CAAS,UAAA,EAAY,aAAA,EAAe,UAAA,CAAW,YAAY,CAAC,CAAA;AAC9F,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,cAAA,IAAkB,IAAA,EAAM;AAC1B,IAAA,GAAA,CAAI,CAAC,UAAA,CAAW,UAAA,EAAY,KAAA,CAAM,QAAA,CAAS,UAAA,EAAY,aAAA,EAAe,UAAA,CAAW,YAAY,CAAC,CAAA;AAC9F,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,UAAA,CAAW,IAAA,EAAM;AACnB,IAAA,GAAA,CAAI,CAAC,+CAAA,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AAA;AAER,IAAA;AACkB,MAAA;AACnB,QAAA;AACsB,UAAA;AACjE,MAAA;AACF,IAAA;AAE0B,IAAA;AAC2C,IAAA;AACsB,MAAA;AAC3C,MAAA;AACd,QAAA;AAC2B,UAAA;AAC3D,MAAA;AAEyC,MAAA;AACvC,QAAA;AACA,QAAA;AAC8D,QAAA;AAChE,MAAA;AAEmC,MAAA;AACrC,IAAA;AAEO,IAAA;AACT,EAAA;AAE+D,EAAA;AACtB,IAAA;AACxC,EAAA;AAEM,EAAA;AACT;ADnByE;AACA;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-PE55R4KH.js","sourcesContent":[null,"import type { CommonSchema } from '../schemas/CommonSchema';\nimport { ExceptionContext } from '../ExceptionContext';\nimport { isValidDateInner } from './isValidDateInner';\n\nexport const ctxSymbol = Symbol('contextSymbol');\n\nexport function innerCheck(schema: CommonSchema, receivedValue: unknown, exCtx: ExceptionContext): unknown {\n const commonTmap = exCtx.t;\n const schemaData = schema[ctxSymbol];\n\n schemaData.transformListBefore?.forEach((transformCallback) => {\n receivedValue = transformCallback(receivedValue);\n });\n\n if (receivedValue === undefined) {\n if (schemaData.defaultValue !== undefined) return schemaData.defaultValue;\n if (!schemaData.isOptional) exCtx.addIssue('Required', receivedValue, commonTmap['c:optional']);\n return receivedValue;\n }\n\n if (receivedValue === null) {\n if (!schemaData.isNullable) exCtx.addIssue('Not null', receivedValue, commonTmap['c:nullable']);\n return receivedValue;\n }\n\n if (schemaData.date) {\n if (!isValidDateInner(receivedValue)) exCtx.addIssue('Date', receivedValue, commonTmap['c:date']);\n }\n\n const typeOfVal = typeof receivedValue;\n\n if (schemaData.type.length) {\n if (!schemaData.type.includes(typeOfVal)) exCtx.addIssue(schemaData.type, typeOfVal, commonTmap['c:invalidType']);\n }\n\n if (schemaData.array) {\n if (!Array.isArray(receivedValue)) return exCtx.addIssue('Array', receivedValue, commonTmap['c:array']);\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\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.createChild(`${pathToError}[${i}]`, schemaData.meta));\n parsedReceivedValue.push(parsedElement);\n });\n\n return parsedReceivedValue;\n }\n\n if (schemaData.object) {\n if (typeOfVal !== 'object') exCtx.addIssue('Object', receivedValue, commonTmap['c:objectType']);\n if (Array.isArray(receivedValue)) exCtx.addIssue('Object', receivedValue, commonTmap['c:objectTypeAsArray']);\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\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 exCtx.addIssue('Unrecognized property', keyPerReceivedValue, 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 exCtx.addIssue('Required', receivedObjectValuePropery, commonTmap['c:requiredProperty']);\n }\n\n const parsedReceivedObjectValuePropery = innerCheck(\n valueOfSchema,\n receivedObjectValuePropery,\n exCtx.createChild(`${pathToError}.${keyOfSchema}`, schemaData.meta),\n );\n\n parsedReceivedValue[keyOfSchema] = parsedReceivedObjectValuePropery;\n }\n\n return parsedReceivedValue;\n }\n\n schemaData.requiredValidations.forEach((requiredValidation) => {\n requiredValidation(receivedValue, exCtx);\n });\n\n return receivedValue;\n}\n"]}
@@ -1,20 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
-
3
- var _chunkMMWS3SXRjs = require('./chunk-MMWS3SXR.js');
4
-
5
-
6
- var _chunkPE55R4KHjs = require('./chunk-PE55R4KH.js');
7
-
8
- // src/schemas/DateSchema.ts
9
- var DateSchema = (_class = class extends _chunkMMWS3SXRjs.CommonSchema {
10
- __init() {this._date = 1}
11
- constructor(ctx) {
12
- super(ctx);_class.prototype.__init.call(this);;
13
- this[_chunkPE55R4KHjs.ctxSymbol].date = true;
14
- }
15
- }, _class);
16
-
17
-
18
-
19
- exports.DateSchema = DateSchema;
20
- //# sourceMappingURL=chunk-PGEXAFA5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-PGEXAFA5.js","../src/schemas/DateSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACJO,IAAM,WAAA,YAAN,MAAA,QAAyB,8BAAa;AAAA,iBACjC,MAAA,EAAQ,EAAA;AAAA,EAElB,WAAA,CAAY,GAAA,EAAuB;AACjC,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,KAAA,EAAO,IAAA;AAAA,EACzB;AACF,UAAA;ADKA;AACA;AACE;AACF,gCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-PGEXAFA5.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class DateSchema extends CommonSchema {\n protected _date = 1;\n\n constructor(ctx: ValidatorContext) {\n super(ctx);\n this[ctxSymbol].date = true;\n }\n}\n"]}