bguard 0.0.8 → 0.1.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 (318) hide show
  1. package/README.md +507 -23
  2. package/lib/{CommonSchema-BIe85W_A.d.mts → CommonSchema-BbGNki0L.d.ts} +7 -4
  3. package/lib/{CommonSchema-BIe85W_A.d.ts → CommonSchema-CjsYE4dC.d.mts} +7 -4
  4. package/lib/InferType.d.mts +2 -1
  5. package/lib/InferType.d.ts +2 -1
  6. package/lib/asserts/array/index.d.mts +4 -3
  7. package/lib/asserts/array/index.d.ts +4 -3
  8. package/lib/asserts/array/index.js +6 -6
  9. package/lib/asserts/array/index.mjs +5 -5
  10. package/lib/asserts/boolean/index.d.mts +4 -3
  11. package/lib/asserts/boolean/index.d.ts +4 -3
  12. package/lib/asserts/boolean/index.js +7 -6
  13. package/lib/asserts/boolean/index.js.map +1 -1
  14. package/lib/asserts/boolean/index.mjs +6 -5
  15. package/lib/asserts/mix/equalTo.d.mts +22 -0
  16. package/lib/asserts/mix/equalTo.d.ts +22 -0
  17. package/lib/asserts/mix/equalTo.js +9 -0
  18. package/lib/asserts/mix/equalTo.js.map +1 -0
  19. package/lib/asserts/mix/equalTo.mjs +9 -0
  20. package/lib/asserts/{common → mix}/index.d.mts +5 -4
  21. package/lib/asserts/{common → mix}/index.d.ts +5 -4
  22. package/lib/asserts/mix/index.js +10 -0
  23. package/lib/asserts/mix/index.js.map +1 -0
  24. package/lib/asserts/mix/index.mjs +10 -0
  25. package/lib/asserts/mix/oneOfValues.d.mts +23 -0
  26. package/lib/asserts/mix/oneOfValues.d.ts +23 -0
  27. package/lib/asserts/mix/oneOfValues.js +9 -0
  28. package/lib/asserts/mix/oneOfValues.js.map +1 -0
  29. package/lib/asserts/mix/oneOfValues.mjs +9 -0
  30. package/lib/asserts/number/index.d.mts +4 -3
  31. package/lib/asserts/number/index.d.ts +4 -3
  32. package/lib/asserts/number/index.js +10 -7
  33. package/lib/asserts/number/index.js.map +1 -1
  34. package/lib/asserts/number/index.mjs +9 -6
  35. package/lib/asserts/number/max.d.mts +15 -10
  36. package/lib/asserts/number/max.d.ts +15 -10
  37. package/lib/asserts/number/max.js +11 -4
  38. package/lib/asserts/number/max.js.map +1 -1
  39. package/lib/asserts/number/max.mjs +12 -5
  40. package/lib/asserts/number/max.mjs.map +1 -1
  41. package/lib/asserts/number/maxExcluded.d.mts +14 -9
  42. package/lib/asserts/number/maxExcluded.d.ts +14 -9
  43. package/lib/asserts/number/maxExcluded.js +11 -4
  44. package/lib/asserts/number/maxExcluded.js.map +1 -1
  45. package/lib/asserts/number/maxExcluded.mjs +12 -5
  46. package/lib/asserts/number/maxExcluded.mjs.map +1 -1
  47. package/lib/asserts/number/min.d.mts +15 -10
  48. package/lib/asserts/number/min.d.ts +15 -10
  49. package/lib/asserts/number/min.js +11 -4
  50. package/lib/asserts/number/min.js.map +1 -1
  51. package/lib/asserts/number/min.mjs +12 -5
  52. package/lib/asserts/number/min.mjs.map +1 -1
  53. package/lib/asserts/number/minExcluded.d.mts +15 -10
  54. package/lib/asserts/number/minExcluded.d.ts +15 -10
  55. package/lib/asserts/number/minExcluded.js +11 -4
  56. package/lib/asserts/number/minExcluded.js.map +1 -1
  57. package/lib/asserts/number/minExcluded.mjs +12 -5
  58. package/lib/asserts/number/minExcluded.mjs.map +1 -1
  59. package/lib/asserts/number/negative.d.mts +14 -9
  60. package/lib/asserts/number/negative.d.ts +14 -9
  61. package/lib/asserts/number/negative.js +11 -3
  62. package/lib/asserts/number/negative.js.map +1 -1
  63. package/lib/asserts/number/negative.mjs +12 -4
  64. package/lib/asserts/number/negative.mjs.map +1 -1
  65. package/lib/asserts/number/positive.d.mts +14 -9
  66. package/lib/asserts/number/positive.d.ts +14 -9
  67. package/lib/asserts/number/positive.js +11 -3
  68. package/lib/asserts/number/positive.js.map +1 -1
  69. package/lib/asserts/number/positive.mjs +12 -4
  70. package/lib/asserts/number/positive.mjs.map +1 -1
  71. package/lib/asserts/object/index.d.mts +4 -3
  72. package/lib/asserts/object/index.d.ts +4 -3
  73. package/lib/asserts/object/index.js +6 -6
  74. package/lib/asserts/object/index.mjs +5 -5
  75. package/lib/asserts/string/email.d.mts +13 -9
  76. package/lib/asserts/string/email.d.ts +13 -9
  77. package/lib/asserts/string/email.js +11 -4
  78. package/lib/asserts/string/email.js.map +1 -1
  79. package/lib/asserts/string/email.mjs +12 -5
  80. package/lib/asserts/string/email.mjs.map +1 -1
  81. package/lib/asserts/string/index.d.mts +4 -3
  82. package/lib/asserts/string/index.d.ts +4 -3
  83. package/lib/asserts/string/index.js +10 -7
  84. package/lib/asserts/string/index.js.map +1 -1
  85. package/lib/asserts/string/index.mjs +9 -6
  86. package/lib/asserts/string/maxLength.d.mts +14 -9
  87. package/lib/asserts/string/maxLength.d.ts +14 -9
  88. package/lib/asserts/string/maxLength.js +11 -4
  89. package/lib/asserts/string/maxLength.js.map +1 -1
  90. package/lib/asserts/string/maxLength.mjs +12 -5
  91. package/lib/asserts/string/maxLength.mjs.map +1 -1
  92. package/lib/asserts/string/minLength.d.mts +14 -9
  93. package/lib/asserts/string/minLength.d.ts +14 -9
  94. package/lib/asserts/string/minLength.js +11 -4
  95. package/lib/asserts/string/minLength.js.map +1 -1
  96. package/lib/asserts/string/minLength.mjs +12 -5
  97. package/lib/asserts/string/minLength.mjs.map +1 -1
  98. package/lib/asserts/string/regExp.d.mts +14 -9
  99. package/lib/asserts/string/regExp.d.ts +14 -9
  100. package/lib/asserts/string/regExp.js +11 -4
  101. package/lib/asserts/string/regExp.js.map +1 -1
  102. package/lib/asserts/string/regExp.mjs +12 -5
  103. package/lib/asserts/string/regExp.mjs.map +1 -1
  104. package/lib/{chunk-32IQXZRK.mjs → chunk-2PM3K3OE.mjs} +2 -2
  105. package/lib/{chunk-32IQXZRK.mjs.map → chunk-2PM3K3OE.mjs.map} +1 -1
  106. package/lib/chunk-3HTYHE2X.mjs +54 -0
  107. package/lib/chunk-3HTYHE2X.mjs.map +1 -0
  108. package/lib/chunk-3O4WCRC2.mjs +21 -0
  109. package/lib/chunk-3O4WCRC2.mjs.map +1 -0
  110. package/lib/chunk-4CYIMDP2.js +21 -0
  111. package/lib/chunk-4CYIMDP2.js.map +1 -0
  112. package/lib/{chunk-QKGQ4XZC.js → chunk-4RNK3I74.js} +3 -3
  113. package/lib/{chunk-QKGQ4XZC.js.map → chunk-4RNK3I74.js.map} +1 -1
  114. package/lib/chunk-5BVJ6YMH.js +54 -0
  115. package/lib/chunk-5BVJ6YMH.js.map +1 -0
  116. package/lib/chunk-6TH3DBDK.js +53 -0
  117. package/lib/chunk-6TH3DBDK.js.map +1 -0
  118. package/lib/chunk-7XFLH6R2.mjs +44 -0
  119. package/lib/chunk-7XFLH6R2.mjs.map +1 -0
  120. package/lib/{chunk-BGMR7A6X.mjs → chunk-B6TFELXR.mjs} +2 -2
  121. package/lib/{chunk-BGMR7A6X.mjs.map → chunk-B6TFELXR.mjs.map} +1 -1
  122. package/lib/{chunk-GEZME6V2.mjs → chunk-CCBCDJXS.mjs} +11 -6
  123. package/lib/chunk-CCBCDJXS.mjs.map +1 -0
  124. package/lib/chunk-CLG3QRZC.mjs +47 -0
  125. package/lib/chunk-CLG3QRZC.mjs.map +1 -0
  126. package/lib/chunk-DJSLA2ZV.js +27 -0
  127. package/lib/chunk-DJSLA2ZV.js.map +1 -0
  128. package/lib/{chunk-L7HUXYFV.mjs → chunk-DPBE7TAQ.mjs} +2 -2
  129. package/lib/chunk-DPBE7TAQ.mjs.map +1 -0
  130. package/lib/{chunk-APTTIN2L.js → chunk-EGEHSELT.js} +6 -6
  131. package/lib/chunk-EGEHSELT.js.map +1 -0
  132. package/lib/chunk-F5MSBL33.js +50 -0
  133. package/lib/chunk-F5MSBL33.js.map +1 -0
  134. package/lib/chunk-FTLRX2XG.mjs +50 -0
  135. package/lib/chunk-FTLRX2XG.mjs.map +1 -0
  136. package/lib/chunk-H7CPKW53.js +47 -0
  137. package/lib/chunk-H7CPKW53.js.map +1 -0
  138. package/lib/{chunk-A7I2JEQO.js → chunk-HDSGCAHH.js} +3 -3
  139. package/lib/{chunk-A7I2JEQO.js.map → chunk-HDSGCAHH.js.map} +1 -1
  140. package/lib/{chunk-L6A7NXUJ.js → chunk-IEUXIOL6.js} +3 -3
  141. package/lib/{chunk-L6A7NXUJ.js.map → chunk-IEUXIOL6.js.map} +1 -1
  142. package/lib/chunk-IRG4OQAB.js +63 -0
  143. package/lib/chunk-IRG4OQAB.js.map +1 -0
  144. package/lib/chunk-J4VKFJQK.js +21 -0
  145. package/lib/chunk-J4VKFJQK.js.map +1 -0
  146. package/lib/{chunk-A2SAWKJA.mjs → chunk-JDGZCBXF.mjs} +2 -2
  147. package/lib/{chunk-A2SAWKJA.mjs.map → chunk-JDGZCBXF.mjs.map} +1 -1
  148. package/lib/chunk-JSGZ7DKT.js +14 -0
  149. package/lib/chunk-JSGZ7DKT.js.map +1 -0
  150. package/lib/{chunk-AJ4WV5DG.mjs → chunk-MRISXZQ4.mjs} +3 -3
  151. package/lib/chunk-MRISXZQ4.mjs.map +1 -0
  152. package/lib/{chunk-A3UTB4RE.mjs → chunk-NDQM5OL4.mjs} +4 -4
  153. package/lib/chunk-NDQM5OL4.mjs.map +1 -0
  154. package/lib/chunk-NNFYXHLU.mjs +21 -0
  155. package/lib/chunk-NNFYXHLU.mjs.map +1 -0
  156. package/lib/{chunk-KCBOOOTF.mjs → chunk-NTC2XQ36.mjs} +2 -2
  157. package/lib/{chunk-KCBOOOTF.mjs.map → chunk-NTC2XQ36.mjs.map} +1 -1
  158. package/lib/chunk-PG2R7P7G.mjs +27 -0
  159. package/lib/chunk-PG2R7P7G.mjs.map +1 -0
  160. package/lib/chunk-PH2PMUZP.mjs +63 -0
  161. package/lib/chunk-PH2PMUZP.mjs.map +1 -0
  162. package/lib/chunk-QQNQ4IDN.js +13 -0
  163. package/lib/chunk-QQNQ4IDN.js.map +1 -0
  164. package/lib/{chunk-PJP63SJT.js → chunk-RL4MSI7R.js} +3 -3
  165. package/lib/{chunk-PJP63SJT.js.map → chunk-RL4MSI7R.js.map} +1 -1
  166. package/lib/chunk-RQH4LXBW.js +47 -0
  167. package/lib/chunk-RQH4LXBW.js.map +1 -0
  168. package/lib/chunk-RRQOET3X.js +28 -0
  169. package/lib/chunk-RRQOET3X.js.map +1 -0
  170. package/lib/chunk-RYVUYVEE.mjs +14 -0
  171. package/lib/chunk-RYVUYVEE.mjs.map +1 -0
  172. package/lib/{chunk-QYLH5ZAC.mjs → chunk-TCQY2R3U.mjs} +25 -4
  173. package/lib/chunk-TCQY2R3U.mjs.map +1 -0
  174. package/lib/{chunk-K2S3FS5K.js → chunk-VHEA4JZ5.js} +3 -3
  175. package/lib/{chunk-K2S3FS5K.js.map → chunk-VHEA4JZ5.js.map} +1 -1
  176. package/lib/{chunk-VPFIIM2X.js → chunk-WBERBAL4.js} +11 -6
  177. package/lib/chunk-WBERBAL4.js.map +1 -0
  178. package/lib/chunk-WK4O3HH4.js +44 -0
  179. package/lib/chunk-WK4O3HH4.js.map +1 -0
  180. package/lib/{chunk-3FEJUC3K.mjs → chunk-YML32TPA.mjs} +2 -2
  181. package/lib/{chunk-3FEJUC3K.mjs.map → chunk-YML32TPA.mjs.map} +1 -1
  182. package/lib/chunk-YUESB2WV.mjs +47 -0
  183. package/lib/chunk-YUESB2WV.mjs.map +1 -0
  184. package/lib/codeGen.d.mts +7 -0
  185. package/lib/codeGen.d.ts +7 -0
  186. package/lib/codeGen.js +51 -0
  187. package/lib/codeGen.js.map +1 -0
  188. package/lib/codeGen.mjs +51 -0
  189. package/lib/codeGen.mjs.map +1 -0
  190. package/lib/commonTypes.d.mts +31 -0
  191. package/lib/commonTypes.d.ts +31 -0
  192. package/lib/commonTypes.js +1 -0
  193. package/lib/commonTypes.js.map +1 -0
  194. package/lib/commonTypes.mjs +1 -0
  195. package/lib/exceptions.d.mts +4 -2
  196. package/lib/exceptions.d.ts +4 -2
  197. package/lib/exceptions.js +2 -2
  198. package/lib/exceptions.mjs +3 -3
  199. package/lib/helpers/core.d.mts +2 -0
  200. package/lib/helpers/core.d.ts +2 -0
  201. package/lib/helpers/core.js +10 -0
  202. package/lib/helpers/core.js.map +1 -0
  203. package/lib/helpers/core.mjs +10 -0
  204. package/lib/helpers/core.mjs.map +1 -0
  205. package/lib/helpers/setStrictType.d.mts +6 -0
  206. package/lib/helpers/setStrictType.d.ts +6 -0
  207. package/lib/helpers/setStrictType.js +9 -0
  208. package/lib/helpers/setStrictType.js.map +1 -0
  209. package/lib/helpers/setStrictType.mjs +9 -0
  210. package/lib/helpers/setStrictType.mjs.map +1 -0
  211. package/lib/index.d.mts +7 -4
  212. package/lib/index.d.ts +7 -4
  213. package/lib/index.js +31 -17
  214. package/lib/index.js.map +1 -1
  215. package/lib/index.mjs +38 -24
  216. package/lib/parse.d.mts +66 -0
  217. package/lib/parse.d.ts +66 -0
  218. package/lib/parse.js +10 -0
  219. package/lib/parse.js.map +1 -0
  220. package/lib/parse.mjs +10 -0
  221. package/lib/parse.mjs.map +1 -0
  222. package/lib/{parseSchema.d.mts → parseOrFail.d.mts} +16 -5
  223. package/lib/{parseSchema.d.ts → parseOrFail.d.ts} +16 -5
  224. package/lib/parseOrFail.js +10 -0
  225. package/lib/parseOrFail.js.map +1 -0
  226. package/lib/parseOrFail.mjs +10 -0
  227. package/lib/parseOrFail.mjs.map +1 -0
  228. package/lib/schemas/ArraySchema.d.mts +2 -1
  229. package/lib/schemas/ArraySchema.d.ts +2 -1
  230. package/lib/schemas/ArraySchema.js +5 -5
  231. package/lib/schemas/ArraySchema.mjs +4 -4
  232. package/lib/schemas/BooleanSchema.d.mts +2 -1
  233. package/lib/schemas/BooleanSchema.d.ts +2 -1
  234. package/lib/schemas/BooleanSchema.js +6 -5
  235. package/lib/schemas/BooleanSchema.js.map +1 -1
  236. package/lib/schemas/BooleanSchema.mjs +5 -4
  237. package/lib/schemas/CommonSchema.d.mts +2 -1
  238. package/lib/schemas/CommonSchema.d.ts +2 -1
  239. package/lib/schemas/CommonSchema.js +4 -4
  240. package/lib/schemas/CommonSchema.mjs +3 -3
  241. package/lib/schemas/NumberSchema.d.mts +12 -1
  242. package/lib/schemas/NumberSchema.d.ts +12 -1
  243. package/lib/schemas/NumberSchema.js +9 -6
  244. package/lib/schemas/NumberSchema.js.map +1 -1
  245. package/lib/schemas/NumberSchema.mjs +8 -5
  246. package/lib/schemas/ObjectSchema.d.mts +20 -1
  247. package/lib/schemas/ObjectSchema.d.ts +20 -1
  248. package/lib/schemas/ObjectSchema.js +5 -5
  249. package/lib/schemas/ObjectSchema.mjs +4 -4
  250. package/lib/schemas/StringSchema.d.mts +12 -1
  251. package/lib/schemas/StringSchema.d.ts +12 -1
  252. package/lib/schemas/StringSchema.js +9 -6
  253. package/lib/schemas/StringSchema.js.map +1 -1
  254. package/lib/schemas/StringSchema.mjs +8 -5
  255. package/lib/translationMap.d.mts +12 -0
  256. package/lib/translationMap.d.ts +12 -0
  257. package/lib/translationMap.js +14 -0
  258. package/lib/translationMap.js.map +1 -0
  259. package/lib/translationMap.mjs +14 -0
  260. package/lib/translationMap.mjs.map +1 -0
  261. package/package.json +35 -18
  262. package/lib/asserts/common/equalTo.d.mts +0 -29
  263. package/lib/asserts/common/equalTo.d.ts +0 -29
  264. package/lib/asserts/common/equalTo.js +0 -8
  265. package/lib/asserts/common/equalTo.js.map +0 -1
  266. package/lib/asserts/common/equalTo.mjs +0 -8
  267. package/lib/asserts/common/index.js +0 -10
  268. package/lib/asserts/common/index.js.map +0 -1
  269. package/lib/asserts/common/index.mjs +0 -10
  270. package/lib/chunk-2AP4OQMT.js +0 -26
  271. package/lib/chunk-2AP4OQMT.js.map +0 -1
  272. package/lib/chunk-5NCJN6D2.js +0 -70
  273. package/lib/chunk-5NCJN6D2.js.map +0 -1
  274. package/lib/chunk-5ZMICHV3.js +0 -21
  275. package/lib/chunk-5ZMICHV3.js.map +0 -1
  276. package/lib/chunk-63IQFNFO.mjs +0 -27
  277. package/lib/chunk-63IQFNFO.mjs.map +0 -1
  278. package/lib/chunk-A3UTB4RE.mjs.map +0 -1
  279. package/lib/chunk-AJ4WV5DG.mjs.map +0 -1
  280. package/lib/chunk-APTTIN2L.js.map +0 -1
  281. package/lib/chunk-AXOP6HPJ.js +0 -14
  282. package/lib/chunk-AXOP6HPJ.js.map +0 -1
  283. package/lib/chunk-FCFO5J5Y.mjs +0 -14
  284. package/lib/chunk-FCFO5J5Y.mjs.map +0 -1
  285. package/lib/chunk-GEZME6V2.mjs.map +0 -1
  286. package/lib/chunk-GNBSKTFV.js +0 -27
  287. package/lib/chunk-GNBSKTFV.js.map +0 -1
  288. package/lib/chunk-IQ3QYABE.js +0 -32
  289. package/lib/chunk-IQ3QYABE.js.map +0 -1
  290. package/lib/chunk-L7HUXYFV.mjs.map +0 -1
  291. package/lib/chunk-LHTJHMKJ.mjs +0 -27
  292. package/lib/chunk-LHTJHMKJ.mjs.map +0 -1
  293. package/lib/chunk-NOADI6PO.mjs +0 -21
  294. package/lib/chunk-NOADI6PO.mjs.map +0 -1
  295. package/lib/chunk-NWY33MFU.js +0 -13
  296. package/lib/chunk-NWY33MFU.js.map +0 -1
  297. package/lib/chunk-P3Y6IWFA.mjs +0 -70
  298. package/lib/chunk-P3Y6IWFA.mjs.map +0 -1
  299. package/lib/chunk-PDVXBE27.js +0 -27
  300. package/lib/chunk-PDVXBE27.js.map +0 -1
  301. package/lib/chunk-QJOXKH7A.mjs +0 -26
  302. package/lib/chunk-QJOXKH7A.mjs.map +0 -1
  303. package/lib/chunk-QYLH5ZAC.mjs.map +0 -1
  304. package/lib/chunk-VPFIIM2X.js.map +0 -1
  305. package/lib/chunk-YXHH5BF6.js +0 -28
  306. package/lib/chunk-YXHH5BF6.js.map +0 -1
  307. package/lib/core.d.mts +0 -1
  308. package/lib/core.d.ts +0 -1
  309. package/lib/core.js +0 -10
  310. package/lib/core.js.map +0 -1
  311. package/lib/core.mjs +0 -10
  312. package/lib/parseSchema.js +0 -9
  313. package/lib/parseSchema.js.map +0 -1
  314. package/lib/parseSchema.mjs +0 -9
  315. /package/lib/asserts/{common → mix}/equalTo.mjs.map +0 -0
  316. /package/lib/asserts/{common → mix}/index.mjs.map +0 -0
  317. /package/lib/{core.mjs.map → asserts/mix/oneOfValues.mjs.map} +0 -0
  318. /package/lib/{parseSchema.mjs.map → commonTypes.mjs.map} +0 -0
