bguard 0.1.0 → 0.2.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 (422) hide show
  1. package/README.md +567 -29
  2. package/lib/{CommonSchema-BbGNki0L.d.ts → CommonSchema-9RtxTxdX.d.ts} +3 -2
  3. package/lib/{CommonSchema-CjsYE4dC.d.mts → CommonSchema-DJmQ3F_9.d.mts} +3 -2
  4. package/lib/InferType.d.mts +5 -2
  5. package/lib/InferType.d.ts +5 -2
  6. package/lib/asserts/array/index.d.mts +4 -4
  7. package/lib/asserts/array/index.d.ts +4 -4
  8. package/lib/asserts/array/index.js +10 -5
  9. package/lib/asserts/array/index.js.map +1 -1
  10. package/lib/asserts/array/index.mjs +10 -5
  11. package/lib/asserts/array/index.mjs.map +1 -1
  12. package/lib/asserts/bigint/bigintMax.d.mts +22 -0
  13. package/lib/asserts/bigint/bigintMax.d.ts +22 -0
  14. package/lib/asserts/bigint/bigintMax.js +20 -0
  15. package/lib/asserts/bigint/bigintMax.js.map +1 -0
  16. package/lib/asserts/bigint/bigintMax.mjs +20 -0
  17. package/lib/asserts/bigint/bigintMax.mjs.map +1 -0
  18. package/lib/asserts/bigint/bigintMaxExcluded.d.mts +22 -0
  19. package/lib/asserts/bigint/bigintMaxExcluded.d.ts +22 -0
  20. package/lib/asserts/bigint/bigintMaxExcluded.js +20 -0
  21. package/lib/asserts/bigint/bigintMaxExcluded.js.map +1 -0
  22. package/lib/asserts/bigint/bigintMaxExcluded.mjs +20 -0
  23. package/lib/asserts/bigint/bigintMaxExcluded.mjs.map +1 -0
  24. package/lib/asserts/bigint/bigintMin.d.mts +22 -0
  25. package/lib/asserts/bigint/bigintMin.d.ts +22 -0
  26. package/lib/asserts/bigint/bigintMin.js +20 -0
  27. package/lib/asserts/bigint/bigintMin.js.map +1 -0
  28. package/lib/asserts/bigint/bigintMin.mjs +20 -0
  29. package/lib/asserts/bigint/bigintMin.mjs.map +1 -0
  30. package/lib/asserts/bigint/bigintMinExcluded.d.mts +22 -0
  31. package/lib/asserts/bigint/bigintMinExcluded.d.ts +22 -0
  32. package/lib/asserts/bigint/bigintMinExcluded.js +20 -0
  33. package/lib/asserts/bigint/bigintMinExcluded.js.map +1 -0
  34. package/lib/asserts/bigint/bigintMinExcluded.mjs +20 -0
  35. package/lib/asserts/bigint/bigintMinExcluded.mjs.map +1 -0
  36. package/lib/asserts/bigint/index.d.mts +18 -0
  37. package/lib/asserts/bigint/index.d.ts +18 -0
  38. package/lib/asserts/bigint/index.js +21 -0
  39. package/lib/asserts/bigint/index.js.map +1 -0
  40. package/lib/asserts/bigint/index.mjs +21 -0
  41. package/lib/asserts/bigint/index.mjs.map +1 -0
  42. package/lib/asserts/boolean/index.d.mts +4 -4
  43. package/lib/asserts/boolean/index.d.ts +4 -4
  44. package/lib/asserts/boolean/index.js +11 -6
  45. package/lib/asserts/boolean/index.js.map +1 -1
  46. package/lib/asserts/boolean/index.mjs +11 -6
  47. package/lib/asserts/boolean/index.mjs.map +1 -1
  48. package/lib/asserts/date/dateMax.d.mts +22 -0
  49. package/lib/asserts/date/dateMax.d.ts +22 -0
  50. package/lib/asserts/date/dateMax.js +28 -0
  51. package/lib/asserts/date/dateMax.js.map +1 -0
  52. package/lib/asserts/date/dateMax.mjs +28 -0
  53. package/lib/asserts/date/dateMax.mjs.map +1 -0
  54. package/lib/asserts/date/dateMin.d.mts +22 -0
  55. package/lib/asserts/date/dateMin.d.ts +22 -0
  56. package/lib/asserts/date/dateMin.js +28 -0
  57. package/lib/asserts/date/dateMin.js.map +1 -0
  58. package/lib/asserts/date/dateMin.mjs +28 -0
  59. package/lib/asserts/date/dateMin.mjs.map +1 -0
  60. package/lib/asserts/date/index.d.mts +17 -0
  61. package/lib/asserts/date/index.d.ts +17 -0
  62. package/lib/asserts/date/index.js +16 -0
  63. package/lib/asserts/date/index.js.map +1 -0
  64. package/lib/asserts/date/index.mjs +16 -0
  65. package/lib/asserts/date/index.mjs.map +1 -0
  66. package/lib/asserts/mix/equalTo.d.mts +1 -1
  67. package/lib/asserts/mix/equalTo.d.ts +1 -1
  68. package/lib/asserts/mix/equalTo.js +3 -3
  69. package/lib/asserts/mix/equalTo.mjs +2 -2
  70. package/lib/asserts/mix/index.d.mts +4 -3
  71. package/lib/asserts/mix/index.d.ts +4 -3
  72. package/lib/asserts/mix/index.js +9 -4
  73. package/lib/asserts/mix/index.js.map +1 -1
  74. package/lib/asserts/mix/index.mjs +9 -4
  75. package/lib/asserts/mix/index.mjs.map +1 -1
  76. package/lib/asserts/mix/oneOfValues.d.mts +1 -1
  77. package/lib/asserts/mix/oneOfValues.d.ts +1 -1
  78. package/lib/asserts/mix/oneOfValues.js +3 -3
  79. package/lib/asserts/mix/oneOfValues.mjs +2 -2
  80. package/lib/asserts/number/index.d.mts +4 -4
  81. package/lib/asserts/number/index.d.ts +4 -4
  82. package/lib/asserts/number/index.js +15 -9
  83. package/lib/asserts/number/index.js.map +1 -1
  84. package/lib/asserts/number/index.mjs +15 -9
  85. package/lib/asserts/number/index.mjs.map +1 -1
  86. package/lib/asserts/number/max.js +2 -2
  87. package/lib/asserts/number/max.mjs +1 -1
  88. package/lib/asserts/number/maxExcluded.js +2 -2
  89. package/lib/asserts/number/maxExcluded.mjs +1 -1
  90. package/lib/asserts/number/min.js +2 -2
  91. package/lib/asserts/number/min.mjs +1 -1
  92. package/lib/asserts/number/minExcluded.js +2 -2
  93. package/lib/asserts/number/minExcluded.mjs +1 -1
  94. package/lib/asserts/number/negative.js +2 -2
  95. package/lib/asserts/number/negative.mjs +1 -1
  96. package/lib/asserts/number/positive.js +2 -2
  97. package/lib/asserts/number/positive.mjs +1 -1
  98. package/lib/asserts/object/index.d.mts +4 -4
  99. package/lib/asserts/object/index.d.ts +4 -4
  100. package/lib/asserts/object/index.js +10 -5
  101. package/lib/asserts/object/index.js.map +1 -1
  102. package/lib/asserts/object/index.mjs +10 -5
  103. package/lib/asserts/object/index.mjs.map +1 -1
  104. package/lib/asserts/string/atLeastOneDigit.d.mts +20 -0
  105. package/lib/asserts/string/atLeastOneDigit.d.ts +20 -0
  106. package/lib/asserts/string/atLeastOneDigit.js +21 -0
  107. package/lib/asserts/string/atLeastOneDigit.js.map +1 -0
  108. package/lib/asserts/string/atLeastOneDigit.mjs +21 -0
  109. package/lib/asserts/string/atLeastOneDigit.mjs.map +1 -0
  110. package/lib/asserts/string/atLeastOneLowerChar.d.mts +20 -0
  111. package/lib/asserts/string/atLeastOneLowerChar.d.ts +20 -0
  112. package/lib/asserts/string/atLeastOneLowerChar.js +22 -0
  113. package/lib/asserts/string/atLeastOneLowerChar.js.map +1 -0
  114. package/lib/asserts/string/atLeastOneLowerChar.mjs +22 -0
  115. package/lib/asserts/string/atLeastOneLowerChar.mjs.map +1 -0
  116. package/lib/asserts/string/atLeastOneSpecialChar.d.mts +25 -0
  117. package/lib/asserts/string/atLeastOneSpecialChar.d.ts +25 -0
  118. package/lib/asserts/string/atLeastOneSpecialChar.js +26 -0
  119. package/lib/asserts/string/atLeastOneSpecialChar.js.map +1 -0
  120. package/lib/asserts/string/atLeastOneSpecialChar.mjs +26 -0
  121. package/lib/asserts/string/atLeastOneSpecialChar.mjs.map +1 -0
  122. package/lib/asserts/string/atLeastOneUpperChar.d.mts +20 -0
  123. package/lib/asserts/string/atLeastOneUpperChar.d.ts +20 -0
  124. package/lib/asserts/string/atLeastOneUpperChar.js +22 -0
  125. package/lib/asserts/string/atLeastOneUpperChar.js.map +1 -0
  126. package/lib/asserts/string/atLeastOneUpperChar.mjs +22 -0
  127. package/lib/asserts/string/atLeastOneUpperChar.mjs.map +1 -0
  128. package/lib/asserts/string/contains.d.mts +21 -0
  129. package/lib/asserts/string/contains.d.ts +21 -0
  130. package/lib/asserts/string/contains.js +22 -0
  131. package/lib/asserts/string/contains.js.map +1 -0
  132. package/lib/asserts/string/contains.mjs +22 -0
  133. package/lib/asserts/string/contains.mjs.map +1 -0
  134. package/lib/asserts/string/email.js +2 -2
  135. package/lib/asserts/string/email.mjs +1 -1
  136. package/lib/asserts/string/endsWith.d.mts +21 -0
  137. package/lib/asserts/string/endsWith.d.ts +21 -0
  138. package/lib/asserts/string/endsWith.js +22 -0
  139. package/lib/asserts/string/endsWith.js.map +1 -0
  140. package/lib/asserts/string/endsWith.mjs +22 -0
  141. package/lib/asserts/string/endsWith.mjs.map +1 -0
  142. package/lib/asserts/string/index.d.mts +4 -4
  143. package/lib/asserts/string/index.d.ts +4 -4
  144. package/lib/asserts/string/index.js +15 -9
  145. package/lib/asserts/string/index.js.map +1 -1
  146. package/lib/asserts/string/index.mjs +15 -9
  147. package/lib/asserts/string/index.mjs.map +1 -1
  148. package/lib/asserts/string/lowerCase.d.mts +20 -0
  149. package/lib/asserts/string/lowerCase.d.ts +20 -0
  150. package/lib/asserts/string/lowerCase.js +20 -0
  151. package/lib/asserts/string/lowerCase.js.map +1 -0
  152. package/lib/asserts/string/lowerCase.mjs +20 -0
  153. package/lib/asserts/string/lowerCase.mjs.map +1 -0
  154. package/lib/asserts/string/maxLength.d.mts +1 -1
  155. package/lib/asserts/string/maxLength.d.ts +1 -1
  156. package/lib/asserts/string/maxLength.js +2 -2
  157. package/lib/asserts/string/maxLength.js.map +1 -1
  158. package/lib/asserts/string/maxLength.mjs +1 -1
  159. package/lib/asserts/string/maxLength.mjs.map +1 -1
  160. package/lib/asserts/string/minLength.d.mts +1 -1
  161. package/lib/asserts/string/minLength.d.ts +1 -1
  162. package/lib/asserts/string/minLength.js +2 -2
  163. package/lib/asserts/string/minLength.js.map +1 -1
  164. package/lib/asserts/string/minLength.mjs +1 -1
  165. package/lib/asserts/string/minLength.mjs.map +1 -1
  166. package/lib/asserts/string/regExp.d.mts +1 -1
  167. package/lib/asserts/string/regExp.d.ts +1 -1
  168. package/lib/asserts/string/regExp.js +2 -2
  169. package/lib/asserts/string/regExp.js.map +1 -1
  170. package/lib/asserts/string/regExp.mjs +1 -1
  171. package/lib/asserts/string/regExp.mjs.map +1 -1
  172. package/lib/asserts/string/startsWith.d.mts +21 -0
  173. package/lib/asserts/string/startsWith.d.ts +21 -0
  174. package/lib/asserts/string/startsWith.js +22 -0
  175. package/lib/asserts/string/startsWith.js.map +1 -0
  176. package/lib/asserts/string/startsWith.mjs +22 -0
  177. package/lib/asserts/string/startsWith.mjs.map +1 -0
  178. package/lib/asserts/string/upperCase.d.mts +21 -0
  179. package/lib/asserts/string/upperCase.d.ts +21 -0
  180. package/lib/asserts/string/upperCase.js +22 -0
  181. package/lib/asserts/string/upperCase.js.map +1 -0
  182. package/lib/asserts/string/upperCase.mjs +22 -0
  183. package/lib/asserts/string/upperCase.mjs.map +1 -0
  184. package/lib/asserts/string/uuid.d.mts +20 -0
  185. package/lib/asserts/string/uuid.d.ts +20 -0
  186. package/lib/asserts/string/uuid.js +23 -0
  187. package/lib/asserts/string/uuid.js.map +1 -0
  188. package/lib/asserts/string/uuid.mjs +23 -0
  189. package/lib/asserts/string/uuid.mjs.map +1 -0
  190. package/lib/asserts/string/uuidV1.d.mts +21 -0
  191. package/lib/asserts/string/uuidV1.d.ts +21 -0
  192. package/lib/asserts/string/uuidV1.js +23 -0
  193. package/lib/asserts/string/uuidV1.js.map +1 -0
  194. package/lib/asserts/string/uuidV1.mjs +23 -0
  195. package/lib/asserts/string/uuidV1.mjs.map +1 -0
  196. package/lib/asserts/string/uuidV2.d.mts +21 -0
  197. package/lib/asserts/string/uuidV2.d.ts +21 -0
  198. package/lib/asserts/string/uuidV2.js +23 -0
  199. package/lib/asserts/string/uuidV2.js.map +1 -0
  200. package/lib/asserts/string/uuidV2.mjs +23 -0
  201. package/lib/asserts/string/uuidV2.mjs.map +1 -0
  202. package/lib/asserts/string/uuidV3.d.mts +21 -0
  203. package/lib/asserts/string/uuidV3.d.ts +21 -0
  204. package/lib/asserts/string/uuidV3.js +23 -0
  205. package/lib/asserts/string/uuidV3.js.map +1 -0
  206. package/lib/asserts/string/uuidV3.mjs +23 -0
  207. package/lib/asserts/string/uuidV3.mjs.map +1 -0
  208. package/lib/asserts/string/uuidV4.d.mts +23 -0
  209. package/lib/asserts/string/uuidV4.d.ts +23 -0
  210. package/lib/asserts/string/uuidV4.js +23 -0
  211. package/lib/asserts/string/uuidV4.js.map +1 -0
  212. package/lib/asserts/string/uuidV4.mjs +23 -0
  213. package/lib/asserts/string/uuidV4.mjs.map +1 -0
  214. package/lib/asserts/string/uuidV5.d.mts +21 -0
  215. package/lib/asserts/string/uuidV5.d.ts +21 -0
  216. package/lib/asserts/string/uuidV5.js +23 -0
  217. package/lib/asserts/string/uuidV5.js.map +1 -0
  218. package/lib/asserts/string/uuidV5.mjs +23 -0
  219. package/lib/asserts/string/uuidV5.mjs.map +1 -0
  220. package/lib/asserts/string/validUrl.d.mts +23 -0
  221. package/lib/asserts/string/validUrl.d.ts +23 -0
  222. package/lib/asserts/string/validUrl.js +32 -0
  223. package/lib/asserts/string/validUrl.js.map +1 -0
  224. package/lib/asserts/string/validUrl.mjs +32 -0
  225. package/lib/asserts/string/validUrl.mjs.map +1 -0
  226. package/lib/{chunk-RRQOET3X.js → chunk-2OINKFOA.js} +6 -6
  227. package/lib/{chunk-RRQOET3X.js.map → chunk-2OINKFOA.js.map} +1 -1
  228. package/lib/{chunk-F5MSBL33.js → chunk-32J4WVLE.js} +21 -10
  229. package/lib/chunk-32J4WVLE.js.map +1 -0
  230. package/lib/chunk-356HMXOP.js +12 -0
  231. package/lib/chunk-356HMXOP.js.map +1 -0
  232. package/lib/chunk-42J6CHIO.js +7 -0
  233. package/lib/chunk-42J6CHIO.js.map +1 -0
  234. package/lib/{chunk-4CYIMDP2.js → chunk-4SPM2CSQ.js} +3 -3
  235. package/lib/chunk-4SPM2CSQ.js.map +1 -0
  236. package/lib/{chunk-WBERBAL4.js → chunk-4SR7J2I4.js} +6 -6
  237. package/lib/{chunk-WBERBAL4.js.map → chunk-4SR7J2I4.js.map} +1 -1
  238. package/lib/{chunk-DPBE7TAQ.mjs → chunk-4UF67IQ2.mjs} +3 -3
  239. package/lib/chunk-4UF67IQ2.mjs.map +1 -0
  240. package/lib/{chunk-RYVUYVEE.mjs → chunk-54RHVQFA.mjs} +2 -2
  241. package/lib/{chunk-YUESB2WV.mjs → chunk-5AO66YV5.mjs} +3 -3
  242. package/lib/{chunk-RQH4LXBW.js → chunk-5EIBKBYS.js} +21 -10
  243. package/lib/chunk-5EIBKBYS.js.map +1 -0
  244. package/lib/{chunk-IRG4OQAB.js → chunk-7GIRQ5EA.js} +7 -1
  245. package/lib/chunk-7GIRQ5EA.js.map +1 -0
  246. package/lib/chunk-ASZW6XRM.mjs +7 -0
  247. package/lib/chunk-ASZW6XRM.mjs.map +1 -0
  248. package/lib/{chunk-5BVJ6YMH.js → chunk-CQWI6YRI.js} +3 -2
  249. package/lib/chunk-CQWI6YRI.js.map +1 -0
  250. package/lib/{chunk-EGEHSELT.js → chunk-EQNVYAKS.js} +7 -7
  251. package/lib/chunk-EQNVYAKS.js.map +1 -0
  252. package/lib/chunk-GDSB7CDN.mjs +12 -0
  253. package/lib/chunk-GDSB7CDN.mjs.map +1 -0
  254. package/lib/chunk-LWAEUS2F.js +14 -0
  255. package/lib/{chunk-JSGZ7DKT.js.map → chunk-LWAEUS2F.js.map} +1 -1
  256. package/lib/{chunk-NNFYXHLU.mjs → chunk-M6OCVAUD.mjs} +2 -2
  257. package/lib/chunk-M6OCVAUD.mjs.map +1 -0
  258. package/lib/{chunk-PG2R7P7G.mjs → chunk-MRWZVTNH.mjs} +3 -3
  259. package/lib/{chunk-DJSLA2ZV.js → chunk-MTJJKWTP.js} +5 -5
  260. package/lib/{chunk-DJSLA2ZV.js.map → chunk-MTJJKWTP.js.map} +1 -1
  261. package/lib/{chunk-6TH3DBDK.js → chunk-N6YMNLXG.js} +8 -8
  262. package/lib/{chunk-6TH3DBDK.js.map → chunk-N6YMNLXG.js.map} +1 -1
  263. package/lib/{chunk-NDQM5OL4.mjs → chunk-PEWNA24X.mjs} +3 -3
  264. package/lib/{chunk-CCBCDJXS.mjs → chunk-PJI3DRGP.mjs} +3 -3
  265. package/lib/{chunk-TCQY2R3U.mjs → chunk-PVOHKGBW.mjs} +3 -3
  266. package/lib/chunk-QLVLZRHT.js +20 -0
  267. package/lib/chunk-QLVLZRHT.js.map +1 -0
  268. package/lib/{chunk-3HTYHE2X.mjs → chunk-QV4JDW3T.mjs} +3 -2
  269. package/lib/chunk-QV4JDW3T.mjs.map +1 -0
  270. package/lib/chunk-SEIKS6G7.js +61 -0
  271. package/lib/chunk-SEIKS6G7.js.map +1 -0
  272. package/lib/{chunk-FTLRX2XG.mjs → chunk-TP5I237J.mjs} +17 -6
  273. package/lib/chunk-TP5I237J.mjs.map +1 -0
  274. package/lib/chunk-UV4I7JZR.mjs +61 -0
  275. package/lib/chunk-UV4I7JZR.mjs.map +1 -0
  276. package/lib/{chunk-H7CPKW53.js → chunk-VGF3Y2EK.js} +5 -5
  277. package/lib/{chunk-H7CPKW53.js.map → chunk-VGF3Y2EK.js.map} +1 -1
  278. package/lib/{chunk-J4VKFJQK.js → chunk-WPHJ4QTB.js} +3 -3
  279. package/lib/chunk-WPHJ4QTB.js.map +1 -0
  280. package/lib/chunk-XFR7Y4XX.mjs +20 -0
  281. package/lib/chunk-XFR7Y4XX.mjs.map +1 -0
  282. package/lib/{chunk-PH2PMUZP.mjs → chunk-XZTZC73V.mjs} +7 -1
  283. package/lib/chunk-XZTZC73V.mjs.map +1 -0
  284. package/lib/{chunk-3O4WCRC2.mjs → chunk-YPAUFM3S.mjs} +2 -2
  285. package/lib/chunk-YPAUFM3S.mjs.map +1 -0
  286. package/lib/{chunk-CLG3QRZC.mjs → chunk-Z7OEFOAD.mjs} +17 -6
  287. package/lib/chunk-Z7OEFOAD.mjs.map +1 -0
  288. package/lib/codeGen.d.mts +1 -1
  289. package/lib/codeGen.d.ts +1 -1
  290. package/lib/codeGen.js +4 -2
  291. package/lib/codeGen.js.map +1 -1
  292. package/lib/codeGen.mjs +3 -1
  293. package/lib/codeGen.mjs.map +1 -1
  294. package/lib/commonTypes.d.mts +1 -0
  295. package/lib/commonTypes.d.ts +1 -0
  296. package/lib/helpers/constants.d.mts +3 -0
  297. package/lib/helpers/constants.d.ts +3 -0
  298. package/lib/helpers/constants.js +7 -0
  299. package/lib/helpers/constants.js.map +1 -0
  300. package/lib/helpers/constants.mjs +7 -0
  301. package/lib/helpers/constants.mjs.map +1 -0
  302. package/lib/helpers/core.d.mts +1 -1
  303. package/lib/helpers/core.d.ts +1 -1
  304. package/lib/helpers/core.js +3 -2
  305. package/lib/helpers/core.js.map +1 -1
  306. package/lib/helpers/core.mjs +2 -1
  307. package/lib/helpers/isValidDate.d.mts +3 -0
  308. package/lib/helpers/isValidDate.d.ts +3 -0
  309. package/lib/helpers/isValidDate.js +7 -0
  310. package/lib/helpers/isValidDate.js.map +1 -0
  311. package/lib/helpers/isValidDate.mjs +7 -0
  312. package/lib/helpers/isValidDate.mjs.map +1 -0
  313. package/lib/helpers/setStrictType.d.mts +1 -1
  314. package/lib/helpers/setStrictType.d.ts +1 -1
  315. package/lib/helpers/setStrictType.js +4 -3
  316. package/lib/helpers/setStrictType.js.map +1 -1
  317. package/lib/helpers/setStrictType.mjs +3 -2
  318. package/lib/index.d.mts +3 -7
  319. package/lib/index.d.ts +3 -7
  320. package/lib/index.js +6 -38
  321. package/lib/index.js.map +1 -1
  322. package/lib/index.mjs +6 -38
  323. package/lib/parse.d.mts +3 -1
  324. package/lib/parse.d.ts +3 -1
  325. package/lib/parse.js +5 -4
  326. package/lib/parse.js.map +1 -1
  327. package/lib/parse.mjs +4 -3
  328. package/lib/parseOrFail.d.mts +3 -1
  329. package/lib/parseOrFail.d.ts +3 -1
  330. package/lib/parseOrFail.js +5 -4
  331. package/lib/parseOrFail.js.map +1 -1
  332. package/lib/parseOrFail.mjs +4 -3
  333. package/lib/schemas/ArraySchema.d.mts +1 -1
  334. package/lib/schemas/ArraySchema.d.ts +1 -1
  335. package/lib/schemas/ArraySchema.js +5 -4
  336. package/lib/schemas/ArraySchema.js.map +1 -1
  337. package/lib/schemas/ArraySchema.mjs +4 -3
  338. package/lib/schemas/BigIntSchema.d.mts +32 -0
  339. package/lib/schemas/BigIntSchema.d.ts +32 -0
  340. package/lib/schemas/BigIntSchema.js +16 -0
  341. package/lib/schemas/BigIntSchema.js.map +1 -0
  342. package/lib/schemas/BigIntSchema.mjs +16 -0
  343. package/lib/schemas/BigIntSchema.mjs.map +1 -0
  344. package/lib/schemas/BooleanSchema.d.mts +1 -1
  345. package/lib/schemas/BooleanSchema.d.ts +1 -1
  346. package/lib/schemas/BooleanSchema.js +6 -5
  347. package/lib/schemas/BooleanSchema.js.map +1 -1
  348. package/lib/schemas/BooleanSchema.mjs +5 -4
  349. package/lib/schemas/CommonSchema.d.mts +1 -1
  350. package/lib/schemas/CommonSchema.d.ts +1 -1
  351. package/lib/schemas/CommonSchema.js +4 -3
  352. package/lib/schemas/CommonSchema.js.map +1 -1
  353. package/lib/schemas/CommonSchema.mjs +3 -2
  354. package/lib/schemas/DateSchema.d.mts +9 -0
  355. package/lib/schemas/DateSchema.d.ts +9 -0
  356. package/lib/schemas/DateSchema.js +11 -0
  357. package/lib/schemas/DateSchema.js.map +1 -0
  358. package/lib/schemas/DateSchema.mjs +11 -0
  359. package/lib/schemas/DateSchema.mjs.map +1 -0
  360. package/lib/schemas/NumberSchema.d.mts +2 -1
  361. package/lib/schemas/NumberSchema.d.ts +2 -1
  362. package/lib/schemas/NumberSchema.js +10 -8
  363. package/lib/schemas/NumberSchema.js.map +1 -1
  364. package/lib/schemas/NumberSchema.mjs +9 -7
  365. package/lib/schemas/ObjectSchema.d.mts +1 -1
  366. package/lib/schemas/ObjectSchema.d.ts +1 -1
  367. package/lib/schemas/ObjectSchema.js +5 -4
  368. package/lib/schemas/ObjectSchema.js.map +1 -1
  369. package/lib/schemas/ObjectSchema.mjs +4 -3
  370. package/lib/schemas/StringSchema.d.mts +2 -1
  371. package/lib/schemas/StringSchema.d.ts +2 -1
  372. package/lib/schemas/StringSchema.js +10 -8
  373. package/lib/schemas/StringSchema.js.map +1 -1
  374. package/lib/schemas/StringSchema.mjs +9 -7
  375. package/lib/translationMap.js +2 -2
  376. package/lib/translationMap.mjs +1 -1
  377. package/package.json +6 -1
  378. package/lib/chunk-2PM3K3OE.mjs +0 -13
  379. package/lib/chunk-2PM3K3OE.mjs.map +0 -1
  380. package/lib/chunk-3HTYHE2X.mjs.map +0 -1
  381. package/lib/chunk-3O4WCRC2.mjs.map +0 -1
  382. package/lib/chunk-4CYIMDP2.js.map +0 -1
  383. package/lib/chunk-4RNK3I74.js +0 -13
  384. package/lib/chunk-4RNK3I74.js.map +0 -1
  385. package/lib/chunk-5BVJ6YMH.js.map +0 -1
  386. package/lib/chunk-B6TFELXR.mjs +0 -13
  387. package/lib/chunk-B6TFELXR.mjs.map +0 -1
  388. package/lib/chunk-CLG3QRZC.mjs.map +0 -1
  389. package/lib/chunk-DPBE7TAQ.mjs.map +0 -1
  390. package/lib/chunk-EGEHSELT.js.map +0 -1
  391. package/lib/chunk-F5MSBL33.js.map +0 -1
  392. package/lib/chunk-FTLRX2XG.mjs.map +0 -1
  393. package/lib/chunk-HDSGCAHH.js +0 -13
  394. package/lib/chunk-HDSGCAHH.js.map +0 -1
  395. package/lib/chunk-IEUXIOL6.js +0 -13
  396. package/lib/chunk-IEUXIOL6.js.map +0 -1
  397. package/lib/chunk-IRG4OQAB.js.map +0 -1
  398. package/lib/chunk-J4VKFJQK.js.map +0 -1
  399. package/lib/chunk-JDGZCBXF.mjs +0 -13
  400. package/lib/chunk-JDGZCBXF.mjs.map +0 -1
  401. package/lib/chunk-JSGZ7DKT.js +0 -14
  402. package/lib/chunk-MRISXZQ4.mjs +0 -13
  403. package/lib/chunk-MRISXZQ4.mjs.map +0 -1
  404. package/lib/chunk-NNFYXHLU.mjs.map +0 -1
  405. package/lib/chunk-NTC2XQ36.mjs +0 -13
  406. package/lib/chunk-NTC2XQ36.mjs.map +0 -1
  407. package/lib/chunk-PH2PMUZP.mjs.map +0 -1
  408. package/lib/chunk-QQNQ4IDN.js +0 -13
  409. package/lib/chunk-QQNQ4IDN.js.map +0 -1
  410. package/lib/chunk-RL4MSI7R.js +0 -13
  411. package/lib/chunk-RL4MSI7R.js.map +0 -1
  412. package/lib/chunk-RQH4LXBW.js.map +0 -1
  413. package/lib/chunk-VHEA4JZ5.js +0 -13
  414. package/lib/chunk-VHEA4JZ5.js.map +0 -1
  415. package/lib/chunk-YML32TPA.mjs +0 -13
  416. package/lib/chunk-YML32TPA.mjs.map +0 -1
  417. /package/lib/{chunk-RYVUYVEE.mjs.map → chunk-54RHVQFA.mjs.map} +0 -0
  418. /package/lib/{chunk-YUESB2WV.mjs.map → chunk-5AO66YV5.mjs.map} +0 -0
  419. /package/lib/{chunk-PG2R7P7G.mjs.map → chunk-MRWZVTNH.mjs.map} +0 -0
  420. /package/lib/{chunk-NDQM5OL4.mjs.map → chunk-PEWNA24X.mjs.map} +0 -0
  421. /package/lib/{chunk-CCBCDJXS.mjs.map → chunk-PJI3DRGP.mjs.map} +0 -0
  422. /package/lib/{chunk-TCQY2R3U.mjs.map → chunk-PVOHKGBW.mjs.map} +0 -0
