bguard 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/README.md +562 -380
  2. package/lib/{CommonSchema-DJmQ3F_9.d.mts → CommonSchema-CiY7spmg.d.mts} +9 -1
  3. package/lib/{CommonSchema-9RtxTxdX.d.ts → CommonSchema-D9QVJBJe.d.ts} +9 -1
  4. package/lib/InferType.d.mts +1 -1
  5. package/lib/InferType.d.ts +1 -1
  6. package/lib/asserts/array/index.d.mts +1 -1
  7. package/lib/asserts/array/index.d.ts +1 -1
  8. package/lib/asserts/array/index.js +8 -6
  9. package/lib/asserts/array/index.js.map +1 -1
  10. package/lib/asserts/array/index.mjs +7 -5
  11. package/lib/asserts/array/index.mjs.map +1 -1
  12. package/lib/asserts/array/maxArrayLength.d.mts +22 -0
  13. package/lib/asserts/array/maxArrayLength.d.ts +22 -0
  14. package/lib/asserts/array/maxArrayLength.js +20 -0
  15. package/lib/asserts/array/maxArrayLength.js.map +1 -0
  16. package/lib/asserts/array/maxArrayLength.mjs +20 -0
  17. package/lib/asserts/array/maxArrayLength.mjs.map +1 -0
  18. package/lib/asserts/array/minArrayLength.d.mts +22 -0
  19. package/lib/asserts/array/minArrayLength.d.ts +22 -0
  20. package/lib/asserts/array/minArrayLength.js +20 -0
  21. package/lib/asserts/array/minArrayLength.js.map +1 -0
  22. package/lib/asserts/array/minArrayLength.mjs +20 -0
  23. package/lib/asserts/array/minArrayLength.mjs.map +1 -0
  24. package/lib/asserts/bigint/bigintMax.js +4 -4
  25. package/lib/asserts/bigint/bigintMax.mjs +2 -2
  26. package/lib/asserts/bigint/bigintMaxExcluded.js +4 -4
  27. package/lib/asserts/bigint/bigintMaxExcluded.mjs +2 -2
  28. package/lib/asserts/bigint/bigintMin.js +4 -4
  29. package/lib/asserts/bigint/bigintMin.mjs +2 -2
  30. package/lib/asserts/bigint/bigintMinExcluded.js +4 -4
  31. package/lib/asserts/bigint/bigintMinExcluded.mjs +2 -2
  32. package/lib/asserts/bigint/index.d.mts +1 -1
  33. package/lib/asserts/bigint/index.d.ts +1 -1
  34. package/lib/asserts/bigint/index.js +11 -10
  35. package/lib/asserts/bigint/index.js.map +1 -1
  36. package/lib/asserts/bigint/index.mjs +10 -9
  37. package/lib/asserts/bigint/index.mjs.map +1 -1
  38. package/lib/asserts/boolean/index.d.mts +1 -1
  39. package/lib/asserts/boolean/index.d.ts +1 -1
  40. package/lib/asserts/boolean/index.js +9 -7
  41. package/lib/asserts/boolean/index.js.map +1 -1
  42. package/lib/asserts/boolean/index.mjs +8 -6
  43. package/lib/asserts/boolean/index.mjs.map +1 -1
  44. package/lib/asserts/date/dateMax.js +6 -6
  45. package/lib/asserts/date/dateMax.js.map +1 -1
  46. package/lib/asserts/date/dateMax.mjs +5 -5
  47. package/lib/asserts/date/dateMax.mjs.map +1 -1
  48. package/lib/asserts/date/dateMin.js +6 -6
  49. package/lib/asserts/date/dateMin.js.map +1 -1
  50. package/lib/asserts/date/dateMin.mjs +5 -5
  51. package/lib/asserts/date/dateMin.mjs.map +1 -1
  52. package/lib/asserts/date/index.d.mts +1 -1
  53. package/lib/asserts/date/index.d.ts +1 -1
  54. package/lib/asserts/date/index.js +8 -6
  55. package/lib/asserts/date/index.js.map +1 -1
  56. package/lib/asserts/date/index.mjs +7 -5
  57. package/lib/asserts/date/index.mjs.map +1 -1
  58. package/lib/asserts/mix/equalTo.js +4 -4
  59. package/lib/asserts/mix/equalTo.mjs +3 -3
  60. package/lib/asserts/mix/index.d.mts +1 -1
  61. package/lib/asserts/mix/index.d.ts +1 -1
  62. package/lib/asserts/mix/index.js +7 -5
  63. package/lib/asserts/mix/index.js.map +1 -1
  64. package/lib/asserts/mix/index.mjs +6 -4
  65. package/lib/asserts/mix/index.mjs.map +1 -1
  66. package/lib/asserts/mix/oneOfValues.js +4 -4
  67. package/lib/asserts/mix/oneOfValues.mjs +3 -3
  68. package/lib/asserts/number/index.d.mts +1 -1
  69. package/lib/asserts/number/index.d.ts +1 -1
  70. package/lib/asserts/number/index.js +11 -10
  71. package/lib/asserts/number/index.js.map +1 -1
  72. package/lib/asserts/number/index.mjs +10 -9
  73. package/lib/asserts/number/index.mjs.map +1 -1
  74. package/lib/asserts/number/max.js +4 -4
  75. package/lib/asserts/number/max.mjs +2 -2
  76. package/lib/asserts/number/maxExcluded.js +4 -4
  77. package/lib/asserts/number/maxExcluded.mjs +2 -2
  78. package/lib/asserts/number/min.js +4 -4
  79. package/lib/asserts/number/min.mjs +2 -2
  80. package/lib/asserts/number/minExcluded.js +4 -4
  81. package/lib/asserts/number/minExcluded.mjs +2 -2
  82. package/lib/asserts/number/negative.js +4 -4
  83. package/lib/asserts/number/negative.mjs +2 -2
  84. package/lib/asserts/number/positive.js +4 -4
  85. package/lib/asserts/number/positive.mjs +2 -2
  86. package/lib/asserts/object/index.d.mts +1 -1
  87. package/lib/asserts/object/index.d.ts +1 -1
  88. package/lib/asserts/object/index.js +8 -6
  89. package/lib/asserts/object/index.js.map +1 -1
  90. package/lib/asserts/object/index.mjs +7 -5
  91. package/lib/asserts/object/index.mjs.map +1 -1
  92. package/lib/asserts/string/atLeastOneDigit.js +4 -4
  93. package/lib/asserts/string/atLeastOneDigit.mjs +2 -2
  94. package/lib/asserts/string/atLeastOneLowerChar.js +4 -4
  95. package/lib/asserts/string/atLeastOneLowerChar.mjs +2 -2
  96. package/lib/asserts/string/atLeastOneSpecialChar.js +4 -4
  97. package/lib/asserts/string/atLeastOneSpecialChar.mjs +2 -2
  98. package/lib/asserts/string/atLeastOneUpperChar.js +4 -4
  99. package/lib/asserts/string/atLeastOneUpperChar.mjs +2 -2
  100. package/lib/asserts/string/contains.js +4 -4
  101. package/lib/asserts/string/contains.mjs +2 -2
  102. package/lib/asserts/string/email.js +4 -4
  103. package/lib/asserts/string/email.mjs +2 -2
  104. package/lib/asserts/string/endsWith.js +4 -4
  105. package/lib/asserts/string/endsWith.mjs +2 -2
  106. package/lib/asserts/string/index.d.mts +1 -1
  107. package/lib/asserts/string/index.d.ts +1 -1
  108. package/lib/asserts/string/index.js +11 -10
  109. package/lib/asserts/string/index.js.map +1 -1
  110. package/lib/asserts/string/index.mjs +10 -9
  111. package/lib/asserts/string/index.mjs.map +1 -1
  112. package/lib/asserts/string/isValidDate.d.mts +21 -0
  113. package/lib/asserts/string/isValidDate.d.ts +21 -0
  114. package/lib/asserts/string/isValidDate.js +25 -0
  115. package/lib/asserts/string/isValidDate.js.map +1 -0
  116. package/lib/asserts/string/isValidDate.mjs +25 -0
  117. package/lib/asserts/string/isValidDate.mjs.map +1 -0
  118. package/lib/asserts/string/isValidDateTime.d.mts +35 -0
  119. package/lib/asserts/string/isValidDateTime.d.ts +35 -0
  120. package/lib/asserts/string/isValidDateTime.js +32 -0
  121. package/lib/asserts/string/isValidDateTime.js.map +1 -0
  122. package/lib/asserts/string/isValidDateTime.mjs +32 -0
  123. package/lib/asserts/string/isValidDateTime.mjs.map +1 -0
  124. package/lib/asserts/string/isValidTime.d.mts +29 -0
  125. package/lib/asserts/string/isValidTime.d.ts +29 -0
  126. package/lib/asserts/string/isValidTime.js +32 -0
  127. package/lib/asserts/string/isValidTime.js.map +1 -0
  128. package/lib/asserts/string/isValidTime.mjs +32 -0
  129. package/lib/asserts/string/isValidTime.mjs.map +1 -0
  130. package/lib/asserts/string/lowerCase.js +4 -4
  131. package/lib/asserts/string/lowerCase.mjs +2 -2
  132. package/lib/asserts/string/maxLength.js +4 -4
  133. package/lib/asserts/string/maxLength.mjs +2 -2
  134. package/lib/asserts/string/minLength.js +4 -4
  135. package/lib/asserts/string/minLength.mjs +2 -2
  136. package/lib/asserts/string/regExp.js +4 -4
  137. package/lib/asserts/string/regExp.mjs +2 -2
  138. package/lib/asserts/string/startsWith.js +4 -4
  139. package/lib/asserts/string/startsWith.mjs +2 -2
  140. package/lib/asserts/string/upperCase.js +4 -4
  141. package/lib/asserts/string/upperCase.mjs +2 -2
  142. package/lib/asserts/string/uuid.js +4 -4
  143. package/lib/asserts/string/uuid.mjs +2 -2
  144. package/lib/asserts/string/uuidV1.js +4 -4
  145. package/lib/asserts/string/uuidV1.mjs +2 -2
  146. package/lib/asserts/string/uuidV2.js +4 -4
  147. package/lib/asserts/string/uuidV2.mjs +2 -2
  148. package/lib/asserts/string/uuidV3.js +4 -4
  149. package/lib/asserts/string/uuidV3.mjs +2 -2
  150. package/lib/asserts/string/uuidV4.js +4 -4
  151. package/lib/asserts/string/uuidV4.mjs +2 -2
  152. package/lib/asserts/string/uuidV5.js +4 -4
  153. package/lib/asserts/string/uuidV5.mjs +2 -2
  154. package/lib/asserts/string/validUrl.js +4 -4
  155. package/lib/asserts/string/validUrl.mjs +2 -2
  156. package/lib/{chunk-32J4WVLE.js → chunk-2D5QE7F4.js} +17 -15
  157. package/lib/chunk-2D5QE7F4.js.map +1 -0
  158. package/lib/{chunk-XFR7Y4XX.mjs → chunk-2MFBOVP2.mjs} +3 -3
  159. package/lib/chunk-2MFBOVP2.mjs.map +1 -0
  160. package/lib/chunk-3IOQH3K4.js +74 -0
  161. package/lib/chunk-3IOQH3K4.js.map +1 -0
  162. package/lib/chunk-3ZPLJ5KC.js +14 -0
  163. package/lib/{chunk-LWAEUS2F.js.map → chunk-3ZPLJ5KC.js.map} +1 -1
  164. package/lib/{chunk-QV4JDW3T.mjs → chunk-4GDBM5LP.mjs} +2 -2
  165. package/lib/{chunk-PVOHKGBW.mjs → chunk-5HT3PYSG.mjs} +4 -4
  166. package/lib/chunk-5HT3PYSG.mjs.map +1 -0
  167. package/lib/{chunk-XZTZC73V.mjs → chunk-5LLJ22IG.mjs} +25 -17
  168. package/lib/chunk-5LLJ22IG.mjs.map +1 -0
  169. package/lib/{chunk-MRWZVTNH.mjs → chunk-ADSMWGDJ.mjs} +4 -4
  170. package/lib/{chunk-VGF3Y2EK.js → chunk-AN3VHQEQ.js} +7 -7
  171. package/lib/{chunk-VGF3Y2EK.js.map → chunk-AN3VHQEQ.js.map} +1 -1
  172. package/lib/chunk-AOUFWACR.mjs +74 -0
  173. package/lib/chunk-AOUFWACR.mjs.map +1 -0
  174. package/lib/{chunk-WK4O3HH4.js → chunk-AY7HKAG2.js} +2 -3
  175. package/lib/chunk-AY7HKAG2.js.map +1 -0
  176. package/lib/{chunk-M6OCVAUD.mjs → chunk-BUXOCPHI.mjs} +3 -3
  177. package/lib/{chunk-54RHVQFA.mjs → chunk-D42ISCFK.mjs} +2 -2
  178. package/lib/{chunk-5EIBKBYS.js → chunk-EU3ZZF7Y.js} +13 -13
  179. package/lib/chunk-EU3ZZF7Y.js.map +1 -0
  180. package/lib/{chunk-PEWNA24X.mjs → chunk-KBZUNXJB.mjs} +4 -4
  181. package/lib/chunk-KBZUNXJB.mjs.map +1 -0
  182. package/lib/chunk-LYNVPN3R.js +28 -0
  183. package/lib/chunk-LYNVPN3R.js.map +1 -0
  184. package/lib/{chunk-7XFLH6R2.mjs → chunk-NP64RC7B.mjs} +2 -3
  185. package/lib/chunk-NP64RC7B.mjs.map +1 -0
  186. package/lib/{chunk-YPAUFM3S.mjs → chunk-OHEMRF7Y.mjs} +3 -3
  187. package/lib/{chunk-QLVLZRHT.js → chunk-OJSTQQ3N.js} +5 -5
  188. package/lib/chunk-OJSTQQ3N.js.map +1 -0
  189. package/lib/{chunk-5AO66YV5.mjs → chunk-OKF3BVUD.mjs} +4 -4
  190. package/lib/{chunk-N6YMNLXG.js → chunk-OO6BTBVP.js} +11 -11
  191. package/lib/chunk-OO6BTBVP.js.map +1 -0
  192. package/lib/{chunk-SEIKS6G7.js → chunk-P6V6S6TZ.js} +19 -15
  193. package/lib/chunk-P6V6S6TZ.js.map +1 -0
  194. package/lib/{chunk-MTJJKWTP.js → chunk-PESVL5YJ.js} +7 -7
  195. package/lib/{chunk-MTJJKWTP.js.map → chunk-PESVL5YJ.js.map} +1 -1
  196. package/lib/{chunk-7GIRQ5EA.js → chunk-PIBDJJUU.js} +31 -23
  197. package/lib/chunk-PIBDJJUU.js.map +1 -0
  198. package/lib/{chunk-WPHJ4QTB.js → chunk-SPWF5IFU.js} +5 -5
  199. package/lib/{chunk-WPHJ4QTB.js.map → chunk-SPWF5IFU.js.map} +1 -1
  200. package/lib/{chunk-Z7OEFOAD.mjs → chunk-TQWUSDQD.mjs} +8 -8
  201. package/lib/chunk-TQWUSDQD.mjs.map +1 -0
  202. package/lib/{chunk-CQWI6YRI.js → chunk-UZ2PWO4O.js} +4 -4
  203. package/lib/{chunk-CQWI6YRI.js.map → chunk-UZ2PWO4O.js.map} +1 -1
  204. package/lib/{chunk-356HMXOP.js → chunk-VBTWYDEM.js} +4 -4
  205. package/lib/chunk-VBTWYDEM.js.map +1 -0
  206. package/lib/{chunk-4SPM2CSQ.js → chunk-W2GOLG3K.js} +5 -5
  207. package/lib/{chunk-4SPM2CSQ.js.map → chunk-W2GOLG3K.js.map} +1 -1
  208. package/lib/{chunk-GDSB7CDN.mjs → chunk-YBVMP4EI.mjs} +4 -4
  209. package/lib/chunk-YBVMP4EI.mjs.map +1 -0
  210. package/lib/{chunk-PJI3DRGP.mjs → chunk-YPAFWVDL.mjs} +4 -4
  211. package/lib/chunk-YPAFWVDL.mjs.map +1 -0
  212. package/lib/{chunk-UV4I7JZR.mjs → chunk-ZMEQCIRN.mjs} +16 -12
  213. package/lib/chunk-ZMEQCIRN.mjs.map +1 -0
  214. package/lib/{chunk-4SR7J2I4.js → chunk-ZVW3IHBW.js} +8 -8
  215. package/lib/chunk-ZVW3IHBW.js.map +1 -0
  216. package/lib/{chunk-TP5I237J.mjs → chunk-ZWE5Q37U.mjs} +14 -12
  217. package/lib/chunk-ZWE5Q37U.mjs.map +1 -0
  218. package/lib/codeGen.d.mts +1 -1
  219. package/lib/codeGen.d.ts +1 -1
  220. package/lib/codeGen.js +4 -4
  221. package/lib/codeGen.mjs +3 -3
  222. package/lib/exceptions.js +2 -2
  223. package/lib/exceptions.mjs +1 -1
  224. package/lib/helpers/core.d.mts +1 -1
  225. package/lib/helpers/core.d.ts +1 -1
  226. package/lib/helpers/core.js +4 -4
  227. package/lib/helpers/core.mjs +3 -3
  228. package/lib/helpers/isValidDateInner.d.mts +3 -0
  229. package/lib/helpers/isValidDateInner.d.ts +3 -0
  230. package/lib/helpers/isValidDateInner.js +7 -0
  231. package/lib/helpers/isValidDateInner.js.map +1 -0
  232. package/lib/helpers/isValidDateInner.mjs +7 -0
  233. package/lib/helpers/setStrictType.d.mts +1 -1
  234. package/lib/helpers/setStrictType.d.ts +1 -1
  235. package/lib/helpers/setStrictType.js +5 -5
  236. package/lib/helpers/setStrictType.mjs +4 -4
  237. package/lib/index.d.mts +1 -1
  238. package/lib/index.d.ts +1 -1
  239. package/lib/index.js +7 -7
  240. package/lib/index.mjs +6 -6
  241. package/lib/parse.d.mts +1 -1
  242. package/lib/parse.d.ts +1 -1
  243. package/lib/parse.js +6 -6
  244. package/lib/parse.mjs +5 -5
  245. package/lib/parseOrFail.d.mts +1 -1
  246. package/lib/parseOrFail.d.ts +1 -1
  247. package/lib/parseOrFail.js +6 -6
  248. package/lib/parseOrFail.mjs +5 -5
  249. package/lib/schemas/ArraySchema.d.mts +2 -2
  250. package/lib/schemas/ArraySchema.d.ts +2 -2
  251. package/lib/schemas/ArraySchema.js +8 -6
  252. package/lib/schemas/ArraySchema.js.map +1 -1
  253. package/lib/schemas/ArraySchema.mjs +7 -5
  254. package/lib/schemas/BigIntSchema.d.mts +3 -2
  255. package/lib/schemas/BigIntSchema.d.ts +3 -2
  256. package/lib/schemas/BigIntSchema.js +11 -10
  257. package/lib/schemas/BigIntSchema.js.map +1 -1
  258. package/lib/schemas/BigIntSchema.mjs +10 -9
  259. package/lib/schemas/BooleanSchema.d.mts +2 -2
  260. package/lib/schemas/BooleanSchema.d.ts +2 -2
  261. package/lib/schemas/BooleanSchema.js +9 -7
  262. package/lib/schemas/BooleanSchema.js.map +1 -1
  263. package/lib/schemas/BooleanSchema.mjs +8 -6
  264. package/lib/schemas/CommonSchema.d.mts +1 -1
  265. package/lib/schemas/CommonSchema.d.ts +1 -1
  266. package/lib/schemas/CommonSchema.js +7 -5
  267. package/lib/schemas/CommonSchema.js.map +1 -1
  268. package/lib/schemas/CommonSchema.mjs +6 -4
  269. package/lib/schemas/DateSchema.d.mts +2 -2
  270. package/lib/schemas/DateSchema.d.ts +2 -2
  271. package/lib/schemas/DateSchema.js +8 -6
  272. package/lib/schemas/DateSchema.js.map +1 -1
  273. package/lib/schemas/DateSchema.mjs +7 -5
  274. package/lib/schemas/NumberSchema.d.mts +2 -2
  275. package/lib/schemas/NumberSchema.d.ts +2 -2
  276. package/lib/schemas/NumberSchema.js +11 -10
  277. package/lib/schemas/NumberSchema.js.map +1 -1
  278. package/lib/schemas/NumberSchema.mjs +10 -9
  279. package/lib/schemas/ObjectSchema.d.mts +2 -2
  280. package/lib/schemas/ObjectSchema.d.ts +2 -2
  281. package/lib/schemas/ObjectSchema.js +8 -6
  282. package/lib/schemas/ObjectSchema.js.map +1 -1
  283. package/lib/schemas/ObjectSchema.mjs +7 -5
  284. package/lib/schemas/StringSchema.d.mts +3 -2
  285. package/lib/schemas/StringSchema.d.ts +3 -2
  286. package/lib/schemas/StringSchema.js +11 -10
  287. package/lib/schemas/StringSchema.js.map +1 -1
  288. package/lib/schemas/StringSchema.mjs +10 -9
  289. package/lib/translationMap.js +3 -3
  290. package/lib/translationMap.mjs +2 -2
  291. package/package.json +1 -1
  292. package/lib/chunk-2OINKFOA.js +0 -28
  293. package/lib/chunk-2OINKFOA.js.map +0 -1
  294. package/lib/chunk-32J4WVLE.js.map +0 -1
  295. package/lib/chunk-356HMXOP.js.map +0 -1
  296. package/lib/chunk-4SR7J2I4.js.map +0 -1
  297. package/lib/chunk-4UF67IQ2.mjs +0 -42
  298. package/lib/chunk-4UF67IQ2.mjs.map +0 -1
  299. package/lib/chunk-5EIBKBYS.js.map +0 -1
  300. package/lib/chunk-7GIRQ5EA.js.map +0 -1
  301. package/lib/chunk-7XFLH6R2.mjs.map +0 -1
  302. package/lib/chunk-EQNVYAKS.js +0 -42
  303. package/lib/chunk-EQNVYAKS.js.map +0 -1
  304. package/lib/chunk-GDSB7CDN.mjs.map +0 -1
  305. package/lib/chunk-LWAEUS2F.js +0 -14
  306. package/lib/chunk-N6YMNLXG.js.map +0 -1
  307. package/lib/chunk-PEWNA24X.mjs.map +0 -1
  308. package/lib/chunk-PJI3DRGP.mjs.map +0 -1
  309. package/lib/chunk-PVOHKGBW.mjs.map +0 -1
  310. package/lib/chunk-QLVLZRHT.js.map +0 -1
  311. package/lib/chunk-SEIKS6G7.js.map +0 -1
  312. package/lib/chunk-TP5I237J.mjs.map +0 -1
  313. package/lib/chunk-UV4I7JZR.mjs.map +0 -1
  314. package/lib/chunk-WK4O3HH4.js.map +0 -1
  315. package/lib/chunk-XFR7Y4XX.mjs.map +0 -1
  316. package/lib/chunk-XZTZC73V.mjs.map +0 -1
  317. package/lib/chunk-Z7OEFOAD.mjs.map +0 -1
  318. package/lib/helpers/isValidDate.d.mts +0 -3
  319. package/lib/helpers/isValidDate.d.ts +0 -3
  320. package/lib/helpers/isValidDate.js +0 -7
  321. package/lib/helpers/isValidDate.js.map +0 -1
  322. package/lib/helpers/isValidDate.mjs +0 -7
  323. /package/lib/{chunk-QV4JDW3T.mjs.map → chunk-4GDBM5LP.mjs.map} +0 -0
  324. /package/lib/{chunk-MRWZVTNH.mjs.map → chunk-ADSMWGDJ.mjs.map} +0 -0
  325. /package/lib/{chunk-M6OCVAUD.mjs.map → chunk-BUXOCPHI.mjs.map} +0 -0
  326. /package/lib/{chunk-54RHVQFA.mjs.map → chunk-D42ISCFK.mjs.map} +0 -0
  327. /package/lib/{chunk-YPAUFM3S.mjs.map → chunk-OHEMRF7Y.mjs.map} +0 -0
  328. /package/lib/{chunk-5AO66YV5.mjs.map → chunk-OKF3BVUD.mjs.map} +0 -0
  329. /package/lib/helpers/{isValidDate.mjs.map → isValidDateInner.mjs.map} +0 -0