@@ -1,16 +1,21 @@
1
- import { R as RequiredValidation } from '../../CommonSchema-BIe85W_A.mjs';
1
+ import { RequiredValidation } from '../../commonTypes.mjs';
2
2
 
3
3
  /**
4
- * Asserts that the length of a string value is not less than a specified minimum length.
5
- *
6
- * @param {number} expected - The minimum required length for the string.
7
- * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is less than the expected length.
8
- *
4
+ * @description Asserts that the length of a string value is not less than a specified minimum length.
5
+ * @param {number} expected The minimum required length for the string.
6
+ * @returns {RequiredValidation} A validation function that takes a received string and a path to the error message.
7
+ * @throws {ValidationError} if the length of the received value is less than the expected length.
9
8
  * @example
10
9
  * const schema = string().custom(minLength(5));
11
- * parseSchema(schema, 'short'); // Throws an error: 'The received value length is less than expected'
12
- * parseSchema(schema, 'adequate'); // Valid
10
+ * parseOrFail(schema, 'short'); // Throws an error: 'The received value length is less than expected'
11
+ * parseOrFail(schema, 'adequate'); // Valid
12
+ *
13
+ * @translation Error Translation Key = 's:minLength'
13
14
  */
14
- declare const minLength: (expected: number) => RequiredValidation;
15
+ declare const minLength: {
16
+ (expected: number): RequiredValidation;
17
+ key: string;
18
+ message: string;
19
+ };
15
20
 