package/README.md CHANGED
@@ -30,7 +30,12 @@ Let's define a schema for a Student object:
30
30
 
31
31
  ```typeScript
32
32
 
33
- import { InferType, string, number, array, object, boolean } from 'bguard';
33
+ import { InferType } from 'bguard';
34
+ import { object } from 'bguard/object';
35
+ import { array } from 'bguard/array';
36
+ import { number } from 'bguard/number';
37
+ import { string } from 'bguard/string';
38
+ import { boolean } from 'bguard/boolean';
34
39
  import { email } from 'bguard/string/email';
35
40
  import { min } from 'bguard/number/min';
36
41
  import { max } from 'bguard/number/max';
@@ -78,10 +83,8 @@ type StudentSchema = {
78
83
 
79
84
  ```
80
85
 
81
-
82
86
  #### Generating TypeScript Types with `codeGen`
83
87
 
84
-
85
88
  If you prefer to generate TypeScript types as a string, you can use the `codeGen` function:
86
89
 
87
90
  ```typeScript
@@ -112,6 +115,7 @@ This would output a string:
112
115
  verified?: boolean | undefined;
113
116
  }
114
117
  ```
118
+
115
119
  Note: The returned string does not include a type name or the `=` symbol. You would need to add these manually if you want a complete type definition.