@@ -1,9 +1,9 @@
1
1
  import {
2
- isValidDate
3
- } from "./chunk-GDSB7CDN.mjs";
2
+ isValidDateInner
3
+ } from "./chunk-YBVMP4EI.mjs";
4
4
  import {
5
5
  guardException
6
- } from "./chunk-7XFLH6R2.mjs";
6
+ } from "./chunk-NP64RC7B.mjs";
7
7
 
8
8
  // src/helpers/core.ts
9
9
  var ctxSymbol = Symbol("contextSymbol");
@@ -11,6 +11,7 @@ function innerCheck(schema, receivedValue, exCtx) {
11
11
  const commonTmap = exCtx.t;
12
12
  const schemaData = schema[ctxSymbol];
13
13
  if (receivedValue === void 0) {
14
+ if (schemaData.defaultValue !== void 0) return schemaData.defaultValue;
14
15
  if (!schemaData.isOptional) guardException("Required", receivedValue, exCtx, commonTmap["c:optional"]);
15
16
  return receivedValue;
16
17
  }
@@ -19,22 +20,32 @@ function innerCheck(schema, receivedValue, exCtx) {
19
20
  return receivedValue;
20
21
  }
21
22
  if (schemaData.date) {
22
- if (!isValidDate(receivedValue)) guardException("Date", receivedValue, exCtx, commonTmap["c:date"]);
23
+ if (!isValidDateInner(receivedValue)) guardException("Date", receivedValue, exCtx, commonTmap["c:date"]);
23
24
  }
25
+ const typeOfVal = typeof receivedValue;
26
+ if (schemaData.type.length) {
27
+ if (!schemaData.type.includes(typeOfVal))
28
+ guardException(schemaData.type, typeOfVal, exCtx, commonTmap["c:invalidType"]);
29
+ }
30
+ schemaData.requiredValidations.forEach((requiredValidation) => {
31
+ requiredValidation(receivedValue, exCtx);
32
+ });
24
33
  if (schemaData.array) {
25
34
  if (!Array.isArray(receivedValue)) return guardException("Array", receivedValue, exCtx, commonTmap["c:array"]);
26
35
  const schema2 = schemaData.array;
27
36
  const pathToError = exCtx.pathToError;
37
+ const parsedReceivedValue = [];
28
38
  receivedValue.forEach((elem, i) => {
29
- innerCheck(schema2, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });
39
+ const parsedElement = innerCheck(schema2, elem, { ...exCtx, pathToError: `${pathToError}[${i}]` });
40
+ parsedReceivedValue.push(parsedElement);
30
41
  });
31
- return receivedValue;
42
+ return parsedReceivedValue;
32
43
  }