16
21
  export { minLength };
@@ -1,16 +1,21 @@
1
- import { R as RequiredValidation } from '../../CommonSchema-BIe85W_A.js';
1
+ import { RequiredValidation } from '../../commonTypes.js';
2
2
 
3
3
  /**
4
- * Asserts that the length of a string value is not less than a specified minimum length.
5
- *
6
- * @param {number} expected - The minimum required length for the string.
7
- * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is less than the expected length.
8
- *
4
+ * @description Asserts that the length of a string value is not less than a specified minimum length.
5
+ * @param {number} expected The minimum required length for the string.
6
+ * @returns {RequiredValidation} A validation function that takes a received string and a path to the error message.
7
+ * @throws {ValidationError} if the length of the received value is less than the expected length.
9
8
  * @example
10
9
  * const schema = string().custom(minLength(5));
11
- * parseSchema(schema, 'short'); // Throws an error: 'The received value length is less than expected'
12
- * parseSchema(schema, 'adequate'); // Valid
10
+ * parseOrFail(schema, 'short'); // Throws an error: 'The received value length is less than expected'
11
+ * parseOrFail(schema, 'adequate'); // Valid
12
+ *
13
+ * @translation Error Translation Key = 's:minLength'
13
14
  */
14
- declare const minLength: (expected: number) => RequiredValidation;
15
+ declare const minLength: {
16
+ (expected: number): RequiredValidation;
17
+ key: string;
18
+ message: string;
19
+ };
15
20
 
16
21
  export { minLength };
@@ -1,12 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk2AP4OQMTjs = require('../../chunk-2AP4OQMT.js');
3
+ var _chunk5BVJ6YMHjs = require('../../chunk-5BVJ6YMH.js');
4
+
5
+
6
+ var _chunkWK4O3HH4js = require('../../chunk-WK4O3HH4.js');
4
7
 
5
8
  // src/asserts/string/minLength.ts