116
120
 
117
121
  #### Generating Named TypeScript Types with `codeGenWithName`
@@ -133,7 +137,6 @@ console.log(namedTypeString);
133
137
 
134
138
  This would output a string:
135
139
 
136
-
137
140
  ```typeScript
138
141
  type StudentSchema = {
139
142
  email?: string | undefined;
@@ -147,13 +150,13 @@ type StudentSchema = {
147
150
  verified?: boolean | undefined;
148
151
  }
149
152
  ```
153
+
150
154
  #### Summary:
151
155
 
152
156
  `codeGen(schema: CommonSchema): string` - Generates a string of the TypeScript type based on the schema. You need to manually add a type name and assignment if needed.
153
157
 
154
158
  `codeGenWithName(typeName: string, schema: CommonSchema): string` - Generates a complete TypeScript type definition string, including the type keyword and type name.
155
159
 
156
-
157
160
  ### Validating Data
158
161
 
159
162
  This library provides two methods to parse data against schemas: `parse` and `parseOrFail`. These methods help in validating the data and obtaining structured errors if any issues are found during validation.
@@ -188,15 +191,12 @@ const invalidStudentData = {
188
191
  ],
189
192
  email: 'invalid-example',
190
193
  };
191
-
192
194
  ```
193
195
 
194
-
195
196
  #### `parse` Method
196
197
 
197
198
  The `parse` method validates the data and returns a tuple containing errors and the parsed value. This method allows you to choose whether to collect all errors or stop at the first error using an options flag.
198
199
 
199
-
200
200
  **Syntax:**
201
201
 
202
202
  ```typescript