33
- const typeOfVal = typeof receivedValue;
34
44
  if (schemaData.object) {
35
45
  if (typeOfVal !== "object") guardException("Object", receivedValue, exCtx, commonTmap["c:objectType"]);
36
46
  if (Array.isArray(receivedValue)) guardException("Object", receivedValue, exCtx, commonTmap["c:objectTypeAsArray"]);
37
47
  const shapeSchema = schemaData.object;
48
+ const parsedReceivedValue = {};
38
49
  if (!schemaData.allowUnrecognizedObjectProps) {
39
50
  for (const keyPerReceivedValue of Object.keys(receivedValue)) {
40
51
  if (shapeSchema[keyPerReceivedValue] === void 0)
@@ -48,17 +59,14 @@ function innerCheck(schema, receivedValue, exCtx) {
48
59
  if (!valueOfSchema[ctxSymbol].isOptional)
49
60
  guardException("Required", receivedObjectValuePropery, exCtx, commonTmap["c:requiredProperty"]);
50
61
  }
51
- innerCheck(valueOfSchema, receivedObjectValuePropery, { ...exCtx, pathToError: `${pathToError}.${keyOfSchema}` });
62
+ const parsedReceivedObjectValuePropery = innerCheck(valueOfSchema, receivedObjectValuePropery, {
63
+ ...exCtx,
64
+ pathToError: `${pathToError}.${keyOfSchema}`
65
+ });
66
+ parsedReceivedValue[keyOfSchema] = parsedReceivedObjectValuePropery;
52
67
  }
53
- return receivedValue;
68
+ return parsedReceivedValue;
54
69
  }
55
- if (schemaData.type.length) {
56
- if (!schemaData.type.includes(typeOfVal))
57
- guardException(schemaData.type, typeOfVal, exCtx, commonTmap["c:invalidType"]);
58
- }
59
- schemaData.requiredValidations.forEach((requiredValidation) => {
60
- requiredValidation(receivedValue, exCtx);
61
- });
62
70
  return receivedValue;
63
71
  }