6
- var minLength = (expected) => (received, pathToError) => {
7
- if (received.length < expected)
8
- _chunk2AP4OQMTjs.throwException.call(void 0, expected, received, pathToError, "The received value length is less than expected");
9
+ var minLengthErrorMessage = "The received value length is less than expected";
10
+ var minLengthErrorKey = "s:minLength";
11
+ var minLength = (expected) => (received, ctx) => {
12
+ if (received.length < expected) _chunkWK4O3HH4js.guardException.call(void 0, expected, received, ctx, minLengthErrorMessage);
9
13
  };
14
+ minLength.key = minLengthErrorKey;
15
+ minLength.message = minLengthErrorMessage;
16
+ _chunk5BVJ6YMHjs.setToDefaultLocale.call(void 0, minLength);
10
17
 
11
18
 
12
19
  exports.minLength = minLength;
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","../../../src/asserts/string/minLength.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACA;ACUO,IAAM,UAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,WAAA,EAAA,GAAwB;AACzC,EAAA,GAAA,CAAI,QAAA,CAAS,OAAA,EAAS,QAAA;AACpB,IAAA,6CAAA,QAAe,EAAU,QAAA,EAAU,WAAA,EAAa,iDAAiD,CAAA;AACrG,CAAA;ADVF;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","sourcesContent":[null,"import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not less than a specified minimum length.\n *\n * @param {number} expected - The minimum required length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is less than the expected length.\n *\n * @example\n * const schema = string().custom(minLength(5));\n * parseSchema(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseSchema(schema, 'adequate'); // Valid\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length < expected)\n throwException(expected, received, pathToError, 'The received value length is less than expected');\n };\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","../../../src/asserts/string/minLength.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,sBAAA,EAAwB,iDAAA;AAC9B,IAAM,kBAAA,EAAoB,aAAA;AAcnB,IAAM,UAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,QAAA,CAAS,OAAA,EAAS,QAAA,EAAU,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,qBAAqB,CAAA;AAC/F,CAAA;AAEF,SAAA,CAAU,IAAA,EAAM,iBAAA;AAChB,SAAA,CAAU,QAAA,EAAU,qBAAA;AACpB,iDAAA,SAA4B,CAAA;ADX5B;AACE;AACF,8BAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/minLength.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst minLengthErrorMessage = 'The received value length is less than expected';\nconst minLengthErrorKey = 's:minLength';\n\n/**\n * @description Asserts that the length of a string value is not less than a specified minimum length.\n * @param {number} expected The minimum required length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and a path to the error message.\n * @throws {ValidationError} if the length of the received value is less than the expected length.\n * @example\n * const schema = string().custom(minLength(5));\n * parseOrFail(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseOrFail(schema, 'adequate'); // Valid\n *\n * @translation Error Translation Key = 's:minLength'\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (received.length < expected) guardException(expected, received, ctx, minLengthErrorMessage);\n };\n\nminLength.key = minLengthErrorKey;\nminLength.message = minLengthErrorMessage;\nsetToDefaultLocale(minLength);\n"]}
@@ -1,12 +1,19 @@
1
1
  import {
2
- throwException
3
- } from "../../chunk-QJOXKH7A.mjs";
2
+ setToDefaultLocale
3
+ } from "../../chunk-3HTYHE2X.mjs";
4
+ import {
5
+ guardException
6
+ } from "../../chunk-7XFLH6R2.mjs";
4
7
 
5
8
  // src/asserts/string/minLength.ts
6
- var minLength = (expected) => (received, pathToError) => {
7
- if (received.length < expected)
8
- throwException(expected, received, pathToError, "The received value length is less than expected");
9
+ var minLengthErrorMessage = "The received value length is less than expected";
10
+ var minLengthErrorKey = "s:minLength";
11
+ var minLength = (expected) => (received, ctx) => {
12
+ if (received.length < expected) guardException(expected, received, ctx, minLengthErrorMessage);
9
13
  };
14
+ minLength.key = minLengthErrorKey;
15
+ minLength.message = minLengthErrorMessage;
16
+ setToDefaultLocale(minLength);
10
17
  export {
11
18
  minLength
12
19
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/asserts/string/minLength.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that the length of a string value is not less than a specified minimum length.\n *\n * @param {number} expected - The minimum required length for the string.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the length of the received value is less than the expected length.\n *\n * @example\n * const schema = string().custom(minLength(5));\n * parseSchema(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseSchema(schema, 'adequate'); // Valid\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (received.length < expected)\n throwException(expected, received, pathToError, 'The received value length is less than expected');\n };\n"],"mappings":";;;;;AAcO,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,SAAS,SAAS;AACpB,mBAAe,UAAU,UAAU,aAAa,iDAAiD;AACrG;","names":[]}
1
+ {"version":3,"sources":["../../../src/asserts/string/minLength.ts"],"sourcesContent":["import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst minLengthErrorMessage = 'The received value length is less than expected';\nconst minLengthErrorKey = 's:minLength';\n\n/**\n * @description Asserts that the length of a string value is not less than a specified minimum length.\n * @param {number} expected The minimum required length for the string.\n * @returns {RequiredValidation} A validation function that takes a received string and a path to the error message.\n * @throws {ValidationError} if the length of the received value is less than the expected length.\n * @example\n * const schema = string().custom(minLength(5));\n * parseOrFail(schema, 'short'); // Throws an error: 'The received value length is less than expected'\n * parseOrFail(schema, 'adequate'); // Valid\n *\n * @translation Error Translation Key = 's:minLength'\n */\nexport const minLength =\n (expected: number): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (received.length < expected) guardException(expected, received, ctx, minLengthErrorMessage);\n };\n\nminLength.key = minLengthErrorKey;\nminLength.message = minLengthErrorMessage;\nsetToDefaultLocale(minLength);\n"],"mappings":";;;;;;;;AAIA,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB;AAcnB,IAAM,YACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,SAAS,SAAS,SAAU,gBAAe,UAAU,UAAU,KAAK,qBAAqB;AAC/F;AAEF,UAAU,MAAM;AAChB,UAAU,UAAU;AACpB,mBAAmB,SAAS;","names":[]}
@@ -1,16 +1,21 @@
1
- import { R as RequiredValidation } from '../../CommonSchema-BIe85W_A.mjs';
1
+ import { RequiredValidation } from '../../commonTypes.mjs';
2
2
 
3
3
  /**
4
- * Asserts that a string value matches a specified regular expression pattern.
5
- *
6
- * @param {RegExp} expected - The regular expression pattern that the string value should match.
7
- * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the received value does not match the expected pattern.
8
- *
4
+ * @description Asserts that a string value matches a specified regular expression pattern.
5
+ * @param {RegExp} expected The regular expression pattern that the string value should match.
6
+ * @returns {RequiredValidation} A validation function that takes a received string and a path to the error message.
7
+ * @throws {ValidationError} if the received value does not match the expected pattern.
9
8
  * @example
10
9
  * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern
11
- * parseSchema(schema, 'valid123'); // Valid
12
- * parseSchema(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'
10
+ * parseOrFail(schema, 'valid123'); // Valid
11
+ * parseOrFail(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'
12
+ *
13
+ * @translation Error Translation Key = 's:regExp'
13
14
  */
14
- declare const regExp: (expected: RegExp) => RequiredValidation;
15
+ declare const regExp: {
16
+ (expected: RegExp): RequiredValidation;
17
+ key: string;
18
+ message: string;
19
+ };
15
20
 
16
21
  export { regExp };
@@ -1,16 +1,21 @@
1
- import { R as RequiredValidation } from '../../CommonSchema-BIe85W_A.js';
1
+ import { RequiredValidation } from '../../commonTypes.js';
2
2
 
3
3
  /**
4
- * Asserts that a string value matches a specified regular expression pattern.
5
- *
6
- * @param {RegExp} expected - The regular expression pattern that the string value should match.
7
- * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the received value does not match the expected pattern.
8
- *
4
+ * @description Asserts that a string value matches a specified regular expression pattern.
5
+ * @param {RegExp} expected The regular expression pattern that the string value should match.
6
+ * @returns {RequiredValidation} A validation function that takes a received string and a path to the error message.
7
+ * @throws {ValidationError} if the received value does not match the expected pattern.
9
8
  * @example
10
9
  * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern
11
- * parseSchema(schema, 'valid123'); // Valid
12
- * parseSchema(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'
10
+ * parseOrFail(schema, 'valid123'); // Valid
11
+ * parseOrFail(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'
12
+ *
13
+ * @translation Error Translation Key = 's:regExp'
13
14
  */
14
- declare const regExp: (expected: RegExp) => RequiredValidation;
15
+ declare const regExp: {
16
+ (expected: RegExp): RequiredValidation;
17
+ key: string;
18
+ message: string;
19
+ };
15
20
 
16
21
  export { regExp };
@@ -1,12 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk2AP4OQMTjs = require('../../chunk-2AP4OQMT.js');
3
+ var _chunk5BVJ6YMHjs = require('../../chunk-5BVJ6YMH.js');
4
+
5
+
6
+ var _chunkWK4O3HH4js = require('../../chunk-WK4O3HH4.js');
4
7
 
5
8
  // src/asserts/string/regExp.ts
6
- var regExp = (expected) => (received, pathToError) => {
7
- if (!expected.test(received))
8
- _chunk2AP4OQMTjs.throwException.call(void 0, expected, received, pathToError, "The received value does not match the required text pattern");
9
+ var regExpErrorMessage = "The received value does not match the required text pattern";
10
+ var regExpErrorKey = "s:regExp";
11
+ var regExp = (expected) => (received, ctx) => {
12
+ if (!expected.test(received)) _chunkWK4O3HH4js.guardException.call(void 0, expected, received, ctx, regExpErrorMessage);
9
13
  };
14
+ regExp.key = regExpErrorKey;
15
+ regExp.message = regExpErrorMessage;
16
+ _chunk5BVJ6YMHjs.setToDefaultLocale.call(void 0, regExp);
10
17
 
11
18
 
12
19
  exports.regExp = regExp;
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","../../../src/asserts/string/regExp.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACA;ACUO,IAAM,OAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,WAAA,EAAA,GAAwB;AACzC,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA;AACzB,IAAA,6CAAA,QAAe,EAAU,QAAA,EAAU,WAAA,EAAa,6DAA6D,CAAA;AACjH,CAAA;ADVF;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","sourcesContent":[null,"import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a string value matches a specified regular expression pattern.\n *\n * @param {RegExp} expected - The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the received value does not match the expected pattern.\n *\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseSchema(schema, 'valid123'); // Valid\n * parseSchema(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (!expected.test(received))\n throwException(expected, received, pathToError, 'The received value does not match the required text pattern');\n };\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","../../../src/asserts/string/regExp.ts"],"names":[],"mappings":"AAAA;AACE;AACF,0DAAgC;AAChC;AACE;AACF,0DAAgC;AAChC;AACA;ACHA,IAAM,mBAAA,EAAqB,6DAAA;AAC3B,IAAM,eAAA,EAAiB,UAAA;AAchB,IAAM,OAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAkB,GAAA,EAAA,GAA0B;AAC3C,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA,EAAG,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,kBAAkB,CAAA;AAC1F,CAAA;AAEF,MAAA,CAAO,IAAA,EAAM,cAAA;AACb,MAAA,CAAO,QAAA,EAAU,kBAAA;AACjB,iDAAA,MAAyB,CAAA;ADXzB;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/asserts/string/regExp.js","sourcesContent":[null,"import { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { guardException } from '../../exceptions';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst regExpErrorMessage = 'The received value does not match the required text pattern';\nconst regExpErrorKey = 's:regExp';\n\n/**\n * @description Asserts that a string value matches a specified regular expression pattern.\n * @param {RegExp} expected The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} A validation function that takes a received string and a path to the error message.\n * @throws {ValidationError} if the received value does not match the expected pattern.\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseOrFail(schema, 'valid123'); // Valid\n * parseOrFail(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n *\n * @translation Error Translation Key = 's:regExp'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (!expected.test(received)) guardException(expected, received, ctx, regExpErrorMessage);\n };\n\nregExp.key = regExpErrorKey;\nregExp.message = regExpErrorMessage;\nsetToDefaultLocale(regExp);\n"]}
@@ -1,12 +1,19 @@
1
1
  import {
2
- throwException
3
- } from "../../chunk-QJOXKH7A.mjs";
2
+ setToDefaultLocale
3
+ } from "../../chunk-3HTYHE2X.mjs";
4
+ import {
5
+ guardException
6
+ } from "../../chunk-7XFLH6R2.mjs";
4
7
 
5
8
  // src/asserts/string/regExp.ts
6
- var regExp = (expected) => (received, pathToError) => {
7
- if (!expected.test(received))
8
- throwException(expected, received, pathToError, "The received value does not match the required text pattern");
9
+ var regExpErrorMessage = "The received value does not match the required text pattern";
10
+ var regExpErrorKey = "s:regExp";
11
+ var regExp = (expected) => (received, ctx) => {
12
+ if (!expected.test(received)) guardException(expected, received, ctx, regExpErrorMessage);
9
13
  };
14
+ regExp.key = regExpErrorKey;
15
+ regExp.message = regExpErrorMessage;
16
+ setToDefaultLocale(regExp);
10
17
  export {
11
18
  regExp
12
19
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/asserts/string/regExp.ts"],"sourcesContent":["import { throwException } from '../../exceptions';\nimport type { RequiredValidation } from '../../schemas/CommonSchema';\n\n/**\n * Asserts that a string value matches a specified regular expression pattern.\n *\n * @param {RegExp} expected - The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} - A validation function that takes a received string and a path to the error message. Throws an error if the received value does not match the expected pattern.\n *\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseSchema(schema, 'valid123'); // Valid\n * parseSchema(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, pathToError: string) => {\n if (!expected.test(received))\n throwException(expected, received, pathToError, 'The received value does not match the required text pattern');\n };\n"],"mappings":";;;;;AAcO,IAAM,SACX,CAAC,aACD,CAAC,UAAkB,gBAAwB;AACzC,MAAI,CAAC,SAAS,KAAK,QAAQ;AACzB,mBAAe,UAAU,UAAU,aAAa,6DAA6D;AACjH;","names":[]}
1
+ {"version":3,"sources":["../../../src/asserts/string/regExp.ts"],"sourcesContent":["import { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { guardException } from '../../exceptions';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst regExpErrorMessage = 'The received value does not match the required text pattern';\nconst regExpErrorKey = 's:regExp';\n\n/**\n * @description Asserts that a string value matches a specified regular expression pattern.\n * @param {RegExp} expected The regular expression pattern that the string value should match.\n * @returns {RequiredValidation} A validation function that takes a received string and a path to the error message.\n * @throws {ValidationError} if the received value does not match the expected pattern.\n * @example\n * const schema = string().custom(regExp(/^[A-Za-z0-9]+$/)); // Validates against alphanumeric pattern\n * parseOrFail(schema, 'valid123'); // Valid\n * parseOrFail(schema, 'invalid!@#'); // Throws an error: 'The received value does not match the required text pattern'\n *\n * @translation Error Translation Key = 's:regExp'\n */\nexport const regExp =\n (expected: RegExp): RequiredValidation =>\n (received: string, ctx: ExceptionContext) => {\n if (!expected.test(received)) guardException(expected, received, ctx, regExpErrorMessage);\n };\n\nregExp.key = regExpErrorKey;\nregExp.message = regExpErrorMessage;\nsetToDefaultLocale(regExp);\n"],"mappings":";;;;;;;;AAIA,IAAM,qBAAqB;AAC3B,IAAM,iBAAiB;AAchB,IAAM,SACX,CAAC,aACD,CAAC,UAAkB,QAA0B;AAC3C,MAAI,CAAC,SAAS,KAAK,QAAQ,EAAG,gBAAe,UAAU,UAAU,KAAK,kBAAkB;AAC1F;AAEF,OAAO,MAAM;AACb,OAAO,UAAU;AACjB,mBAAmB,MAAM;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ObjectSchema
3
- } from "./chunk-QYLH5ZAC.mjs";
3
+ } from "./chunk-TCQY2R3U.mjs";
4
4
 
5
5
  // src/asserts/object/index.ts
6
6
  function object(shapeSchema) {
@@ -10,4 +10,4 @@ function object(shapeSchema) {
10
10
  export {
11
11
  object
12
12
  };
13
- //# sourceMappingURL=chunk-32IQXZRK.mjs.map
13
+ //# sourceMappingURL=chunk-2PM3K3OE.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/asserts/object/index.ts"],"sourcesContent":["import { ObjectShapeSchemaType } from '../../schemas/CommonSchema';\nimport { ObjectSchema, WithObject } from '../../schemas/ObjectSchema';\n\n/**\n * Creates a new schema for validating objects where each property must match the specified schema.\n *\n * @template T\n * @param {T} shapeSchema - The schema that each property of the object must match.\n * @returns {WithObject<T>} A new instance of `ObjectSchema` for validating objects with properties matching the specified schema.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number()\n * });\n * parseSchema(schema, { name: 'John', age: 30 }); // Validates successfully\n * parseSchema(schema, { name: 'John', age: '30' }); // Throws a validation error\n */\nexport function object<T extends ObjectShapeSchemaType>(shapeSchema: T): WithObject<T> {\n return new ObjectSchema({ type: [], requiredValidations: [] }, shapeSchema) as WithObject<T>;\n}\n"],"mappings":";;;;;AAkBO,SAAS,OAAwC,aAA+B;AACrF,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,EAAE,GAAG,WAAW;AAC5E;","names":[]}
1
+ {"version":3,"sources":["../src/asserts/object/index.ts"],"sourcesContent":["import { ObjectShapeSchemaType } from '../../schemas/CommonSchema';\nimport { ObjectSchema, WithObject } from '../../schemas/ObjectSchema';\n\n/**\n * Creates a new schema for validating objects where each property must match the specified schema.\n *\n * @template T\n * @param {T} shapeSchema - The schema that each property of the object must match.\n * @returns {WithObject<T>} A new instance of `ObjectSchema` for validating objects with properties matching the specified schema.\n *\n * @example\n * const schema = object({\n * name: string(),\n * age: number()\n * });\n * parseOrFail(schema, { name: 'John', age: 30 }); // Validates successfully\n * parseOrFail(schema, { name: 'John', age: '30' }); // Throws a validation error\n */\nexport function object<T extends ObjectShapeSchemaType>(shapeSchema: T): WithObject<T> {\n return new ObjectSchema({ type: [], requiredValidations: [] }, shapeSchema) as WithObject<T>;\n}\n"],"mappings":";;;;;AAkBO,SAAS,OAAwC,aAA+B;AACrF,SAAO,IAAI,aAAa,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC,EAAE,GAAG,WAAW;AAC5E;","names":[]}
@@ -0,0 +1,54 @@
1
+ import {
2
+ BuildSchemaError
3
+ } from "./chunk-7XFLH6R2.mjs";
4
+
5
+ // src/translationMap.ts
6
+ var defaultErrorMap = {
7
+ //@@start
8
+ "c:optional": "The required value is missing",
9
+ "c:nullable": "Value should not be null",
10
+ "c:array": "Expected an array but received a different type",
11
+ "c:objectType": "Expected an object but received a different type",
12
+ "c:objectTypeAsArray": "Expected an object but received an array. Invalid type of data",
13
+ "c:unrecognizedProperty": "This property is not allowed in the object",
14
+ "c:requiredProperty": "Missing required property in the object",
15
+ "c:invalidType": "Invalid type of data",
16
+ "c:isBoolean": "The received value is not {{e}}"
17
+ //@@end
18
+ };
19
+ var data = {
20
+ default: { ...defaultErrorMap }
21
+ };
22
+ function setToDefaultLocale({
23
+ key,
24
+ message
25
+ }) {
26
+ const defaultLocale = data.default;
27
+ if (defaultLocale[key]) throw new BuildSchemaError("Duplicate default message key");
28
+ defaultLocale[key] = message;
29
+ }
30
+ function setLocale(lng, custom) {
31
+ if (lng === "default") throw new BuildSchemaError("Invalid language");
32
+ if (!data[lng]) data[lng] = { ...defaultErrorMap };
33
+ const locale = data[lng];
34
+ Object.entries(custom).forEach(([messageKey, messageValue]) => {
35
+ locale[messageKey] = messageValue;
36
+ });
37
+ }
38
+ function clearLocales() {
39
+ data = {
40
+ default: { ...defaultErrorMap }
41
+ };
42
+ }
43
+ function getTranslationByLocale(lng) {
44
+ if (!lng) return data["default"];
45
+ return data[lng] ?? data["default"];
46
+ }
47
+
48
+ export {
49
+ setToDefaultLocale,
50
+ setLocale,
51
+ clearLocales,
52
+ getTranslationByLocale
53
+ };
54
+ //# sourceMappingURL=chunk-3HTYHE2X.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/translationMap.ts"],"sourcesContent":["import { BuildSchemaError } from './exceptions';\nimport { RequiredValidation, TranslationErrorMap } from './commonTypes';\n\n// c: stands for common\nconst defaultErrorMap: TranslationErrorMap = {\n //@@start\n 'c:optional': 'The required value is missing',\n 'c:nullable': 'Value should not be null',\n 'c:array': 'Expected an array but received a different type',\n 'c:objectType': 'Expected an object but received a different type',\n 'c:objectTypeAsArray': 'Expected an object but received an array. Invalid type of data',\n 'c:unrecognizedProperty': 'This property is not allowed in the object',\n 'c:requiredProperty': 'Missing required property in the object',\n 'c:invalidType': 'Invalid type of data',\n 'c:isBoolean': 'The received value is not {{e}}',\n //@@end\n};\n\nlet data: Record<string, Record<string, string>> = {\n default: { ...defaultErrorMap },\n};\n\nexport function setToDefaultLocale({\n key,\n message,\n}: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (expected: any): RequiredValidation;\n key: string;\n message: string;\n}) {\n const defaultLocale = data.default!;\n if (defaultLocale[key]) throw new BuildSchemaError('Duplicate default message key');\n defaultLocale[key] = message;\n}\n\nexport function setLocale(lng: string, custom: Partial<TranslationErrorMap>) {\n if (lng === 'default') throw new BuildSchemaError('Invalid language');\n if (!data[lng]) data[lng] = { ...defaultErrorMap };\n const locale = data[lng]!;\n Object.entries(custom).forEach(([messageKey, messageValue]) => {\n locale[messageKey] = messageValue!;\n });\n}\n\nexport function clearLocales() {\n data = {\n default: { ...defaultErrorMap },\n };\n}\n\nexport function getTranslationByLocale(lng?: string): TranslationErrorMap {\n if (!lng) return data['default'] as TranslationErrorMap;\n return (data[lng] ?? data['default']) as TranslationErrorMap;\n}\n"],"mappings":";;;;;AAIA,IAAM,kBAAuC;AAAA;AAAA,EAE3C,cAAc;AAAA,EACd,cAAc;AAAA,EACd,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,uBAAuB;AAAA,EACvB,0BAA0B;AAAA,EAC1B,sBAAsB;AAAA,EACtB,iBAAiB;AAAA,EACjB,eAAe;AAAA;AAEjB;AAEA,IAAI,OAA+C;AAAA,EACjD,SAAS,EAAE,GAAG,gBAAgB;AAChC;AAEO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAKG;AACD,QAAM,gBAAgB,KAAK;AAC3B,MAAI,cAAc,GAAG,EAAG,OAAM,IAAI,iBAAiB,+BAA+B;AAClF,gBAAc,GAAG,IAAI;AACvB;AAEO,SAAS,UAAU,KAAa,QAAsC;AAC3E,MAAI,QAAQ,UAAW,OAAM,IAAI,iBAAiB,kBAAkB;AACpE,MAAI,CAAC,KAAK,GAAG,EAAG,MAAK,GAAG,IAAI,EAAE,GAAG,gBAAgB;AACjD,QAAM,SAAS,KAAK,GAAG;AACvB,SAAO,QAAQ,MAAM,EAAE,QAAQ,CAAC,CAAC,YAAY,YAAY,MAAM;AAC7D,WAAO,UAAU,IAAI;AAAA,EACvB,CAAC;AACH;AAEO,SAAS,eAAe;AAC7B,SAAO;AAAA,IACL,SAAS,EAAE,GAAG,gBAAgB;AAAA,EAChC;AACF;AAEO,SAAS,uBAAuB,KAAmC;AACxE,MAAI,CAAC,IAAK,QAAO,KAAK,SAAS;AAC/B,SAAQ,KAAK,GAAG,KAAK,KAAK,SAAS;AACrC;","names":[]}
@@ -0,0 +1,21 @@
1
+ import {
2
+ setToDefaultLocale
3
+ } from "./chunk-3HTYHE2X.mjs";
4
+ import {
5
+ guardException
6
+ } from "./chunk-7XFLH6R2.mjs";
7
+
8
+ // src/asserts/mix/oneOfValues.ts
9
+ var oneOfValuesErrorMessage = "The received value is not equal to expected";
10
+ var oneOfValuesErrorKey = "m:oneOfValues";
11
+ var oneOfValues = (expected) => (received, ctx) => {
12
+ if (!expected.includes(received)) guardException(expected, received, ctx, oneOfValuesErrorKey);
13
+ };
14
+ oneOfValues.key = oneOfValuesErrorKey;
15
+ oneOfValues.message = oneOfValuesErrorMessage;
16
+ setToDefaultLocale(oneOfValues);
17
+
18
+ export {
19
+ oneOfValues
20
+ };
21
+ //# sourceMappingURL=chunk-3O4WCRC2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/asserts/mix/oneOfValues.ts"],"sourcesContent":["import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst oneOfValuesErrorMessage = 'The received value is not equal to expected';\nconst oneOfValuesErrorKey = 'm:oneOfValues';\n\n/**\n * @description Creates a custom assertion that checks if a value is equal to the one of expected values.\n * @notice It has already been implemented in the number and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match at least one of the expected values.\n * @example\n * const schema = number().custom(oneOfValues([5, 4])); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 4); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:oneOfValues'\n */\nexport const oneOfValues =\n (expected: unknown[]): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (!expected.includes(received)) guardException(expected, received, ctx, oneOfValuesErrorKey);\n };\n\noneOfValues.key = oneOfValuesErrorKey;\noneOfValues.message = oneOfValuesErrorMessage;\nsetToDefaultLocale(oneOfValues);\n"],"mappings":";;;;;;;;AAIA,IAAM,0BAA0B;AAChC,IAAM,sBAAsB;AAgBrB,IAAM,cACX,CAAC,aACD,CAAC,UAAmB,QAA0B;AAC5C,MAAI,CAAC,SAAS,SAAS,QAAQ,EAAG,gBAAe,UAAU,UAAU,KAAK,mBAAmB;AAC/F;AAEF,YAAY,MAAM;AAClB,YAAY,UAAU;AACtB,mBAAmB,WAAW;","names":[]}
@@ -0,0 +1,21 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk5BVJ6YMHjs = require('./chunk-5BVJ6YMH.js');
4
+
5
+
6
+ var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
7
+
8
+ // src/asserts/mix/oneOfValues.ts
9
+ var oneOfValuesErrorMessage = "The received value is not equal to expected";
10
+ var oneOfValuesErrorKey = "m:oneOfValues";
11
+ var oneOfValues = (expected) => (received, ctx) => {
12
+ if (!expected.includes(received)) _chunkWK4O3HH4js.guardException.call(void 0, expected, received, ctx, oneOfValuesErrorKey);
13
+ };
14
+ oneOfValues.key = oneOfValuesErrorKey;
15
+ oneOfValues.message = oneOfValuesErrorMessage;
16
+ _chunk5BVJ6YMHjs.setToDefaultLocale.call(void 0, oneOfValues);
17
+
18
+
19
+
20
+ exports.oneOfValues = oneOfValues;
21
+ //# sourceMappingURL=chunk-4CYIMDP2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-4CYIMDP2.js","../src/asserts/mix/oneOfValues.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACHA,IAAM,wBAAA,EAA0B,6CAAA;AAChC,IAAM,oBAAA,EAAsB,eAAA;AAgBrB,IAAM,YAAA,EACX,CAAC,QAAA,EAAA,GACD,CAAC,QAAA,EAAmB,GAAA,EAAA,GAA0B;AAC5C,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,QAAA,CAAS,QAAQ,CAAA,EAAG,6CAAA,QAAe,EAAU,QAAA,EAAU,GAAA,EAAK,mBAAmB,CAAA;AAC/F,CAAA;AAEF,WAAA,CAAY,IAAA,EAAM,mBAAA;AAClB,WAAA,CAAY,QAAA,EAAU,uBAAA;AACtB,iDAAA,WAA8B,CAAA;ADb9B;AACA;AACE;AACF,kCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-4CYIMDP2.js","sourcesContent":[null,"import { guardException } from '../../exceptions';\nimport { ExceptionContext, RequiredValidation } from '../../commonTypes';\nimport { setToDefaultLocale } from '../../translationMap';\n\nconst oneOfValuesErrorMessage = 'The received value is not equal to expected';\nconst oneOfValuesErrorKey = 'm:oneOfValues';\n\n/**\n * @description Creates a custom assertion that checks if a value is equal to the one of expected values.\n * @notice It has already been implemented in the number and string schema. There is no need to use it as a custom assert.\n * @param {unknown} expected The value that the received value is expected to match.\n * @returns {RequiredValidation} A validation function that takes a received value and an exception context.\n * @throws {ValidationError} If the received value does not match at least one of the expected values.\n * @example\n * const schema = number().custom(oneOfValues([5, 4])); // Define a schema with a custom assertion\n * parseOrFail(schema, 5); // Valid\n * parseOrFail(schema, 4); // Valid\n * parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'\n *\n * @translation Error Translation Key = 'm:oneOfValues'\n */\nexport const oneOfValues =\n (expected: unknown[]): RequiredValidation =>\n (received: unknown, ctx: ExceptionContext) => {\n if (!expected.includes(received)) guardException(expected, received, ctx, oneOfValuesErrorKey);\n };\n\noneOfValues.key = oneOfValuesErrorKey;\noneOfValues.message = oneOfValuesErrorMessage;\nsetToDefaultLocale(oneOfValues);\n"]}
@@ -1,13 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkGNBSKTFVjs = require('./chunk-GNBSKTFV.js');
3
+ var _chunkRQH4LXBWjs = require('./chunk-RQH4LXBW.js');
4
4
 
5
5
  // src/asserts/number/index.ts
6
6
  function number() {
7
- return new (0, _chunkGNBSKTFVjs.NumberSchema)({ type: ["number"], requiredValidations: [] });
7
+ return new (0, _chunkRQH4LXBWjs.NumberSchema)({ type: ["number"], requiredValidations: [] });
8
8
  }
9
9
 
10
10
 
11
11
 
12
12
  exports.number = number;
13
- //# sourceMappingURL=chunk-QKGQ4XZC.js.map
13
+ //# sourceMappingURL=chunk-4RNK3I74.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-QKGQ4XZC.js","../src/asserts/number/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,MAAA,CAAA,EAAuB;AACrC,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADNA;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-QKGQ4XZC.js","sourcesContent":[null,"import { NumberSchema } from '../../schemas/NumberSchema';\n\n/**\n * Creates a new schema for validating number values.\n *\n * @returns {NumberSchema} A new instance of `NumberSchema` for validating numbers.\n *\n * @example\n * const schema = number();\n * parseSchema(schema, 42); // Validates successfully\n * parseSchema(schema, '42'); // Throws a validation error\n */\nexport function number(): NumberSchema {\n return new NumberSchema({ type: ['number'], requiredValidations: [] });\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-4RNK3I74.js","../src/asserts/number/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACQO,SAAS,MAAA,CAAA,EAAuB;AACrC,EAAA,OAAO,IAAI,kCAAA,CAAa,EAAE,IAAA,EAAM,CAAC,QAAQ,CAAA,EAAG,mBAAA,EAAqB,CAAC,EAAE,CAAC,CAAA;AACvE;ADNA;AACA;AACE;AACF,wBAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-4RNK3I74.js","sourcesContent":[null,"import { NumberSchema } from '../../schemas/NumberSchema';\n\n/**\n * Creates a new schema for validating number values.\n *\n * @returns {NumberSchema} A new instance of `NumberSchema` for validating numbers.\n *\n * @example\n * const schema = number();\n * parseOrFail(schema, 42); // Validates successfully\n * parseOrFail(schema, '42'); // Throws a validation error\n */\nexport function number(): NumberSchema {\n return new NumberSchema({ type: ['number'], requiredValidations: [] });\n}\n"]}
@@ -0,0 +1,54 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+ var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
4
+
5
+ // src/translationMap.ts
6
+ var defaultErrorMap = {
7
+ //@@start
8
+ "c:optional": "The required value is missing",
9
+ "c:nullable": "Value should not be null",
10
+ "c:array": "Expected an array but received a different type",
11
+ "c:objectType": "Expected an object but received a different type",
12
+ "c:objectTypeAsArray": "Expected an object but received an array. Invalid type of data",
13
+ "c:unrecognizedProperty": "This property is not allowed in the object",
14
+ "c:requiredProperty": "Missing required property in the object",
15
+ "c:invalidType": "Invalid type of data",
16
+ "c:isBoolean": "The received value is not {{e}}"
17
+ //@@end
18
+ };
19
+ var data = {
20
+ default: { ...defaultErrorMap }
21
+ };
22
+ function setToDefaultLocale({
23
+ key,
24
+ message
25
+ }) {
26
+ const defaultLocale = data.default;
27
+ if (defaultLocale[key]) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Duplicate default message key");
28
+ defaultLocale[key] = message;
29
+ }
30
+ function setLocale(lng, custom) {
31
+ if (lng === "default") throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Invalid language");
32
+ if (!data[lng]) data[lng] = { ...defaultErrorMap };
33
+ const locale = data[lng];
34
+ Object.entries(custom).forEach(([messageKey, messageValue]) => {
35
+ locale[messageKey] = messageValue;
36
+ });
37
+ }
38
+ function clearLocales() {
39
+ data = {
40
+ default: { ...defaultErrorMap }
41
+ };
42
+ }
43
+ function getTranslationByLocale(lng) {
44
+ if (!lng) return data["default"];
45
+ return _nullishCoalesce(data[lng], () => ( data["default"]));
46
+ }
47
+
48
+
49
+
50
+
51
+
52
+
53
+ exports.setToDefaultLocale = setToDefaultLocale; exports.setLocale = setLocale; exports.clearLocales = clearLocales; exports.getTranslationByLocale = getTranslationByLocale;
54
+ //# sourceMappingURL=chunk-5BVJ6YMH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-5BVJ6YMH.js","../src/translationMap.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACAA,IAAM,gBAAA,EAAuC;AAAA;AAAA,EAE3C,YAAA,EAAc,+BAAA;AAAA,EACd,YAAA,EAAc,0BAAA;AAAA,EACd,SAAA,EAAW,iDAAA;AAAA,EACX,cAAA,EAAgB,kDAAA;AAAA,EAChB,qBAAA,EAAuB,gEAAA;AAAA,EACvB,wBAAA,EAA0B,4CAAA;AAAA,EAC1B,oBAAA,EAAsB,yCAAA;AAAA,EACtB,eAAA,EAAiB,sBAAA;AAAA,EACjB,aAAA,EAAe;AAAA;AAEjB,CAAA;AAEA,IAAI,KAAA,EAA+C;AAAA,EACjD,OAAA,EAAS,EAAE,GAAG,gBAAgB;AAChC,CAAA;AAEO,SAAS,kBAAA,CAAmB;AAAA,EACjC,GAAA;AAAA,EACA;AACF,CAAA,EAKG;AACD,EAAA,MAAM,cAAA,EAAgB,IAAA,CAAK,OAAA;AAC3B,EAAA,GAAA,CAAI,aAAA,CAAc,GAAG,CAAA,EAAG,MAAM,IAAI,sCAAA,CAAiB,+BAA+B,CAAA;AAClF,EAAA,aAAA,CAAc,GAAG,EAAA,EAAI,OAAA;AACvB;AAEO,SAAS,SAAA,CAAU,GAAA,EAAa,MAAA,EAAsC;AAC3E,EAAA,GAAA,CAAI,IAAA,IAAQ,SAAA,EAAW,MAAM,IAAI,sCAAA,CAAiB,kBAAkB,CAAA;AACpE,EAAA,GAAA,CAAI,CAAC,IAAA,CAAK,GAAG,CAAA,EAAG,IAAA,CAAK,GAAG,EAAA,EAAI,EAAE,GAAG,gBAAgB,CAAA;AACjD,EAAA,MAAM,OAAA,EAAS,IAAA,CAAK,GAAG,CAAA;AACvB,EAAA,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAC,UAAA,EAAY,YAAY,CAAA,EAAA,GAAM;AAC7D,IAAA,MAAA,CAAO,UAAU,EAAA,EAAI,YAAA;AAAA,EACvB,CAAC,CAAA;AACH;AAEO,SAAS,YAAA,CAAA,EAAe;AAC7B,EAAA,KAAA,EAAO;AAAA,IACL,OAAA,EAAS,EAAE,GAAG,gBAAgB;AAAA,EAChC,CAAA;AACF;AAEO,SAAS,sBAAA,CAAuB,GAAA,EAAmC;AACxE,EAAA,GAAA,CAAI,CAAC,GAAA,EAAK,OAAO,IAAA,CAAK,SAAS,CAAA;AAC/B,EAAA,wBAAQ,IAAA,CAAK,GAAG,CAAA,UAAK,IAAA,CAAK,SAAS,GAAA;AACrC;ADRA;AACA;AACE;AACA;AACA;AACA;AACF,6KAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-5BVJ6YMH.js","sourcesContent":[null,"import { BuildSchemaError } from './exceptions';\nimport { RequiredValidation, TranslationErrorMap } from './commonTypes';\n\n// c: stands for common\nconst defaultErrorMap: TranslationErrorMap = {\n //@@start\n 'c:optional': 'The required value is missing',\n 'c:nullable': 'Value should not be null',\n 'c:array': 'Expected an array but received a different type',\n 'c:objectType': 'Expected an object but received a different type',\n 'c:objectTypeAsArray': 'Expected an object but received an array. Invalid type of data',\n 'c:unrecognizedProperty': 'This property is not allowed in the object',\n 'c:requiredProperty': 'Missing required property in the object',\n 'c:invalidType': 'Invalid type of data',\n 'c:isBoolean': 'The received value is not {{e}}',\n //@@end\n};\n\nlet data: Record<string, Record<string, string>> = {\n default: { ...defaultErrorMap },\n};\n\nexport function setToDefaultLocale({\n key,\n message,\n}: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (expected: any): RequiredValidation;\n key: string;\n message: string;\n}) {\n const defaultLocale = data.default!;\n if (defaultLocale[key]) throw new BuildSchemaError('Duplicate default message key');\n defaultLocale[key] = message;\n}\n\nexport function setLocale(lng: string, custom: Partial<TranslationErrorMap>) {\n if (lng === 'default') throw new BuildSchemaError('Invalid language');\n if (!data[lng]) data[lng] = { ...defaultErrorMap };\n const locale = data[lng]!;\n Object.entries(custom).forEach(([messageKey, messageValue]) => {\n locale[messageKey] = messageValue!;\n });\n}\n\nexport function clearLocales() {\n data = {\n default: { ...defaultErrorMap },\n };\n}\n\nexport function getTranslationByLocale(lng?: string): TranslationErrorMap {\n if (!lng) return data['default'] as TranslationErrorMap;\n return (data[lng] ?? data['default']) as TranslationErrorMap;\n}\n"]}
@@ -0,0 +1,53 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;
2
+
3
+ var _chunkEGEHSELTjs = require('./chunk-EGEHSELT.js');
4
+
5
+
6
+ var _chunkIRG4OQABjs = require('./chunk-IRG4OQAB.js');
7
+
8
+
9
+ var _chunkWK4O3HH4js = require('./chunk-WK4O3HH4.js');
10
+
11
+ // src/schemas/ObjectSchema.ts
12
+ var ObjectSchema = (_class = class extends _chunkEGEHSELTjs.CommonSchema {
13
+ __init() {this._object = 1}
14
+ constructor(ctx, shapeSchema) {
15
+ super(ctx);_class.prototype.__init.call(this);;
16
+ this.validateObjectEntry(shapeSchema);
17
+ this[_chunkIRG4OQABjs.ctxSymbol].object = shapeSchema;
18
+ }
19
+ validateObjectEntry(shapeSchema) {
20
+ if (!shapeSchema) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Missing schema in object method");
21
+ if (shapeSchema instanceof _chunkEGEHSELTjs.CommonSchema) throw new (0, _chunkWK4O3HH4js.BuildSchemaError)("Invalid schema in object");
22
+ for (const [key, value] of Object.entries(shapeSchema)) {
23
+ if (!(value instanceof _chunkEGEHSELTjs.CommonSchema))
24
+ throw new (0, _chunkWK4O3HH4js.BuildSchemaError)(`Invalid schema in object method for property '${key}'`);
25
+ }
26
+ }
27
+ /**
28
+ * Allows unrecognized properties in the validated object.
29
+ * When this method is called, the validation will not fail
30
+ * if the received object contains properties not specified
31
+ * in the validation schema.
32
+ *
33
+ * @returns {this} The current ObjectSchema instance.
34
+ *
35
+ * @example
36
+ * const userSchema = object({
37
+ * name: string(),
38
+ * age: number(),
39
+ * }).allowUnrecognized();
40
+ *
41
+ * parseOrFail(userSchema, ({ name: 'John', age: 30, extra: 'value' }););
42
+ * // No error thrown
43
+ */
44
+ allowUnrecognized() {
45
+ this[_chunkIRG4OQABjs.ctxSymbol].allowUnrecognizedObjectProps = true;
46
+ return this;
47
+ }
48
+ }, _class);
49
+
50
+
51
+
52
+ exports.ObjectSchema = ObjectSchema;
53
+ //# sourceMappingURL=chunk-6TH3DBDK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bguard/bguard/lib/chunk-6TH3DBDK.js","../src/schemas/ObjectSchema.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACE;AACF,sDAA4B;AAC5B;AACA;ACNO,IAAM,aAAA,YAAN,MAAA,QAA2B,8BAAa;AAAA,iBAC7C,QAAA,EAAU,EAAA;AAAA,EACV,WAAA,CAAY,GAAA,EAAuB,WAAA,EAAoC;AACrE,IAAA,KAAA,CAAM,GAAG,qCAAA;AACT,IAAA,IAAA,CAAK,mBAAA,CAAoB,WAAW,CAAA;AACpC,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,OAAA,EAAS,WAAA;AAAA,EAC3B;AAAA,EAEQ,mBAAA,CAAoB,WAAA,EAAoC;AAC9D,IAAA,GAAA,CAAI,CAAC,WAAA,EAAa,MAAM,IAAI,sCAAA,CAAiB,iCAAiC,CAAA;AAC9E,IAAA,GAAA,CAAI,YAAA,WAAuB,6BAAA,EAAc,MAAM,IAAI,sCAAA,CAAiB,0BAA0B,CAAA;AAC9F,IAAA,IAAA,CAAA,MAAW,CAAC,GAAA,EAAK,KAAK,EAAA,GAAK,MAAA,CAAO,OAAA,CAAQ,WAAW,CAAA,EAAG;AACtD,MAAA,GAAA,CAAI,CAAA,CAAE,MAAA,WAAiB,6BAAA,CAAA;AACrB,QAAA,MAAM,IAAI,sCAAA,CAAiB,CAAA,8CAAA,EAAiD,GAAG,CAAA,CAAA,CAAG,CAAA;AAAA,IACtF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBO,iBAAA,CAAA,EAA0B;AAC/B,IAAA,IAAA,CAAK,0BAAS,CAAA,CAAE,6BAAA,EAA+B,IAAA;AAC/C,IAAA,OAAO,IAAA;AAAA,EACT;AACF,UAAA;ADMA;AACA;AACE;AACF,oCAAC","file":"/home/runner/work/bguard/bguard/lib/chunk-6TH3DBDK.js","sourcesContent":[null,"import { ctxSymbol } from '../helpers/core';\nimport { BuildSchemaError } from '../exceptions';\nimport { CommonSchema, ObjectShapeSchemaType, ValidatorContext } from './CommonSchema';\n\nexport class ObjectSchema extends CommonSchema {\n _object = 1;\n constructor(ctx: ValidatorContext, shapeSchema: ObjectShapeSchemaType) {\n super(ctx);\n this.validateObjectEntry(shapeSchema);\n this[ctxSymbol].object = shapeSchema;\n }\n\n private validateObjectEntry(shapeSchema: ObjectShapeSchemaType) {\n if (!shapeSchema) throw new BuildSchemaError('Missing schema in object method');\n if (shapeSchema instanceof CommonSchema) throw new BuildSchemaError('Invalid schema in object');\n for (const [key, value] of Object.entries(shapeSchema)) {\n if (!(value instanceof CommonSchema))\n throw new BuildSchemaError(`Invalid schema in object method for property '${key}'`);\n }\n }\n\n /**\n * Allows unrecognized properties in the validated object.\n * When this method is called, the validation will not fail\n * if the received object contains properties not specified\n * in the validation schema.\n *\n * @returns {this} The current ObjectSchema instance.\n *\n * @example\n * const userSchema = object({\n * name: string(),\n * age: number(),\n * }).allowUnrecognized();\n *\n * parseOrFail(userSchema, ({ name: 'John', age: 30, extra: 'value' }););\n * // No error thrown\n */\n public allowUnrecognized(): this {\n this[ctxSymbol].allowUnrecognizedObjectProps = true;\n return this;\n }\n}\n\nexport type WithObject<Y extends ObjectShapeSchemaType> = ObjectSchema & { validation_object: Y };\n"]}