@@ -235,16 +235,18 @@ try {
235
235
  console.error(error.message); // Logs the first validation error message, if any
236
236
  }
237
237
  ```
238
+
238
239
  Throws:
240
+
239
241
  - `ValidationError`: If any validation rule fails, this error is thrown with details of the first encountered error.
240
242
 
241
243
  Options:
242
- - `lng`: Specifies the language for error messages. Default is `'default'`.
243
244
 
245
+ - `lng`: Specifies the language for error messages. Default is `'default'`.
244
246
 
245
247
  ####
246
248
 
247
- ### Explanation
249
+ Explanation
248
250
 
249
251
  - **`parse` Method**: This method returns a tuple where the first element is an array of validation errors (if any), and the second element is the successfully parsed value (or `undefined` if errors exist). It allows collecting all errors by setting the `getAllErrors` flag.
250
252
 
@@ -276,9 +278,12 @@ const schema = string().nullable().optional();
276
278
  `boolean().onlyTrue()` will infer <b>true</b> as the type.
277
279
  `boolean().onlyFalse()` will infer <b>false</b> as the type.
278
280
 
279
- ### Custom Assertions
281
+ ### Custom (Library Built-in) Assertions
280
282
 
281
- You can extend the validation with custom assertions:
283
+ The `custom` method allows you to extend the validation schema with additional asserts. These asserts can either be user-defined or selected from the comprehensive set provided by the library. This flexibility ensures that you can tailor validations to meet specific requirements beyond the standard methods available.
284
+ All built-in asserts are documented in the [Built-in Custom Assert Documentation](#builtin_custom_assert_documentation) section.
285
+
286
+ Example
282
287
 
283
288
  ```typeScript