64
72
 
@@ -66,4 +74,4 @@ export {
66
74
  ctxSymbol,
67
75
  innerCheck
68
76
  };
69
- //# sourceMappingURL=chunk-XZTZC73V.mjs.map
77
+ //# sourceMappingURL=chunk-5LLJ22IG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers/core.ts"],"sourcesContent":["export const ctxSymbol = Symbol('contextSymbol');\n\nimport { ExceptionContext } from '../commonTypes';\nimport { guardException } from '../exceptions';\nimport type { CommonSchema } from '../schemas/CommonSchema';\nimport { 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"],"mappings":";;;;;;;;AAAO,IAAM,YAAY,OAAO,eAAe;AAOxC,SAAS,WAAW,QAAsB,eAAwB,OAAkC;AACzG,QAAM,aAAa,MAAM;AACzB,QAAM,aAAa,OAAO,SAAS;AACnC,MAAI,kBAAkB,QAAW;AAC/B,QAAI,WAAW,iBAAiB,OAAW,QAAO,WAAW;AAC7D,QAAI,CAAC,WAAW,WAAY,gBAAe,YAAY,eAAe,OAAO,WAAW,YAAY,CAAC;AACrG,WAAO;AAAA,EACT;AAEA,MAAI,kBAAkB,MAAM;AAC1B,QAAI,CAAC,WAAW,WAAY,gBAAe,YAAY,eAAe,OAAO,WAAW,YAAY,CAAC;AACrG,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,MAAM;AACnB,QAAI,CAAC,iBAAiB,aAAa,EAAG,gBAAe,QAAQ,eAAe,OAAO,WAAW,QAAQ,CAAC;AAAA,EACzG;AAEA,QAAM,YAAY,OAAO;AAEzB,MAAI,WAAW,KAAK,QAAQ;AAC1B,QAAI,CAAC,WAAW,KAAK,SAAS,SAAS;AACrC,qBAAe,WAAW,MAAM,WAAW,OAAO,WAAW,eAAe,CAAC;AAAA,EACjF;AAEA,aAAW,oBAAoB,QAAQ,CAAC,uBAAuB;AAC7D,uBAAmB,eAAe,KAAK;AAAA,EACzC,CAAC;AAED,MAAI,WAAW,OAAO;AACpB,QAAI,CAAC,MAAM,QAAQ,aAAa,EAAG,QAAO,eAAe,SAAS,eAAe,OAAO,WAAW,SAAS,CAAC;AAC7G,UAAMA,UAAS,WAAW;AAC1B,UAAM,cAAc,MAAM;AAC1B,UAAM,sBAAiC,CAAC;AACxC,kBAAc,QAAQ,CAAC,MAAM,MAAM;AACjC,YAAM,gBAAgB,WAAWA,SAAQ,MAAM,EAAE,GAAG,OAAO,aAAa,GAAG,WAAW,IAAI,CAAC,IAAI,CAAC;AAChG,0BAAoB,KAAK,aAAa;AAAA,IACxC,CAAC;AAED,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,QAAQ;AACrB,QAAI,cAAc,SAAU,gBAAe,UAAU,eAAe,OAAO,WAAW,cAAc,CAAC;AACrG,QAAI,MAAM,QAAQ,aAAa,EAAG,gBAAe,UAAU,eAAe,OAAO,WAAW,qBAAqB,CAAC;AAClH,UAAM,cAAc,WAAW;AAC/B,UAAM,sBAA+C,CAAC;AAEtD,QAAI,CAAC,WAAW,8BAA8B;AAC5C,iBAAW,uBAAuB,OAAO,KAAK,aAAa,GAAG;AAC5D,YAAI,YAAY,mBAAmB,MAAM;AACvC,yBAAe,yBAAyB,qBAAqB,OAAO,WAAW,wBAAwB,CAAC;AAAA,MAC5G;AAAA,IACF;AAEA,UAAM,cAAc,MAAM;AAC1B,eAAW,CAAC,aAAa,aAAa,KAAK,OAAO,QAAQ,WAAW,GAAG;AACtE,YAAM,6BAA8B,cAA0C,WAAW;AACzF,UAAI,+BAA+B,QAAW;AAC5C,YAAI,CAAC,cAAc,SAAS,EAAE;AAC5B,yBAAe,YAAY,4BAA4B,OAAO,WAAW,oBAAoB,CAAC;AAAA,MAClG;AAEA,YAAM,mCAAmC,WAAW,eAAe,4BAA4B;AAAA,QAC7F,GAAG;AAAA,QACH,aAAa,GAAG,WAAW,IAAI,WAAW;AAAA,MAC5C,CAAC;AAED,0BAAoB,WAAW,IAAI;AAAA,IACrC;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":["schema"]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  innerCheck
3
- } from "./chunk-XZTZC73V.mjs";
3
+ } from "./chunk-5LLJ22IG.mjs";
4
4
  import {
5
5
  getTranslationByLocale
6
- } from "./chunk-QV4JDW3T.mjs";
6
+ } from "./chunk-4GDBM5LP.mjs";
7
7
  import {
8
8
  ValidationError
9
- } from "./chunk-7XFLH6R2.mjs";
9
+ } from "./chunk-NP64RC7B.mjs";
10
10
 
11
11
  // src/parseOrFail.ts
12
12
  function parseOrFail(schema, receivedValue, options) {
@@ -24,4 +24,4 @@ function parseOrFail(schema, receivedValue, options) {
24
24
  export {
25
25
  parseOrFail
26
26
  };
27
- //# sourceMappingURL=chunk-MRWZVTNH.mjs.map
27
+ //# sourceMappingURL=chunk-ADSMWGDJ.mjs.map
@@ -1,29 +1,29 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunk7GIRQ5EAjs = require('./chunk-7GIRQ5EA.js');
3
+ var _chunkPIBDJJUUjs = require('./chunk-PIBDJJUU.js');
4
4
 
5
5
 
6
- var _chunkCQWI6YRIjs = require('./chunk-CQWI6YRI.js');
6
+ var _chunkUZ2PWO4Ojs = require('./chunk-UZ2PWO4O.js');
7
7
 
8
8
 
9
- var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
9
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
10
10
 
11
11
  // src/parse.ts
12
12
  function parse(schema, receivedValue, options) {
13
13
  try {
14
14
  const ctx = {
15
- t: _chunkCQWI6YRIjs.getTranslationByLocale.call(void 0, _optionalChain([options, 'optionalAccess', _ => _.lng])),
15
+ t: _chunkUZ2PWO4Ojs.getTranslationByLocale.call(void 0, _optionalChain([options, 'optionalAccess', _ => _.lng])),
16
16
  pathToError: "",
17
17
  getAllErrors: _optionalChain([options, 'optionalAccess', _2 => _2.getAllErrors]),
18
18
  errors: []
19
19
  };
20
- const parsedValue = _chunk7GIRQ5EAjs.innerCheck.call(void 0, schema, receivedValue, ctx);
20
+ const parsedValue = _chunkPIBDJJUUjs.innerCheck.call(void 0, schema, receivedValue, ctx);
21
21
  if (ctx.getAllErrors && ctx.errors.length) {
22
22
  return [ctx.errors, void 0];
23
23
  }
24
24
  return [void 0, parsedValue];
25
25
  } catch (e) {
26
- if (e instanceof _chunkWK4O3HH4js.ValidationError) {
26
+ if (e instanceof _chunkAY7HKAG2js.ValidationError) {
27
27
  delete e.stack;
28
28
  return [[e], void 0];
29
29
  }
@@ -44,4 +44,4 @@ function parse(schema, receivedValue, options) {
44
44
 
45
45
 
46
46
  exports.parse = parse;
47
- //# sourceMappingURL=chunk-VGF3Y2EK.js.map
47
+ //# sourceMappingURL=chunk-AN3VHQEQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-VGF3Y2EK.js","../src/parse.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACqDO,SAAS,KAAA,CACd,MAAA,EACA,aAAA,EACA,OAAA,EACgE;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,EAAwB;AAAA,MAC5B,CAAA,EAAG,qDAAA,gBAAuB,OAAA,2BAAS,KAAG,CAAA;AAAA,MACtC,WAAA,EAAa,EAAA;AAAA,MACb,YAAA,kBAAc,OAAA,6BAAS,cAAA;AAAA,MACvB,MAAA,EAAQ,CAAC;AAAA,IACX,CAAA;AAEA,IAAA,MAAM,YAAA,EAAc,yCAAA,MAAW,EAAQ,aAAA,EAAe,GAAG,CAAA;AAEzD,IAAA,GAAA,CAAI,GAAA,CAAI,aAAA,GAAgB,GAAA,CAAI,MAAA,CAAO,MAAA,EAAQ;AACzC,MAAA,OAAO,CAAC,GAAA,CAAI,MAAA,EAAQ,KAAA,CAAS,CAAA;AAAA,IAC/B;AAEA,IAAA,OAAO,CAAC,KAAA,CAAA,EAAW,WAAW,CAAA;AAAA,EAChC,EAAA,MAAA,CAAS,CAAA,EAAG;AACV,IAAA,GAAA,CAAI,EAAA,WAAa,gCAAA,EAAiB;AAChC,MAAA,OAAO,CAAA,CAAE,KAAA;AACT,MAAA,OAAO,CAAC,CAAC,CAAC,CAAA,EAAG,KAAA,CAAS,CAAA;AAAA,IACxB;AAEA,IAAA,OAAO;AAAA,MACL;AAAA,QACE;AAAA,UACE,OAAA,EAAS,+BAAA;AAAA,UACT,QAAA,EAAU,EAAA;AAAA,UACV,QAAA,EAAU,EAAA;AAAA,UACV,WAAA,EAAa;AAAA,QACf;AAAA,MACF,CAAA;AAAA,MACA,KAAA;AAAA,IACF,CAAA;AAAA,EACF;AACF;AD3DA;AACA;AACE;AACF,sBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-VGF3Y2EK.js","sourcesContent":[null,"import { InferType } from './InferType';\nimport { innerCheck } from './helpers/core';\nimport { getTranslationByLocale } from './translationMap';\nimport { ValidationError } from './exceptions';\nimport { CommonSchema } from './schemas/CommonSchema';\nimport { ExceptionContext, ValidationErrorData } from './commonTypes';\n\ninterface ParseOptions {\n /**\n * Set language keyword to map error messages.\n * @default 'default'\n * @example 'sr' or 'Serbia' or any string to identify language\n */\n lng?: string;\n\n /**\n * If true, collects all validation errors and returns them.\n * If false or undefined, returns the first validation error it can find and stops looking,\n * which provides a small runtime optimization.\n * @default undefined\n */\n getAllErrors?: boolean;\n}\n\n/**\n * Parses and validates a value against the provided schema, returning a type-safe parsedValue.\n *\n * This function will throw a `ValidationError` if the value does not conform to the schema.\n * The inferred TypeScript type of the returned value will match the structure defined by the schema.\n *\n * @template T\n * @param {T} schema - The schema to validate the received value against. This schema dictates the expected structure and type of the value.\n * @param {unknown} receivedValue - The value to be validated and parsed according to the schema.\n * @param {ParseOptions} options - Options\n * @param {ParseOptions.lng} options.lng - Set language keyword to map Error messages\n * @param {ParseOptions.lng} options.getAllErrors - If `false` or `undefined` - returns the first validation error it can find and stops looking, which provides a small runtime optimization.\n * @returns {[undefined, InferType<T>]} A tuple of [undefined, InferType<T>] if parsing is successful.\n * @returns {[ValidationErrorData[], undefined]} A tuple of [ValidationErrorData[], undefined]] if errors occur.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number(),\n * });\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: 30 });\n * // parsedValue will be inferred as { name: string; age: number }\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: '30' });\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // Array 'errors' returns only one element.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { getAllErrors: true});\n * // Returns array \"errors\" with multiple errors because 'age' should be a number and 'name' a string.\n * // With provided options { getAllErrors: true}, we can expecte more than one error in 'errors' array.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { lng: 'SR'});\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // With provided options { lng: 'SR'}, errors will be translated to a language mapped with keyword 'SR'\n */\nexport function parse<T extends CommonSchema>(\n schema: T,\n receivedValue: unknown,\n options?: ParseOptions,\n): [ValidationErrorData[], undefined] | [undefined, InferType<T>] {\n try {\n const ctx: ExceptionContext = {\n t: getTranslationByLocale(options?.lng),\n pathToError: '',\n getAllErrors: options?.getAllErrors,\n errors: [],\n };\n\n const parsedValue = innerCheck(schema, receivedValue, ctx) as InferType<T>;\n\n if (ctx.getAllErrors && ctx.errors.length) {\n return [ctx.errors, undefined];\n }\n\n return [undefined, parsedValue];\n } catch (e) {\n if (e instanceof ValidationError) {\n delete e.stack;\n return [[e], undefined];\n }\n /* istanbul ignore next */\n return [\n [\n {\n message: 'Something unexpected happened',\n expected: '',\n received: '',\n pathToError: '',\n },\n ],\n undefined,\n ];\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-AN3VHQEQ.js","../src/parse.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACqDO,SAAS,KAAA,CACd,MAAA,EACA,aAAA,EACA,OAAA,EACgE;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,EAAwB;AAAA,MAC5B,CAAA,EAAG,qDAAA,gBAAuB,OAAA,2BAAS,KAAG,CAAA;AAAA,MACtC,WAAA,EAAa,EAAA;AAAA,MACb,YAAA,kBAAc,OAAA,6BAAS,cAAA;AAAA,MACvB,MAAA,EAAQ,CAAC;AAAA,IACX,CAAA;AAEA,IAAA,MAAM,YAAA,EAAc,yCAAA,MAAW,EAAQ,aAAA,EAAe,GAAG,CAAA;AAEzD,IAAA,GAAA,CAAI,GAAA,CAAI,aAAA,GAAgB,GAAA,CAAI,MAAA,CAAO,MAAA,EAAQ;AACzC,MAAA,OAAO,CAAC,GAAA,CAAI,MAAA,EAAQ,KAAA,CAAS,CAAA;AAAA,IAC/B;AAEA,IAAA,OAAO,CAAC,KAAA,CAAA,EAAW,WAAW,CAAA;AAAA,EAChC,EAAA,MAAA,CAAS,CAAA,EAAG;AACV,IAAA,GAAA,CAAI,EAAA,WAAa,gCAAA,EAAiB;AAChC,MAAA,OAAO,CAAA,CAAE,KAAA;AACT,MAAA,OAAO,CAAC,CAAC,CAAC,CAAA,EAAG,KAAA,CAAS,CAAA;AAAA,IACxB;AAEA,IAAA,OAAO;AAAA,MACL;AAAA,QACE;AAAA,UACE,OAAA,EAAS,+BAAA;AAAA,UACT,QAAA,EAAU,EAAA;AAAA,UACV,QAAA,EAAU,EAAA;AAAA,UACV,WAAA,EAAa;AAAA,QACf;AAAA,MACF,CAAA;AAAA,MACA,KAAA;AAAA,IACF,CAAA;AAAA,EACF;AACF;AD3DA;AACA;AACE;AACF,sBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-AN3VHQEQ.js","sourcesContent":[null,"import { InferType } from './InferType';\nimport { innerCheck } from './helpers/core';\nimport { getTranslationByLocale } from './translationMap';\nimport { ValidationError } from './exceptions';\nimport { CommonSchema } from './schemas/CommonSchema';\nimport { ExceptionContext, ValidationErrorData } from './commonTypes';\n\ninterface ParseOptions {\n /**\n * Set language keyword to map error messages.\n * @default 'default'\n * @example 'sr' or 'Serbia' or any string to identify language\n */\n lng?: string;\n\n /**\n * If true, collects all validation errors and returns them.\n * If false or undefined, returns the first validation error it can find and stops looking,\n * which provides a small runtime optimization.\n * @default undefined\n */\n getAllErrors?: boolean;\n}\n\n/**\n * Parses and validates a value against the provided schema, returning a type-safe parsedValue.\n *\n * This function will throw a `ValidationError` if the value does not conform to the schema.\n * The inferred TypeScript type of the returned value will match the structure defined by the schema.\n *\n * @template T\n * @param {T} schema - The schema to validate the received value against. This schema dictates the expected structure and type of the value.\n * @param {unknown} receivedValue - The value to be validated and parsed according to the schema.\n * @param {ParseOptions} options - Options\n * @param {ParseOptions.lng} options.lng - Set language keyword to map Error messages\n * @param {ParseOptions.lng} options.getAllErrors - If `false` or `undefined` - returns the first validation error it can find and stops looking, which provides a small runtime optimization.\n * @returns {[undefined, InferType<T>]} A tuple of [undefined, InferType<T>] if parsing is successful.\n * @returns {[ValidationErrorData[], undefined]} A tuple of [ValidationErrorData[], undefined]] if errors occur.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number(),\n * });\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: 30 });\n * // parsedValue will be inferred as { name: string; age: number }\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: 'Alice', age: '30' });\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // Array 'errors' returns only one element.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { getAllErrors: true});\n * // Returns array \"errors\" with multiple errors because 'age' should be a number and 'name' a string.\n * // With provided options { getAllErrors: true}, we can expecte more than one error in 'errors' array.\n *\n *\n * const [errors, parsedValue] = parse(schema, { name: true, age: '30' }, { lng: 'SR'});\n * // First element in array \"errors\" will have an error because 'age' should be a number, not a string.\n * // With provided options { lng: 'SR'}, errors will be translated to a language mapped with keyword 'SR'\n */\nexport function parse<T extends CommonSchema>(\n schema: T,\n receivedValue: unknown,\n options?: ParseOptions,\n): [ValidationErrorData[], undefined] | [undefined, InferType<T>] {\n try {\n const ctx: ExceptionContext = {\n t: getTranslationByLocale(options?.lng),\n pathToError: '',\n getAllErrors: options?.getAllErrors,\n errors: [],\n };\n\n const parsedValue = innerCheck(schema, receivedValue, ctx) as InferType<T>;\n\n if (ctx.getAllErrors && ctx.errors.length) {\n return [ctx.errors, undefined];\n }\n\n return [undefined, parsedValue];\n } catch (e) {\n if (e instanceof ValidationError) {\n delete e.stack;\n return [[e], undefined];\n }\n /* istanbul ignore next */\n return [\n [\n {\n message: 'Something unexpected happened',\n expected: '',\n received: '',\n pathToError: '',\n },\n ],\n undefined,\n ];\n }\n}\n"]}
@@ -0,0 +1,74 @@
1
+ import {
2
+ parseOrFail
3
+ } from "./chunk-ADSMWGDJ.mjs";
4
+ import {
5
+ ctxSymbol
6
+ } from "./chunk-5LLJ22IG.mjs";
7
+ import {
8
+ BuildSchemaError
9
+ } from "./chunk-NP64RC7B.mjs";
10
+
11
+ // src/schemas/CommonSchema.ts
12
+ var CommonSchema = class {
13
+ [ctxSymbol];
14
+ constructor(ctx) {
15
+ this[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[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[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[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[ctxSymbol];
53
+ if (ctx.isOptional) {
54
+ throw new BuildSchemaError(`Cannot call method 'default' after method 'optional'`);
55
+ }
56
+ try {
57
+ parseOrFail(this, defaultValue);
58
+ } catch (e) {
59
+ throw new BuildSchemaError(e.message);
60
+ }
61
+ this[ctxSymbol].defaultValue = defaultValue;
62
+ return this;
63
+ }
64
+ defaultValueCheck() {
65
+ if (this[ctxSymbol].defaultValue !== void 0) {
66
+ throw new BuildSchemaError("Default value must be the last method called in schema");
67
+ }
68
+ }
69
+ };
70
+
71
+ export {
72
+ CommonSchema
73
+ };
74
+ //# sourceMappingURL=chunk-AOUFWACR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/CommonSchema.ts"],"sourcesContent":["import { PrimitiveType, RequiredValidation } 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: PrimitiveType[];\n isNullable?: boolean;\n isOptional?: boolean;\n requiredValidations: RequiredValidation[];\n array?: CommonSchema;\n object?: ObjectShapeSchemaType;\n allowUnrecognizedObjectProps?: boolean;\n strictType?: boolean;\n strictTypeValue?: unknown;\n date?: boolean;\n defaultValue?: unknown;\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: unknown): 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 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\nexport type WithNull<T extends CommonSchema> = T & { validation_null: true };\nexport type WithUndefined<T extends CommonSchema> = T & { validation_undefined: true };\n\ntype TypeMapping = {\n number: number;\n string: string;\n boolean: boolean;\n undefined: undefined;\n object: object;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n function: Function;\n symbol: symbol;\n bigint: bigint;\n};\n\nexport type WithMix<Y = unknown> = CommonSchema & { validation_mix: Y };\nexport type ExtractFromMix<T> = T extends WithMix<infer X> ? X : never;\n\nexport type MapMixTypes<T extends PrimitiveType[]> = T extends (infer U)[]\n ? U extends keyof TypeMapping\n ? TypeMapping[U]\n : never\n : never;\n"],"mappings":";;;;;;;;;;;AAqBO,IAAM,eAAN,MAAmB;AAAA,EACxB,CAAC,SAAS;AAAA,EACV,YAAY,KAAuB;AACjC,SAAK,SAAS,IAAI;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,UAAU,YAAwC;AACvD,SAAK,kBAAkB;AACvB,SAAK,SAAS,EAAE,oBAAoB,KAAK,GAAG,UAAU;AACtD,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,WAA2B;AAChC,SAAK,kBAAkB;AACvB,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,WAAgC;AACrC,SAAK,kBAAkB;AACvB,SAAK,SAAS,EAAE,aAAa;AAC7B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,QAAQ,cAA6B;AAC1C,UAAM,MAAM,KAAK,SAAS;AAC1B,QAAI,IAAI,YAAY;AAClB,YAAM,IAAI,iBAAiB,sDAAsD;AAAA,IACnF;AAEA,QAAI;AACF,kBAAY,MAAM,YAAY;AAAA,IAChC,SAAS,GAAG;AACV,YAAM,IAAI,iBAAkB,EAAY,OAAO;AAAA,IACjD;AAEA,SAAK,SAAS,EAAE,eAAe;AAC/B,WAAO;AAAA,EACT;AAAA,EAEU,oBAAoB;AAC5B,QAAI,KAAK,SAAS,EAAE,iBAAiB,QAAW;AAC9C,YAAM,IAAI,iBAAiB,wDAAwD;AAAA,IACrF;AAAA,EACF;AACF;","names":[]}
@@ -17,8 +17,7 @@ var BuildSchemaError = class extends Error {
17
17
  function replacePlaceholders(template, replacements) {
18
18
  const regex = /{{(.*?)}}/g;
19
19
  return template.replace(regex, (_, key) => {
20
- const vvv = key in replacements ? `${replacements[key]}` : `{{${key}}}`;
21
- return vvv;
20
+ return key in replacements ? `${replacements[key]}` : `{{${key}}}`;
22
21
  });
23
22
  }
24
23
  function guardException(expected, received, ctx, messageKey) {
@@ -41,4 +40,4 @@ function guardException(expected, received, ctx, messageKey) {
41
40
 
42
41
 
43
42
  exports.ValidationError = ValidationError; exports.BuildSchemaError = BuildSchemaError; exports.guardException = guardException;
44
- //# sourceMappingURL=chunk-WK4O3HH4.js.map
43
+ //# sourceMappingURL=chunk-AY7HKAG2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-AY7HKAG2.js","../src/exceptions.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,gBAAA,EAAN,MAAA,QAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAA,CAAY,QAAA,EAAmB,QAAA,EAAmB,WAAA,EAAqB,OAAA,EAAiB;AACtF,IAAA,KAAA,CAAM,CAAA;AACN,IAAA,IAAA,CAAK,SAAA,EAAW,QAAA;AAChB,IAAA,IAAA,CAAK,SAAA,EAAW,QAAA;AAChB,IAAA,IAAA,CAAK,YAAA,EAAc,WAAA;AACnB,IAAA,IAAA,CAAK,QAAA,EAAU,OAAA;AAAA,EACjB;AACF,CAAA;AAEO,IAAM,iBAAA,EAAN,MAAA,QAA+B,MAAM;AAAC,CAAA;AAE7C,SAAS,mBAAA,CAAoB,QAAA,EAAkB,YAAA,EAA+C;AAC5F,EAAA,MAAM,MAAA,EAAQ,YAAA;AACd,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,KAAA,EAAO,CAAC,CAAA,EAAG,GAAA,EAAA,GAAQ;AACzC,IAAA,OAAO,IAAA,GAAO,aAAA,EAAe,CAAA,EAAA;AAC9B,EAAA;AACH;AAIE;AAIyB,EAAA;AACT,EAAA;AAEM,EAAA;AACJ,IAAA;AACd,MAAA;AACA,MAAA;AACiB,MAAA;AACjB,MAAA;AACD,IAAA;AAED,IAAA;AACF,EAAA;AAC0B,EAAA;AAC5B;ADTkC;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/bguard/bguard/lib/chunk-AY7HKAG2.js","sourcesContent":[null,"import type { ExceptionContext } from './commonTypes';\n\nexport class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nfunction replacePlaceholders(template: string, replacements: Record<string, unknown>): string {\n const regex = /{{(.*?)}}/g;\n return template.replace(regex, (_, key) => {\n return key in replacements ? `${replacements[key] as string}` : `{{${key}}}`;\n });\n}\n\nexport function guardException(\n expected: unknown,\n received: unknown,\n ctx: ExceptionContext,\n messageKey: string,\n): never | void {\n const rawMessage = ctx.t[messageKey] ?? messageKey;\n const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: ctx.pathToError });\n\n if (ctx.getAllErrors) {\n ctx.errors.push({\n expected,\n received,\n pathToError: ctx.pathToError,\n message,\n });\n\n return;\n }\n throw new ValidationError(expected, received, ctx.pathToError, message);\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  setToDefaultLocale
3
- } from "./chunk-QV4JDW3T.mjs";
3
+ } from "./chunk-4GDBM5LP.mjs";
4
4
  import {
5
5
  guardException
6
- } from "./chunk-7XFLH6R2.mjs";
6
+ } from "./chunk-NP64RC7B.mjs";
7
7
 
8
8
  // src/asserts/mix/equalTo.ts
9
9
  var equalToErrorMessage = "The received value is not equal to expected";
@@ -18,4 +18,4 @@ setToDefaultLocale(equalTo);
18
18
  export {
19
19
  equalTo
20
20
  };
21
- //# sourceMappingURL=chunk-M6OCVAUD.mjs.map
21
+ //# sourceMappingURL=chunk-BUXOCPHI.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ctxSymbol
3
- } from "./chunk-XZTZC73V.mjs";
3
+ } from "./chunk-5LLJ22IG.mjs";
4
4
 
5
5
  // src/helpers/setStrictType.ts
6
6
  function _setStrictType(that, val) {
@@ -11,4 +11,4 @@ function _setStrictType(that, val) {
11
11
  export {
12
12
  _setStrictType
13
13
  };
14
- //# sourceMappingURL=chunk-54RHVQFA.mjs.map
14
+ //# sourceMappingURL=chunk-D42ISCFK.mjs.map
@@ -1,24 +1,24 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
2
 
3
- var _chunk4SPM2CSQjs = require('./chunk-4SPM2CSQ.js');
3
+ var _chunkSPWF5IFUjs = require('./chunk-SPWF5IFU.js');
4
4
 
5
5
 
6
- var _chunkWPHJ4QTBjs = require('./chunk-WPHJ4QTB.js');
6
+ var _chunkW2GOLG3Kjs = require('./chunk-W2GOLG3K.js');
7
7
 
8
8
 
9
9
  var _chunk42J6CHIOjs = require('./chunk-42J6CHIO.js');
10
10
 
11
11
 
12
- var _chunkLWAEUS2Fjs = require('./chunk-LWAEUS2F.js');
12
+ var _chunk3ZPLJ5KCjs = require('./chunk-3ZPLJ5KC.js');
13
13
 
14
14
 
15
- var _chunkEQNVYAKSjs = require('./chunk-EQNVYAKS.js');
15
+ var _chunk3IOQH3K4js = require('./chunk-3IOQH3K4.js');
16
16
 
17
17
 
18
- var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
18
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
19
19
 
20
20
  // src/schemas/NumberSchema.ts
21
- var NumberSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
21
+ var NumberSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {constructor(...args) { super(...args); _class.prototype.__init.call(this); }
22
22
  __init() {this._number = 1}
23
23
 
24
24
  /**
@@ -30,10 +30,10 @@ var NumberSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constr
30
30
  * @example - number().equalTo(42); // Infers the type 42
31
31
  */
32
32
  equalTo(expectedValue) {
33
- if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
33
+ if (this.limit) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
34
34
  this.limit = true;
35
- _chunkLWAEUS2Fjs._setStrictType.call(void 0, this, expectedValue);
36
- return this.custom(_chunkWPHJ4QTBjs.equalTo.call(void 0, expectedValue));
35
+ _chunk3ZPLJ5KCjs._setStrictType.call(void 0, this, expectedValue);
36
+ return this.custom(_chunkSPWF5IFUjs.equalTo.call(void 0, expectedValue));
37
37
  }
38
38
  /**
39
39
  * Restricts the schema to match one of the specified values and infers the union of those values as the TypeScript type.
@@ -45,14 +45,14 @@ var NumberSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {constr
45
45
  * number().oneOfValues([5, 7]); // Infers the type 5 | 7
46
46
  */
47
47
  oneOfValues(expectedValue) {
48
- if (this.limit) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
48
+ if (this.limit) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)(_chunk42J6CHIOjs.ONLY_ONCE);
49
49
  this.limit = true;
50
- _chunkLWAEUS2Fjs._setStrictType.call(void 0, this, expectedValue);
51
- return this.custom(_chunk4SPM2CSQjs.oneOfValues.call(void 0, expectedValue));
50
+ _chunk3ZPLJ5KCjs._setStrictType.call(void 0, this, expectedValue);
51
+ return this.custom(_chunkW2GOLG3Kjs.oneOfValues.call(void 0, expectedValue));
52
52
  }
53
53
  }, _class);
54
54
 
55
55
 
56
56
 
57
57
  exports.NumberSchema = NumberSchema;
58
- //# sourceMappingURL=chunk-5EIBKBYS.js.map
58
+ //# sourceMappingURL=chunk-EU3ZZF7Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-EU3ZZF7Y.js","../src/schemas/NumberSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACZO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBACnC,QAAA,EAAU,EAAA;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUD,OAAA,CAA0B,aAAA,EAAuC;AACtE,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,sCAAA,aAAqB,CAAC,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWO,WAAA,CAA8B,aAAA,EAAyC;AAC5E,IAAA,GAAA,CAAI,IAAA,CAAK,KAAA,EAAO,MAAM,IAAI,sCAAA,CAAiB,0BAAS,CAAA;AACpD,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAA;AACb,IAAA,6CAAA,IAAe,EAAM,aAAa,CAAA;AAClC,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,0CAAA,aAAyB,CAAC,CAAA;AAAA,EAC/C;AACF,UAAA;ADYA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-EU3ZZF7Y.js","sourcesContent":[null,"import { equalTo } from '../asserts/mix/equalTo';\nimport { oneOfValues } from '../asserts/mix/oneOfValues';\nimport { BuildSchemaError } from '../exceptions';\nimport { ONLY_ONCE } from '../helpers/constants';\nimport { _setStrictType } from '../helpers/setStrictType';\nimport { CommonSchema } from './CommonSchema';\n\nexport class NumberSchema extends CommonSchema {\n 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"]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  CommonSchema
3
- } from "./chunk-4UF67IQ2.mjs";
3
+ } from "./chunk-AOUFWACR.mjs";
4
4
  import {
5
5
  ctxSymbol
6
- } from "./chunk-XZTZC73V.mjs";
6
+ } from "./chunk-5LLJ22IG.mjs";
7
7
  import {
8
8
  BuildSchemaError
9
- } from "./chunk-7XFLH6R2.mjs";
9
+ } from "./chunk-NP64RC7B.mjs";
10
10
 
11
11
  // src/schemas/ArraySchema.ts
12
12
  var ArraySchema = class extends CommonSchema {
@@ -25,4 +25,4 @@ var ArraySchema = class extends CommonSchema {
25
25
  export {
26
26
  ArraySchema
27
27
  };
28
- //# sourceMappingURL=chunk-PEWNA24X.mjs.map
28
+ //# sourceMappingURL=chunk-KBZUNXJB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/ArraySchema.ts"],"sourcesContent":["import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class ArraySchema extends CommonSchema {\n protected _array = 1;\n constructor(ctx: ValidatorContext, arraySchema: CommonSchema) {\n super(ctx);\n this.validateArrayEntry(arraySchema);\n this[ctxSymbol].array = arraySchema;\n }\n\n private validateArrayEntry(arraySchema: CommonSchema) {\n if (!arraySchema) throw new BuildSchemaError('Missing schema in array method');\n if (!(arraySchema instanceof CommonSchema)) throw new BuildSchemaError('Invalid schema in array method');\n }\n}\n\nexport type WithArray<Y extends CommonSchema> = ArraySchema & { validation_array: Y };\nexport type ExtractFromArray<T> = T extends WithArray<infer X> ? X : never;\n"],"mappings":";;;;;;;;;;;AAIO,IAAM,cAAN,cAA0B,aAAa;AAAA,EAClC,SAAS;AAAA,EACnB,YAAY,KAAuB,aAA2B;AAC5D,UAAM,GAAG;AACT,SAAK,mBAAmB,WAAW;AACnC,SAAK,SAAS,EAAE,QAAQ;AAAA,EAC1B;AAAA,EAEQ,mBAAmB,aAA2B;AACpD,QAAI,CAAC,YAAa,OAAM,IAAI,iBAAiB,gCAAgC;AAC7E,QAAI,EAAE,uBAAuB,cAAe,OAAM,IAAI,iBAAiB,gCAAgC;AAAA,EACzG;AACF;","names":[]}
@@ -0,0 +1,28 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
+
3
+ var _chunk3IOQH3K4js = require('./chunk-3IOQH3K4.js');
4
+
5
+
6
+ var _chunkPIBDJJUUjs = require('./chunk-PIBDJJUU.js');
7
+
8
+
9
+ var _chunkAY7HKAG2js = require('./chunk-AY7HKAG2.js');
10
+
11
+ // src/schemas/ArraySchema.ts
12
+ var ArraySchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {
13
+ __init() {this._array = 1}
14
+ constructor(ctx, arraySchema) {
15
+ super(ctx);_class.prototype.__init.call(this);;
16
+ this.validateArrayEntry(arraySchema);
17
+ this[_chunkPIBDJJUUjs.ctxSymbol].array = arraySchema;
18
+ }
19
+ validateArrayEntry(arraySchema) {
20
+ if (!arraySchema) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)("Missing schema in array method");
21
+ if (!(arraySchema instanceof _chunk3IOQH3K4js.CommonSchema)) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)("Invalid schema in array method");
22
+ }
23
+ }, _class);
24
+
25
+
26
+
27
+ exports.ArraySchema = ArraySchema;
28
+ //# sourceMappingURL=chunk-LYNVPN3R.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-LYNVPN3R.js","../src/schemas/ArraySchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNO,IAAM,YAAA,YAAN,MAAA,QAA0B,8BAAa;AAAA,iBAClC,OAAA,EAAS,EAAA;AAAA,EACnB,WAAA,CAAY,GAAA,EAAuB,WAAA,EAA2B;AAC5D,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,kBAAA,CAAmB,WAAW,CAAA;AACnC,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,MAAA,EAAQ,WAAA;AAAA,EAC1B;AAAA,EAEQ,kBAAA,CAAmB,WAAA,EAA2B;AACpD,IAAA,GAAA,CAAI,CAAC,WAAA,EAAa,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAC7E,IAAA,GAAA,CAAI,CAAA,CAAE,YAAA,WAAuB,6BAAA,CAAA,EAAe,MAAM,IAAI,sCAAA,CAAiB,gCAAgC,CAAA;AAAA,EACzG;AACF,UAAA;ADOA;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-LYNVPN3R.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ValidatorContext } from './CommonSchema';\n\nexport class ArraySchema extends CommonSchema {\n protected _array = 1;\n constructor(ctx: ValidatorContext, arraySchema: CommonSchema) {\n super(ctx);\n this.validateArrayEntry(arraySchema);\n this[ctxSymbol].array = arraySchema;\n }\n\n private validateArrayEntry(arraySchema: CommonSchema) {\n if (!arraySchema) throw new BuildSchemaError('Missing schema in array method');\n if (!(arraySchema instanceof CommonSchema)) throw new BuildSchemaError('Invalid schema in array method');\n }\n}\n\nexport type WithArray<Y extends CommonSchema> = ArraySchema & { validation_array: Y };\nexport type ExtractFromArray<T> = T extends WithArray<infer X> ? X : never;\n"]}
@@ -17,8 +17,7 @@ var BuildSchemaError = class extends Error {
17
17
  function replacePlaceholders(template, replacements) {
18
18
  const regex = /{{(.*?)}}/g;
19
19
  return template.replace(regex, (_, key) => {
20
- const vvv = key in replacements ? `${replacements[key]}` : `{{${key}}}`;
21
- return vvv;
20
+ return key in replacements ? `${replacements[key]}` : `{{${key}}}`;
22
21
  });
23
22
  }
24
23
  function guardException(expected, received, ctx, messageKey) {
@@ -41,4 +40,4 @@ export {
41
40
  BuildSchemaError,
42
41
  guardException
43
42
  };
44
- //# sourceMappingURL=chunk-7XFLH6R2.mjs.map
43
+ //# sourceMappingURL=chunk-NP64RC7B.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/exceptions.ts"],"sourcesContent":["import type { ExceptionContext } from './commonTypes';\n\nexport class ValidationError extends Error {\n expected: unknown;\n received: unknown;\n pathToError: string;\n message: string;\n constructor(expected: unknown, received: unknown, pathToError: string, message: string) {\n super();\n this.expected = expected;\n this.received = received;\n this.pathToError = pathToError;\n this.message = message;\n }\n}\n\nexport class BuildSchemaError extends Error {}\n\nfunction replacePlaceholders(template: string, replacements: Record<string, unknown>): string {\n const regex = /{{(.*?)}}/g;\n return template.replace(regex, (_, key) => {\n return key in replacements ? `${replacements[key] as string}` : `{{${key}}}`;\n });\n}\n\nexport function guardException(\n expected: unknown,\n received: unknown,\n ctx: ExceptionContext,\n messageKey: string,\n): never | void {\n const rawMessage = ctx.t[messageKey] ?? messageKey;\n const message = replacePlaceholders(rawMessage, { e: expected, r: received, p: ctx.pathToError });\n\n if (ctx.getAllErrors) {\n ctx.errors.push({\n expected,\n received,\n pathToError: ctx.pathToError,\n message,\n });\n\n return;\n }\n throw new ValidationError(expected, received, ctx.pathToError, message);\n}\n"],"mappings":";AAEO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,UAAmB,UAAmB,aAAqB,SAAiB;AACtF,UAAM;AACN,SAAK,WAAW;AAChB,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,UAAU;AAAA,EACjB;AACF;AAEO,IAAM,mBAAN,cAA+B,MAAM;AAAC;AAE7C,SAAS,oBAAoB,UAAkB,cAA+C;AAC5F,QAAM,QAAQ;AACd,SAAO,SAAS,QAAQ,OAAO,CAAC,GAAG,QAAQ;AACzC,WAAO,OAAO,eAAe,GAAG,aAAa,GAAG,CAAW,KAAK,KAAK,GAAG;AAAA,EAC1E,CAAC;AACH;AAEO,SAAS,eACd,UACA,UACA,KACA,YACc;AACd,QAAM,aAAa,IAAI,EAAE,UAAU,KAAK;AACxC,QAAM,UAAU,oBAAoB,YAAY,EAAE,GAAG,UAAU,GAAG,UAAU,GAAG,IAAI,YAAY,CAAC;AAEhG,MAAI,IAAI,cAAc;AACpB,QAAI,OAAO,KAAK;AAAA,MACd;AAAA,MACA;AAAA,MACA,aAAa,IAAI;AAAA,MACjB;AAAA,IACF,CAAC;AAED;AAAA,EACF;AACA,QAAM,IAAI,gBAAgB,UAAU,UAAU,IAAI,aAAa,OAAO;AACxE;","names":[]}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  setToDefaultLocale
3
- } from "./chunk-QV4JDW3T.mjs";
3
+ } from "./chunk-4GDBM5LP.mjs";
4
4
  import {
5
5
  guardException
6
- } from "./chunk-7XFLH6R2.mjs";
6
+ } from "./chunk-NP64RC7B.mjs";
7
7
 
8
8
  // src/asserts/mix/oneOfValues.ts
9
9
  var oneOfValuesErrorMessage = "The received value is not equal to expected";
@@ -18,4 +18,4 @@ setToDefaultLocale(oneOfValues);
18
18
  export {
19
19
  oneOfValues
20
20
  };
21
- //# sourceMappingURL=chunk-YPAUFM3S.mjs.map
21
+ //# sourceMappingURL=chunk-OHEMRF7Y.mjs.map
@@ -1,20 +1,20 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
2
 
3
- var _chunkEQNVYAKSjs = require('./chunk-EQNVYAKS.js');
3
+ var _chunk3IOQH3K4js = require('./chunk-3IOQH3K4.js');
4
4
 
5
5
 
6
- var _chunk7GIRQ5EAjs = require('./chunk-7GIRQ5EA.js');
6
+ var _chunkPIBDJJUUjs = require('./chunk-PIBDJJUU.js');
7
7
 
8
8
  // src/schemas/DateSchema.ts
9
- var DateSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {
9
+ var DateSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {
10
10
  __init() {this._date = 1}
11
11
  constructor(ctx) {
12
12
  super(ctx);_class.prototype.__init.call(this);;
13
- this[_chunk7GIRQ5EAjs.ctxSymbol].date = true;
13
+ this[_chunkPIBDJJUUjs.ctxSymbol].date = true;
14
14
  }
15
15
  }, _class);
16
16
 
17
17
 
18
18
 
19
19
  exports.DateSchema = DateSchema;
20
- //# sourceMappingURL=chunk-QLVLZRHT.js.map
20
+ //# sourceMappingURL=chunk-OJSTQQ3N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-OJSTQQ3N.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-OJSTQQ3N.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"]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  innerCheck
3
- } from "./chunk-XZTZC73V.mjs";
3
+ } from "./chunk-5LLJ22IG.mjs";
4
4
  import {
5
5
  getTranslationByLocale
6
- } from "./chunk-QV4JDW3T.mjs";
6
+ } from "./chunk-4GDBM5LP.mjs";
7
7
  import {
8
8
  ValidationError
9
- } from "./chunk-7XFLH6R2.mjs";
9
+ } from "./chunk-NP64RC7B.mjs";
10
10
 