284
289
  import { min } from 'bguard/number/min';
@@ -287,10 +292,53 @@ import { max } from 'bguard/number/max';
287
292
  const ageSchema = number().custom(min(18), max(120));
288
293
  ```
289
294
 
290
- Assertions are imported from specific paths for better tree-shaking and smaller bundle sizes.
295
+ Library built-in assertions are imported from specific paths for better tree-shaking and smaller bundle sizes.
296
+
297
+ ### Create Custom Assertions
298
+
299
+ Bguard allows developers to create custom validation functions that can be integrated seamlessly with the library's existing functionality. Below is a detailed example demonstrating how to create a custom validation function, `minLength`, and how to properly document and map error messages for translations.
300
+
301
+ Example: Creating a `minLength` Custom Validation
302
+
303
+ ```typescript
304
+ import { guardException } from 'bguard/exceptions';
305
+ import { ExceptionContext, RequiredValidation } from 'bguard/commonTypes';
306
+ import { setToDefaultLocale } from 'bguard/translationMap';
307
+
308
+ const minLengthErrorMessage = 'The received value {{r}} is shorter than the expected length {{e}}';
309
+ const minLengthErrorKey = 'customPrefix:minLength';
310
+
311
+ export const minLength =
312
+ (expected: number): RequiredValidation =>
313
+ (received: string, ctx: ExceptionContext) => {
314
+ if (received.length < expected) {
315
+ guardException(expected, received, ctx, minLengthErrorKey);
316
+ }
317
+ };
318
+
319
+ minLength.key = minLengthErrorKey;
320
+ minLength.message = minLengthErrorMessage;
321
+ setToDefaultLocale(minLength);
322
+ ```
323
+
324
+ Explanation
325
+
326
+ - Error Key (`minLength.key`): This key (`'customPrefix:minLength'`) uniquely identifies the validation and is used for mapping error messages, especially when supporting multiple languages. It's essential to avoid collisions with built-in assertions, which use prefixes like `s:`, `n:`, and `b:` etc. More on that in [Common and Custom Translations](#common_and_custom_translations).
327
+
328
+ - Error Message (`minLength.message`): The message supports [interpolation](#translation), where `{{e}}` will be replaced by the expected value, and `{{r}}` will be replaced by the received value during validation .
329
+
330
+ - Exception Handling (`guardException`): This function is responsible for throwing the error when the validation fails. The `ctx` parameter must be passed to ensure the internal logic of the application works correctly.
331
+
332
+ - Localization Support (`setToDefaultLocale`): This function registers the default error message with its associated key. If you later decide to support multiple languages, you can easily map this key to different messages.
291
333
 
334
+ - Key Points for Developers:
292
335
 
293
- ### Translation
336
+ 1. Always create unique error keys for custom validations to avoid potential conflicts with Bguard's built-in validations.
337
+ 2. Custom validations should use prefixes other than `s:`, `n:`, `b:`, and similar ones reserved for Bguard's internal validations.
338
+ 3. The `minLengthErrorMessage` serves as the default message. If you want to provide translations, you can do so by mapping the error key in the translationMap.
339
+ For single-language applications, you can override the default message by directly passing your custom message to `guardException`.
340
+
341
+ ### Translation {#translation}
294
342
 
295
343
  Bguard provides default translations for error messages, but you can customize them as needed. Each potential error has an `errorKey` and `errorMessage`.
296
344
 
@@ -319,19 +367,17 @@ setLocale('SR', {
319
367
  // ... continue adding other translations
320
368
  });
321
369
  ```
370
+
322
371
  With this setup, in the translation namespace 'SR', if the received value is 4, you'll get an error message like:
323
372
 
324
373
  `'The received value 4 found on path .foo is less than expected value 5'`
325
374
 
326
- - `{{r}}` - Replaced with the received value.
327
- - `{{p}}` - Replaced with the path to the error.
328
- - `{{e}}` - Replaced with the expected value.
329
-
375
+ - `{{r}}` - Replaced with the received value.
376
+ - `{{p}}` - Replaced with the path to the error.
377
+ - `{{e}}` - Replaced with the expected value.
330
378
 
331
379
  > **Notice:** Do not overwrite the 'default' namespace. If a translation is missing, it will fall back to the 'default' translation.
332
380
 
333
-
334
-
335
381
  #### Using Translations
336
382
 
337
383
  To apply the new translation, both `parse` and `parseOrFail` functions accept a lng property in the options object provided as the third parameter:
@@ -342,8 +388,7 @@ parseOrFail(testSchema, { foo: 4 }, { lng: 'SR' });
342
388
  parse(testSchema, { foo: 4 }, { lng: 'SR' });
343
389
  ```
344
390
 
345
-
346
- #### Common and Custom Translations
391
+ #### Common and Custom Translations {#common_and_custom_translations}
347
392
 
348
393
  We have two sets of translations: common errors and specific assertions.
349
394
 
@@ -359,13 +404,14 @@ We have two sets of translations: common errors and specific assertions.
359
404
  'c:requiredProperty': 'Missing required property in the object',
360
405
  'c:invalidType': 'Invalid type of data',
361
406
  'c:isBoolean': 'The received value is not {{e}}',
407
+ 'c:date': 'The received value is not a valid instance of Date',
362
408
  ```
363
409
 
364
410
  <b>Custom Assertion Translations</b>:
365
411
 
366
412
  For custom assertions, each key and message are located in separate files for better code splitting. There are multiple ways to identify a key:
367
413
 
368
- 1. Key Construction:
414
+ <b>1.</b> Key Construction:
369
415
  Keys are constructed as `'{typeId}:{functionName}'`, where `typeId` represents:
370
416
 
371
417
  - c - common
@@ -378,6 +424,7 @@ Keys are constructed as `'{typeId}:{functionName}'`, where `typeId` represents:
378
424
  - f - function
379
425
  - bi - bigint
380
426
  - m - mixed
427
+ - dt - date
381
428
 
382
429
  Each `typeId` maps to the folder from which custom assertions are retrieved (except 'common', as explained above).
383
430
 
@@ -386,9 +433,10 @@ Example:
386
433
  ```typeScript
387
434
  import { maxLength } from 'bguard/string/maxLength';
388
435
  ```