11
11
  // src/parse.ts
12
12
  function parse(schema, receivedValue, options) {
@@ -44,4 +44,4 @@ function parse(schema, receivedValue, options) {
44
44
  export {
45
45
  parse
46
46
  };
47
- //# sourceMappingURL=chunk-5AO66YV5.mjs.map
47
+ //# sourceMappingURL=chunk-OKF3BVUD.mjs.map
@@ -1,27 +1,27 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
2
 
3
- var _chunkEQNVYAKSjs = require('./chunk-EQNVYAKS.js');
3
+ var _chunk3IOQH3K4js = require('./chunk-3IOQH3K4.js');
4
4
 
5
5
 
6
- var _chunk7GIRQ5EAjs = require('./chunk-7GIRQ5EA.js');
6
+ var _chunkPIBDJJUUjs = require('./chunk-PIBDJJUU.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/ObjectSchema.ts
12
- var ObjectSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {
12
+ var ObjectSchema = (_class = class extends _chunk3IOQH3K4js.CommonSchema {
13
13
  __init() {this._object = 1}
14
14
  constructor(ctx, shapeSchema) {
15
15
  super(ctx);_class.prototype.__init.call(this);;
16
16
  this.validateObjectEntry(shapeSchema);
17
- this[_chunk7GIRQ5EAjs.ctxSymbol].object = shapeSchema;
17
+ this[_chunkPIBDJJUUjs.ctxSymbol].object = shapeSchema;
18
18
  }
19
19
  validateObjectEntry(shapeSchema) {
20
- if (!shapeSchema) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Missing schema in object method");
21
- if (shapeSchema instanceof _chunkEQNVYAKSjs.CommonSchema) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Invalid schema in object");
20
+ if (!shapeSchema) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)("Missing schema in object method");
21
+ if (shapeSchema instanceof _chunk3IOQH3K4js.CommonSchema) throw new (0, _chunkAY7HKAG2js.BuildSchemaError)("Invalid schema in object");
22
22
  for (const [key, value] of Object.entries(shapeSchema)) {
23
- if (!(value instanceof _chunkEQNVYAKSjs.CommonSchema))
24
- throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(`Invalid schema in object method for property '${key}'`);
23
+ if (!(value instanceof _chunk3IOQH3K4js.CommonSchema))
24
+ throw new (0, _chunkAY7HKAG2js.BuildSchemaError)(`Invalid schema in object method for property '${key}'`);
25
25
  }
26
26
  }
27
27
  /**
@@ -42,7 +42,7 @@ var ObjectSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {
42
42
  * // No error thrown
43
43
  */
44
44
  allowUnrecognized() {
45
- this[_chunk7GIRQ5EAjs.ctxSymbol].allowUnrecognizedObjectProps = true;
45
+ this[_chunkPIBDJJUUjs.ctxSymbol].allowUnrecognizedObjectProps = true;
46
46
  return this;
47
47
  }
48
48
  }, _class);
@@ -50,4 +50,4 @@ var ObjectSchema = (_class = class extends _chunkEQNVYAKSjs.CommonSchema {
50
50
 
51
51
 
52
52
  exports.ObjectSchema = ObjectSchema;
53
- //# sourceMappingURL=chunk-N6YMNLXG.js.map
53
+ //# sourceMappingURL=chunk-OO6BTBVP.js.map
@@ -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"]}