436
+
389
437
  The function located in `'bguard/string/maxLength'` will have the key `'s:maxLength'`.
390
438
 
391
- 2. Assertion Function Properties:
439
+ <b>2.</b> Assertion Function Properties:
392
440
 
393
441
  Each assert function has two additional properties: `key` and `message`.
394
442
 
@@ -398,12 +446,181 @@ import { maxLength } from 'bguard/string/maxLength';
398
446
  console.log(maxLength.key); // Output: 's:maxLength'
399
447
  console.log(maxLength.message); // Output: 'The received value length is greater than expected'
400
448
  ```
449
+
401
450
  > **Notice:** Do not directly change these values.
402
451
 
403
- 3. IDE Support:
404
- Each key and message will be visible in text editors that support JSDoc IntelliSense.### Custom Assert Documentation
452
+ <b>3.</b> IDE Support:
453
+ Each key and message will be visible in text editors that support JSDoc IntelliSense.
405
454
 
455
+ ### Built-in Custom Assert Documentation {#builtin_custom_assert_documentation}
456
+
457
+ #### bigint
458
+
459
+ <b>Prerequisites</b>
460
+
461
+ ```typescript
462
+ import { bigint } from 'bguard/bigint';
463
+ ```
464
+
465
+ * _Description_ Creates a new schema for validating bigint values.
466
+ * _Example_
467
+ ```typescript
468
+ const schema = bigint();
469
+ parseOrFail(schema, 42n); // Validates successfully
470
+ parseOrFail(schema, 42); // Throws a validation error
471
+ parseOrFail(schema, '42'); // Throws a validation error
472
+ ```
473
+
474
+
475
+ ##### bigintMax (bigint)
476
+
477
+ ```typescript
478
+ import { bigintMax } from 'bguard/bigint/bigintMax';
479
+ ```
480
+
481
+ * _Description_ Asserts that a bigint value does not exceed a specified maximum value.
482
+ * _Param_ {bigint} expected The maximum allowable value.
483
+ * _Throws_ {ValidationError} if the received value exceeds the expected maximum value.
484
+ * _Example_
485
+ ```typescript
486
+ const schema = bigint().custom(bigintMax(100n));
487
+ parseOrFail(schema, 99n); // Valid
488
+ parseOrFail(schema, 100n); // Valid
489
+ parseOrFail(schema, 101n); // Throws an error: 'The received value is greater than expected'
490
+ ```
491
+ * _See_ Error Translation Key = 'bi:max'
492
+
493
+
494
+ ##### bigintMaxExcluded (bigint)
495
+
496
+ ```typescript
497
+ import { bigintMaxExcluded } from 'bguard/bigint/bigintMaxExcluded';
498
+ ```
499
+
500
+ * _Description_ - Asserts that a bigint value is strictly less than a specified maximum value (i.e., the maximum value is excluded).
501
+ * _Param_ {bigint} expected - The maximum allowable value, which is excluded.
502
+ * _Throws_ {ValidationError} if the received value is greater than or equal to the expected maximum value.
503
+ * _Example_
504
+ ```typescript
505
+ const schema = bigint().custom(bigintMaxExcluded(100n));
506
+ parseOrFail(schema, 99n); // Valid
507
+ parseOrFail(schema, 100n); // Throws an error: 'The received value is greater than or equal to expected'
508
+ parseOrFail(schema, 101n); // Throws an error: 'The received value is greater than or equal to expected'
509
+ ```
510
+ * _See_ Error Translation Key = 'bi:maxExcluded'
511
+
512
+
513
+ ##### bigintMin (bigint)
514
+
515
+ ```typescript
516
+ import { bigintMin } from 'bguard/bigint/bigintMin';
517
+ ```
518
+
519
+ * _Description_ Asserts that a bigint value is not less than a specified minimum value.
520
+ * _Param_ {bigint} expected The minimum allowable value.
521
+ * _Throws_ {ValidationError} if the received value is less than the expected minimum value.
522
+ * _Example_
523
+ ```typescript
524
+ const schema = bigint().custom(bigintMin(10n));
525
+ parseOrFail(schema, 11n); // Valid
526
+ parseOrFail(schema, 10n); // Valid
527
+ parseOrFail(schema, 9n); // Throws an error: 'The received value is less than expected'
528
+ ```
529
+ * _See_ Error Translation Key = 'bi:min'
530
+
531
+
532
+ ##### bigintMinExcluded (bigint)
533
+
534
+ ```typescript
535
+ import { bigintMinExcluded } from 'bguard/bigint/bigintMinExcluded';
536
+ ```
537
+
538
+ * _Description_ Asserts that a bigint value is strictly greater than a specified minimum value (i.e., the minimum value is excluded).
539
+ * _Param_ {bigint} expected The minimum allowable value, which is excluded.
540
+ * _Throws_ {ValidationError} if the received value is less than or equal to the expected minimum value.
541
+ * _Example_
542
+ ```typescript
543
+ const schema = bigint().custom(bigintMinExcluded(10n));
544
+ parseOrFail(schema, 11n); // Valid
545
+ parseOrFail(schema, 10n); // Throws an error: 'The received value is less than or equal to expected'
546
+ parseOrFail(schema, 9n); // Throws an error: 'The received value is less than or equal to expected'
547
+ ```
548
+ * _See_ Error Translation Key = 'bi:minExcluded'
549
+
550
+ #### date
551
+
552
+ <b>Prerequisites</b>
553
+
554
+ ```typescript
555
+ import { date } from 'bguard/date';
556
+ ```
557
+
558
+ * _Description_ Creates a new schema for validating date values.
559
+ * _Example_
560
+ ```typescript
561
+ const schema = date();
562
+ parseOrFail(schema, true); // Validates successfully
563
+ parseOrFail(schema, 'true'); // Throws a validation error
564
+ ```
565
+
566
+
567
+ ##### dateMax (date)
568
+
569
+ ```typescript
570
+ import { dateMax } from 'bguard/date/dateMax';
571
+ ```
572
+
573
+ * _Description_ Asserts that a date value is not greater than a specified maximum value.
574
+ * _Param_ {Date | string} expected The maximum allowable value.
575
+ * _Throws_ {ValidationError} if the received value is greater than the expected maximum value.
576
+ * _Example_
577
+ ```typescript
578
+ const schema = date().custom(dateMax('2024-12-31'));
579
+ parseOrFail(schema, new Date('2024-12-30')); // Valid
580
+ parseOrFail(schema, new Date('2024-12-31')); // Valid
581
+ parseOrFail(schema, new Date('2025-01-01')); // Throws an error: 'The received value is greater than expected'
582
+ ```
583
+ * _See_ Error Translation Key = 'dt:max'
584
+
585
+
586
+ ##### dateMin (date)
587
+
588
+ ```typescript
589
+ import { dateMin } from 'bguard/date/dateMin';
590
+ ```
591
+
592
+ * _Description_ Asserts that a number value is not less than a specified minimum value.
593
+ * _Param_ {Date | string} expected The minimum allowable value.
594
+ * _Throws_ {ValidationError} if the received value is less than the expected minimum value.
595
+ * _Example_
596
+ ```typescript
597
+ const schema = date().custom(dateMin('2023-01-01'));
598
+ parseOrFail(schema, new Date('2023-01-02')); // Valid
599
+ parseOrFail(schema, new Date('2023-01-01')); // Valid
600
+ parseOrFail(schema, new Date('2022-12-31')); // Throws an error: 'The received value is less than expected'
601
+ ```
602
+ * _See_ Error Translation Key = 'dt:min'
603
+
406
604
  #### mix
605
+
606
+ <b>Prerequisites</b>
607
+
608
+ ```typescript
609
+ import { oneOfTypes } from 'bguard/mix';
610
+ ```
611
+
612
+ * _Description_ Creates a new schema for validating values that can match any one of the specified primitive types.
613
+
614
+
615
+ * _Param_ {T} valueTypes - An array of primitive types that the value can match.
616
+ * _Example_
617
+ ```typescript
618
+ const schema = oneOfTypes(['string', 'number']);
619
+ parseOrFail(schema, 'hello'); // Validates successfully
620
+ parseOrFail(schema, 42); // Validates successfully
621
+ parseOrFail(schema, true); // Throws a validation error
622
+ ```
623
+
407
624
 
408
625
  ##### equalTo (mix)
409
626
 
@@ -412,7 +629,7 @@ import { equalTo } from 'bguard/mix/equalTo';
412
629
  ```
413
630
 
414
631
  * _Description_ Creates a custom assertion that checks if a value is equal to the expected value.
415
- * > **Notice:** It has already been implemented in the number and string schema. There is no need to use it as a custom assert.
632
+ * > **Notice:** It has already been implemented in the number, bigint and string schema. There is no need to use it as a custom assert.
416
633
  * _Param_ {unknown} expected The value that the received value is expected to match.
417
634
  * _Throws_ {ValidationError} If the received value does not match the expected value.
418
635
  * _Example_
@@ -431,7 +648,7 @@ import { oneOfValues } from 'bguard/mix/oneOfValues';
431
648
  ```
432
649
 
433
650
  * _Description_ Creates a custom assertion that checks if a value is equal to the one of expected values.
434
- * > **Notice:** It has already been implemented in the number and string schema. There is no need to use it as a custom assert.
651
+ * > **Notice:** It has already been implemented in the number, bigint and string schema. There is no need to use it as a custom assert.
435
652
  * _Param_ {unknown} expected The value that the received value is expected to match.
436
653
  * _Throws_ {ValidationError} If the received value does not match at least one of the expected values.
437
654
  * _Example_
@@ -444,6 +661,21 @@ import { oneOfValues } from 'bguard/mix/oneOfValues';
444
661
  * _See_ Error Translation Key = 'm:oneOfValues'
445
662
 
446
663
  #### number
664
+
665
+ <b>Prerequisites</b>
666
+
667
+ ```typescript
668
+ import { number } from 'bguard/number';
669
+ ```
670
+
671
+ * _Description_ Creates a new schema for validating number values.
672
+ * _Example_
673
+ ```typescript
674
+ const schema = number();
675
+ parseOrFail(schema, 42); // Validates successfully
676
+ parseOrFail(schema, '42'); // Throws a validation error
677
+ ```
678
+
447
679
 
448
680
  ##### max (number)
449
681
 
@@ -557,6 +789,112 @@ import { positive } from 'bguard/number/positive';
557
789
  * _See_ Error Translation Key = 'n:positive'
558
790
 
559
791
  #### string
792
+
793
+ <b>Prerequisites</b>
794
+
795
+ ```typescript
796
+ import { string } from 'bguard/string';
797
+ ```
798
+
799
+ * _Description_ Creates a new schema for validating string values.
800
+ * _Example_
801
+ ```typescript
802
+ const schema = string();
803
+ parseOrFail(schema, 'hello'); // Validates successfully
804
+ parseOrFail(schema, 123); // Throws a validation error
805
+ ```
806
+
807
+
808
+ ##### atLeastOneDigit (string)
809
+
810
+ ```typescript
811
+ import { atLeastOneDigit } from 'bguard/string/atLeastOneDigit';
812
+ ```
813
+
814
+ * _Description_ Asserts that a string value contains at least one digit.
815
+ * _Throws_ {ValidationError} if the received value does not contain at least one digit.
816
+ * _Example_
817
+ ```typescript
818
+ const schema = string().custom(atLeastOneDigit());
819
+ parseOrFail(schema, 'abc123'); // Valid
820
+ parseOrFail(schema, 'abcdef'); // Throws an error: 'The received value does not contain at least one digit'
821
+ ```
822
+ * _See_ Error Translation Key = 's:atLeastOneDigit'
823
+
824
+
825
+ ##### atLeastOneLowerChar (string)
826
+
827
+ ```typescript
828
+ import { atLeastOneLowerChar } from 'bguard/string/atLeastOneLowerChar';
829
+ ```
830
+
831
+ * _Description_ Asserts that a string value contains at least one lowercase character.
832
+ * _Throws_ {ValidationError} if the received value does not contain at least one lowercase character.
833
+ * _Example_
834
+ ```typescript
835
+ const schema = string().custom(atLeastOneLowerChar());
836
+ parseOrFail(schema, 'abcDEF'); // Valid
837
+ parseOrFail(schema, 'ABCDEF'); // Throws an error: 'The received value does not contain at least one lowercase character'
838
+ ```
839
+ * _See_ Error Translation Key = 's:atLeastOneLowerChar'
840
+
841
+
842
+ ##### atLeastOneSpecialChar (string)
843
+
844
+ ```typescript
845
+ import { atLeastOneSpecialChar } from 'bguard/string/atLeastOneSpecialChar';
846
+ ```
847
+
848
+ * _Description_ Asserts that a string value contains at least one special character.
849
+ * _Param_ {string} [allowedSpecialChars=* '@!#%&()^~{}'] The string containing allowed special characters. Defaults to '*@!#%&()^~{}'.
850
+ * _Throws_ {ValidationError} if the received value does not contain at least one of the allowed special characters.
851
+ * _Example_
852
+ ```typescript
853
+ const schema = string().custom(atLeastOneSpecialChar()); // Default special characters
854
+ parseOrFail(schema, 'abc!def'); // Valid
855
+ parseOrFail(schema, 'abcdef'); // Throws an error: 'The received value does not contain at least one special character'
856
+
857
+ const customSchema = string().custom(atLeastOneSpecialChar('@$')); // Custom special characters
858
+ parseOrFail(customSchema, 'abc@def'); // Valid
859
+ parseOrFail(customSchema, 'abcdef'); // Throws an error: 'The received value does not contain at least one special character'
860
+ ```
861
+ * _See_ Error Translation Key = 's:atLeastOneSpecialChar'
862
+
863
+
864
+ ##### atLeastOneUpperChar (string)
865
+
866
+ ```typescript
867
+ import { atLeastOneUpperChar } from 'bguard/string/atLeastOneUpperChar';
868
+ ```
869
+
870
+ * _Description_ Asserts that a string value contains at least one uppercase character.
871
+ * _Throws_ {ValidationError} if the received value does not contain at least one uppercase character.
872
+ * _Example_
873
+ ```typescript
874
+ const schema = string().custom(atLeastOneUpperChar());
875
+ parseOrFail(schema, 'abcDEF'); // Valid
876
+ parseOrFail(schema, 'abcdef'); // Throws an error: 'The received value does not contain at least one uppercase character'
877
+ ```
878
+ * _See_ Error Translation Key = 's:atLeastOneUpperChar'
879
+
880
+
881
+ ##### contains (string)
882
+
883
+ ```typescript
884
+ import { contains } from 'bguard/string/contains';
885
+ ```
886
+
887
+ * _Description_ Asserts that a string value contains a specified substring.
888
+ * _Param_ {string} substring The substring that must be present in the string value.
889
+ * _Throws_ {ValidationError} if the received value does not contain the required substring.
890
+ * _Example_
891
+ ```typescript
892
+ const schema = string().custom(contains('foo'));
893
+ parseOrFail(schema, 'foobar'); // Valid
894
+ parseOrFail(schema, 'bar'); // Throws an error: 'The received value does not contain the required substring'
895
+ ```
896
+ * _See_ Error Translation Key = 's:contains'
897
+
560
898
 
561
899
  ##### email (string)
562
900
 
@@ -575,6 +913,41 @@ import { email } from 'bguard/string/email';
575
913
  * _See_ - Error Translation Key = 's:email'
576
914
 
577
915
 
916
+ ##### endsWith (string)
917
+
918
+ ```typescript
919
+ import { endsWith } from 'bguard/string/endsWith';
920
+ ```
921
+
922
+ * _Description_ Asserts that a string value ends with a specified substring.
923
+ * _Param_ {string} substring The substring that the string value must end with.
924
+ * _Throws_ {ValidationError} if the received value does not end with the required substring.
925
+ * _Example_
926
+ ```typescript
927
+ const schema = string().custom(endsWith('bar'));
928
+ parseOrFail(schema, 'foobar'); // Valid
929
+ parseOrFail(schema, 'foofoo'); // Throws an error: 'The received value does not end with the required substring'
930
+ ```
931
+ * _See_ Error Translation Key = 's:endsWith'
932
+
933
+
934
+ ##### lowerCase (string)
935
+
936
+ ```typescript
937
+ import { lowerCase } from 'bguard/string/lowerCase';
938
+ ```
939
+
940
+ * _Description_ Asserts that a string value is in lowercase.
941
+ * _Throws_ {ValidationError} if the received value is not in lowercase.
942
+ * _Example_
943
+ ```typescript
944
+ const schema = string().custom(lowerCase());
945
+ parseOrFail(schema, 'valid'); // Valid
946
+ parseOrFail(schema, 'Invalid'); // Throws an error: 'The received value is not in lowercase'
947
+ ```
948
+ * _See_ Error Translation Key = 's:lowerCase'
949
+
950
+
578
951
  ##### maxLength (string)
579
952
 
580
953
  ```typescript
@@ -628,5 +1001,170 @@ import { regExp } from 'bguard/string/regExp';
628
1001
  ```
629
1002
  * _See_ Error Translation Key = 's:regExp'
630
1003
 
1004
+
1005
+ ##### startsWith (string)
1006
+
1007
+ ```typescript
1008
+ import { startsWith } from 'bguard/string/startsWith';
1009
+ ```
1010
+
1011
+ * _Description_ Asserts that a string value starts with a specified substring.
1012
+ * _Param_ {string} substring The substring that the string value must start with.
1013
+ * _Throws_ {ValidationError} if the received value does not start with the required substring.
1014
+ * _Example_
1015
+ ```typescript
1016
+ const schema = string().custom(startsWith('foo'));
1017
+ parseOrFail(schema, 'foobar'); // Valid
1018
+ parseOrFail(schema, 'barfoo'); // Throws an error: 'The received value does not start with the required substring'
1019
+ ```
1020
+ * _See_ Error Translation Key = 's:startsWith'
1021
+
1022
+
1023
+ ##### upperCase (string)
1024
+
1025
+ ```typescript
1026
+ import { upperCase } from 'bguard/string/upperCase';
1027
+ ```
1028
+
1029
+ * _Description_ Asserts that a string value is entirely in uppercase.
1030
+ * _Throws_ {ValidationError} if the received value is not in uppercase.
1031
+ * _Example_
1032
+ ```typescript
1033
+ const schema = string().custom(upperCase());
1034
+ parseOrFail(schema, 'VALID'); // Valid
1035
+ parseOrFail(schema, 'INVALID'); // Throws an error: 'The received value is not in uppercase'
1036
+ parseOrFail(schema, 'Valid'); // Throws an error: 'The received value is not in uppercase'
1037
+ ```
1038
+ * _See_ Error Translation Key = 's:upperCase'
1039
+
1040
+
1041
+ ##### uuid (string)
1042
+
1043
+ ```typescript
1044
+ import { uuid } from 'bguard/string/uuid';
1045
+ ```
1046
+
1047
+ * _Description_ Asserts that a string value matches the UUID format.
1048
+ * _Throws_ {ValidationError} if the received value is not a valid UUID.
1049
+ * _Example_
1050
+ ```typescript
1051
+ const schema = string().custom(uuid());
1052
+ parseOrFail(schema, '123e4567-e89b-12d3-a456-426614174000'); // Valid
1053
+ parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID'
1054
+ ```
1055
+ * _See_ Error Translation Key = 's:uuid'
1056
+
1057
+
1058
+ ##### uuidV1 (string)
1059
+
1060
+ ```typescript
1061
+ import { uuidV1 } from 'bguard/string/uuidV1';
1062
+ ```
1063
+
1064
+ * _Description_ Asserts that a string value matches the UUID v1 format.
1065
+ * _Throws_ {ValidationError} if the received value is not a valid UUID v1.
1066
+ * _Example_
1067
+ ```typescript
1068
+ const schema = string().custom(uuidV1());
1069
+ parseOrFail(schema, '550e8400-e29b-11d4-a716-446655440000'); // Valid
1070
+ parseOrFail(schema, '550e8400-e29b-21d4-a716-446655440000'); // Throws an error: 'The received value is not a valid UUID v1'
1071
+ parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID v1'
1072
+ ```
1073
+ * _See_ Error Translation Key = 's:uuidV1'
1074
+
1075
+
1076
+ ##### uuidV2 (string)
1077
+
1078
+ ```typescript
1079
+ import { uuidV2 } from 'bguard/string/uuidV2';
1080
+ ```
1081
+
1082
+ * _Description_ Asserts that a string value matches the UUID v2 format.
1083
+ * _Throws_ {ValidationError} if the received value is not a valid UUID v2.
1084
+ * _Example_
1085
+ ```typescript
1086
+ const schema = string().custom(uuidV2());
1087
+ parseOrFail(schema, '550e8400-e29b-21d4-a716-446655440000'); // Valid
1088
+ parseOrFail(schema, '550e8400-e29b-31d4-d716-446655440000'); // Throws an error: 'The received value is not a valid UUID v2'
1089
+ parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID v2'
1090
+ ```
1091
+ * _See_ Error Translation Key = 's:uuidV2'
1092
+
1093
+
1094
+ ##### uuidV3 (string)
1095
+
1096
+ ```typescript
1097
+ import { uuidV3 } from 'bguard/string/uuidV3';
1098
+ ```
1099
+
1100
+ * _Description_ Asserts that a string value matches the UUID v3 format.
1101
+ * _Throws_ {ValidationError} if the received value is not a valid UUID v3.
1102
+ * _Example_
1103
+ ```typescript
1104
+ const schema = string().custom(uuidV3());
1105
+ parseOrFail(schema, '550e8400-e29b-38d1-a456-426614174000'); // Valid
1106
+ parseOrFail(schema, '550e8400-e29b-28d1-a456-426614174000'); // Throws an error: 'The received value is not a valid UUID v3'
1107
+ parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID v3'
1108
+ ```
1109
+ * _See_ Error Translation Key = 's:uuidV3'
1110
+
1111
+
1112
+ ##### uuidV4 (string)
1113
+
1114
+ ```typescript
1115
+ import { uuidV4 } from 'bguard/string/uuidV4';
1116
+ ```
1117
+
1118
+ * _Description_ Asserts that a string value matches the UUID v4 format.
1119
+ * _Throws_ {ValidationError} if the received value is not a valid UUID v4.
1120
+ * _Example_
1121
+ ```typescript
1122
+ const schema = string().custom(uuidV4());
1123
+ parseOrFail(schema, '123e4567-e89b-42d3-a456-426614174000'); // Valid
1124
+ parseOrFail(schema, '123e4567-e89b-12d3-a456-426614174000'); // Throws an error: 'The received value is not a valid UUID v4'
1125
+ parseOrFail(schema, '123e4567-e89b-a2d3-a456-426614174000'); // Throws an error: 'The received value is not a valid UUID v4'
1126
+ parseOrFail(schema, '123e4567-e89b-42d3-c456-426614174000'); // Throws an error: 'The received value is not a valid UUID v4'
1127
+ parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID v4'
1128
+ ```
1129
+ * _See_ Error Translation Key = 's:uuidV4'
1130
+
1131
+
1132
+ ##### uuidV5 (string)
1133
+
1134
+ ```typescript
1135
+ import { uuidV5 } from 'bguard/string/uuidV5';
1136
+ ```
1137
+
1138
+ * _Description_ Asserts that a string value matches the UUID v5 format.
1139
+ * _Throws_ {ValidationError} if the received value is not a valid UUID v5.
1140
+ * _Example_
1141
+ ```typescript
1142
+ const schema = string().custom(uuidV5());
1143
+ parseOrFail(schema, '550e8400-e29b-51d4-a716-446655440000'); // Valid
1144
+ parseOrFail(schema, '550e8400-e29b-41d4-a716-446655440000'); // Throws an error: 'The received value is not a valid UUID v5'
1145
+ parseOrFail(schema, 'invalid-uuid'); // Throws an error: 'The received value is not a valid UUID v5'
1146
+ ```
1147
+ * _See_ Error Translation Key = 's:uuidV5'
1148
+
1149
+
1150
+ ##### validUrl (string)
1151
+
1152
+ ```typescript
1153
+ import { validUrl } from 'bguard/string/validUrl';
1154
+ ```
1155
+
1156
+ * _Description_ Asserts that the string value is a valid URL with optional protocol validation.
1157
+ * _Param_ {string} [protocol] The protocol that the URL must start with (e.g., 'http'). If not provided, any URL starting with 'http://' or 'https://' is considered valid.
1158
+ * _Throws_ {ValidationError} if the received value does not match the expected URL pattern.
1159
+ * _Example_
1160
+ ```typescript
1161
+ const schema = string().custom(validUrl()); // Validates any URL starting with 'http://' or 'https://'
1162
+ parseOrFail(schema, 'http://example.com'); // Valid
1163
+ parseOrFail(schema, 'https://example.com'); // Valid
1164
+ parseOrFail(schema, 'ftp://example.com'); // Throws an error
1165
+ parseOrFail(schema, 'http:example.com'); // Throws an error
1166
+ ```
1167
+ * _See_ Error Translation Key = 's:url'
1168
+
631
1169
  ### Contributing
632
- Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.
1170
+ Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.