bguard 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/README.md +561 -175
  2. package/lib/{CommonSchema-CjsYE4dC.d.mts → CommonSchema-CiY7spmg.d.mts} +12 -3
  3. package/lib/{CommonSchema-BbGNki0L.d.ts → CommonSchema-D9QVJBJe.d.ts} +12 -3
  4. package/lib/InferType.d.mts +5 -2
  5. package/lib/InferType.d.ts +5 -2
  6. package/lib/asserts/array/index.d.mts +4 -4
  7. package/lib/asserts/array/index.d.ts +4 -4
  8. package/lib/asserts/array/index.js +13 -6
  9. package/lib/asserts/array/index.js.map +1 -1
  10. package/lib/asserts/array/index.mjs +13 -6
  11. package/lib/asserts/array/index.mjs.map +1 -1
  12. package/lib/asserts/array/maxArrayLength.d.mts +22 -0
  13. package/lib/asserts/array/maxArrayLength.d.ts +22 -0
  14. package/lib/asserts/array/maxArrayLength.js +20 -0
  15. package/lib/asserts/array/maxArrayLength.js.map +1 -0
  16. package/lib/asserts/array/maxArrayLength.mjs +20 -0
  17. package/lib/asserts/array/maxArrayLength.mjs.map +1 -0
  18. package/lib/asserts/array/minArrayLength.d.mts +22 -0
  19. package/lib/asserts/array/minArrayLength.d.ts +22 -0
  20. package/lib/asserts/array/minArrayLength.js +20 -0
  21. package/lib/asserts/array/minArrayLength.js.map +1 -0
  22. package/lib/asserts/array/minArrayLength.mjs +20 -0
  23. package/lib/asserts/array/minArrayLength.mjs.map +1 -0
  24. package/lib/asserts/bigint/bigintMax.d.mts +22 -0
  25. package/lib/asserts/bigint/bigintMax.d.ts +22 -0
  26. package/lib/asserts/bigint/bigintMax.js +20 -0
  27. package/lib/asserts/bigint/bigintMax.js.map +1 -0
  28. package/lib/asserts/bigint/bigintMax.mjs +20 -0
  29. package/lib/asserts/bigint/bigintMax.mjs.map +1 -0
  30. package/lib/asserts/bigint/bigintMaxExcluded.d.mts +22 -0
  31. package/lib/asserts/bigint/bigintMaxExcluded.d.ts +22 -0
  32. package/lib/asserts/bigint/bigintMaxExcluded.js +20 -0
  33. package/lib/asserts/bigint/bigintMaxExcluded.js.map +1 -0
  34. package/lib/asserts/bigint/bigintMaxExcluded.mjs +20 -0
  35. package/lib/asserts/bigint/bigintMaxExcluded.mjs.map +1 -0
  36. package/lib/asserts/bigint/bigintMin.d.mts +22 -0
  37. package/lib/asserts/bigint/bigintMin.d.ts +22 -0
  38. package/lib/asserts/bigint/bigintMin.js +20 -0
  39. package/lib/asserts/bigint/bigintMin.js.map +1 -0
  40. package/lib/asserts/bigint/bigintMin.mjs +20 -0
  41. package/lib/asserts/bigint/bigintMin.mjs.map +1 -0
  42. package/lib/asserts/bigint/bigintMinExcluded.d.mts +22 -0
  43. package/lib/asserts/bigint/bigintMinExcluded.d.ts +22 -0
  44. package/lib/asserts/bigint/bigintMinExcluded.js +20 -0
  45. package/lib/asserts/bigint/bigintMinExcluded.js.map +1 -0
  46. package/lib/asserts/bigint/bigintMinExcluded.mjs +20 -0
  47. package/lib/asserts/bigint/bigintMinExcluded.mjs.map +1 -0
  48. package/lib/asserts/bigint/index.d.mts +18 -0
  49. package/lib/asserts/bigint/index.d.ts +18 -0
  50. package/lib/asserts/bigint/index.js +22 -0
  51. package/lib/asserts/bigint/index.js.map +1 -0
  52. package/lib/asserts/bigint/index.mjs +22 -0
  53. package/lib/asserts/bigint/index.mjs.map +1 -0
  54. package/lib/asserts/boolean/index.d.mts +4 -4
  55. package/lib/asserts/boolean/index.d.ts +4 -4
  56. package/lib/asserts/boolean/index.js +14 -7
  57. package/lib/asserts/boolean/index.js.map +1 -1
  58. package/lib/asserts/boolean/index.mjs +14 -7
  59. package/lib/asserts/boolean/index.mjs.map +1 -1
  60. package/lib/asserts/date/dateMax.d.mts +22 -0
  61. package/lib/asserts/date/dateMax.d.ts +22 -0
  62. package/lib/asserts/date/dateMax.js +28 -0
  63. package/lib/asserts/date/dateMax.js.map +1 -0
  64. package/lib/asserts/date/dateMax.mjs +28 -0
  65. package/lib/asserts/date/dateMax.mjs.map +1 -0
  66. package/lib/asserts/date/dateMin.d.mts +22 -0
  67. package/lib/asserts/date/dateMin.d.ts +22 -0
  68. package/lib/asserts/date/dateMin.js +28 -0
  69. package/lib/asserts/date/dateMin.js.map +1 -0
  70. package/lib/asserts/date/dateMin.mjs +28 -0
  71. package/lib/asserts/date/dateMin.mjs.map +1 -0
  72. package/lib/asserts/date/index.d.mts +17 -0
  73. package/lib/asserts/date/index.d.ts +17 -0
  74. package/lib/asserts/date/index.js +18 -0
  75. package/lib/asserts/date/index.js.map +1 -0
  76. package/lib/asserts/date/index.mjs +18 -0
  77. package/lib/asserts/date/index.mjs.map +1 -0
  78. package/lib/asserts/mix/equalTo.d.mts +1 -1
  79. package/lib/asserts/mix/equalTo.d.ts +1 -1
  80. package/lib/asserts/mix/equalTo.js +4 -4
  81. package/lib/asserts/mix/equalTo.mjs +3 -3
  82. package/lib/asserts/mix/index.d.mts +4 -3
  83. package/lib/asserts/mix/index.d.ts +4 -3
  84. package/lib/asserts/mix/index.js +12 -5
  85. package/lib/asserts/mix/index.js.map +1 -1
  86. package/lib/asserts/mix/index.mjs +12 -5
  87. package/lib/asserts/mix/index.mjs.map +1 -1
  88. package/lib/asserts/mix/oneOfValues.d.mts +1 -1
  89. package/lib/asserts/mix/oneOfValues.d.ts +1 -1
  90. package/lib/asserts/mix/oneOfValues.js +4 -4
  91. package/lib/asserts/mix/oneOfValues.mjs +3 -3
  92. package/lib/asserts/number/index.d.mts +4 -4
  93. package/lib/asserts/number/index.d.ts +4 -4
  94. package/lib/asserts/number/index.js +16 -10
  95. package/lib/asserts/number/index.js.map +1 -1
  96. package/lib/asserts/number/index.mjs +16 -10
  97. package/lib/asserts/number/index.mjs.map +1 -1
  98. package/lib/asserts/number/max.js +4 -4
  99. package/lib/asserts/number/max.mjs +2 -2
  100. package/lib/asserts/number/maxExcluded.js +4 -4
  101. package/lib/asserts/number/maxExcluded.mjs +2 -2
  102. package/lib/asserts/number/min.js +4 -4
  103. package/lib/asserts/number/min.mjs +2 -2
  104. package/lib/asserts/number/minExcluded.js +4 -4
  105. package/lib/asserts/number/minExcluded.mjs +2 -2
  106. package/lib/asserts/number/negative.js +4 -4
  107. package/lib/asserts/number/negative.mjs +2 -2
  108. package/lib/asserts/number/positive.js +4 -4
  109. package/lib/asserts/number/positive.mjs +2 -2
  110. package/lib/asserts/object/index.d.mts +4 -4
  111. package/lib/asserts/object/index.d.ts +4 -4
  112. package/lib/asserts/object/index.js +13 -6
  113. package/lib/asserts/object/index.js.map +1 -1
  114. package/lib/asserts/object/index.mjs +13 -6
  115. package/lib/asserts/object/index.mjs.map +1 -1
  116. package/lib/asserts/string/atLeastOneDigit.js +4 -4
  117. package/lib/asserts/string/atLeastOneDigit.mjs +2 -2
  118. package/lib/asserts/string/atLeastOneLowerChar.js +4 -4
  119. package/lib/asserts/string/atLeastOneLowerChar.mjs +2 -2
  120. package/lib/asserts/string/atLeastOneSpecialChar.js +4 -4
  121. package/lib/asserts/string/atLeastOneSpecialChar.mjs +2 -2
  122. package/lib/asserts/string/atLeastOneUpperChar.js +4 -4
  123. package/lib/asserts/string/atLeastOneUpperChar.mjs +2 -2
  124. package/lib/asserts/string/contains.js +4 -4
  125. package/lib/asserts/string/contains.mjs +2 -2
  126. package/lib/asserts/string/email.js +4 -4
  127. package/lib/asserts/string/email.mjs +2 -2
  128. package/lib/asserts/string/endsWith.js +4 -4
  129. package/lib/asserts/string/endsWith.mjs +2 -2
  130. package/lib/asserts/string/index.d.mts +4 -4
  131. package/lib/asserts/string/index.d.ts +4 -4
  132. package/lib/asserts/string/index.js +16 -10
  133. package/lib/asserts/string/index.js.map +1 -1
  134. package/lib/asserts/string/index.mjs +16 -10
  135. package/lib/asserts/string/index.mjs.map +1 -1
  136. package/lib/asserts/string/isValidDate.d.mts +21 -0
  137. package/lib/asserts/string/isValidDate.d.ts +21 -0
  138. package/lib/asserts/string/isValidDate.js +25 -0
  139. package/lib/asserts/string/isValidDate.js.map +1 -0
  140. package/lib/asserts/string/isValidDate.mjs +25 -0
  141. package/lib/asserts/string/isValidDate.mjs.map +1 -0
  142. package/lib/asserts/string/isValidDateTime.d.mts +35 -0
  143. package/lib/asserts/string/isValidDateTime.d.ts +35 -0
  144. package/lib/asserts/string/isValidDateTime.js +32 -0
  145. package/lib/asserts/string/isValidDateTime.js.map +1 -0
  146. package/lib/asserts/string/isValidDateTime.mjs +32 -0
  147. package/lib/asserts/string/isValidDateTime.mjs.map +1 -0
  148. package/lib/asserts/string/isValidTime.d.mts +29 -0
  149. package/lib/asserts/string/isValidTime.d.ts +29 -0
  150. package/lib/asserts/string/isValidTime.js +32 -0
  151. package/lib/asserts/string/isValidTime.js.map +1 -0
  152. package/lib/asserts/string/isValidTime.mjs +32 -0
  153. package/lib/asserts/string/isValidTime.mjs.map +1 -0
  154. package/lib/asserts/string/lowerCase.js +4 -4
  155. package/lib/asserts/string/lowerCase.mjs +2 -2
  156. package/lib/asserts/string/maxLength.js +4 -4
  157. package/lib/asserts/string/maxLength.mjs +2 -2
  158. package/lib/asserts/string/minLength.js +4 -4
  159. package/lib/asserts/string/minLength.mjs +2 -2
  160. package/lib/asserts/string/regExp.js +4 -4
  161. package/lib/asserts/string/regExp.mjs +2 -2
  162. package/lib/asserts/string/startsWith.js +4 -4
  163. package/lib/asserts/string/startsWith.mjs +2 -2
  164. package/lib/asserts/string/upperCase.js +4 -4
  165. package/lib/asserts/string/upperCase.mjs +2 -2
  166. package/lib/asserts/string/uuid.js +4 -4
  167. package/lib/asserts/string/uuid.mjs +2 -2
  168. package/lib/asserts/string/uuidV1.js +4 -4
  169. package/lib/asserts/string/uuidV1.mjs +2 -2
  170. package/lib/asserts/string/uuidV2.js +4 -4
  171. package/lib/asserts/string/uuidV2.mjs +2 -2
  172. package/lib/asserts/string/uuidV3.js +4 -4
  173. package/lib/asserts/string/uuidV3.mjs +2 -2
  174. package/lib/asserts/string/uuidV4.js +4 -4
  175. package/lib/asserts/string/uuidV4.mjs +2 -2
  176. package/lib/asserts/string/uuidV5.js +4 -4
  177. package/lib/asserts/string/uuidV5.mjs +2 -2
  178. package/lib/asserts/string/validUrl.js +4 -4
  179. package/lib/asserts/string/validUrl.mjs +2 -2
  180. package/lib/{chunk-LEQCDD66.js → chunk-2D5QE7F4.js} +17 -15
  181. package/lib/chunk-2D5QE7F4.js.map +1 -0
  182. package/lib/chunk-2MFBOVP2.mjs +20 -0
  183. package/lib/chunk-2MFBOVP2.mjs.map +1 -0
  184. package/lib/chunk-3IOQH3K4.js +74 -0
  185. package/lib/chunk-3IOQH3K4.js.map +1 -0
  186. package/lib/chunk-3ZPLJ5KC.js +14 -0
  187. package/lib/{chunk-JSGZ7DKT.js.map → chunk-3ZPLJ5KC.js.map} +1 -1
  188. package/lib/{chunk-3HTYHE2X.mjs → chunk-4GDBM5LP.mjs} +4 -3
  189. package/lib/chunk-4GDBM5LP.mjs.map +1 -0
  190. package/lib/{chunk-TCQY2R3U.mjs → chunk-5HT3PYSG.mjs} +4 -4
  191. package/lib/chunk-5HT3PYSG.mjs.map +1 -0
  192. package/lib/{chunk-PH2PMUZP.mjs → chunk-5LLJ22IG.mjs} +28 -14
  193. package/lib/chunk-5LLJ22IG.mjs.map +1 -0
  194. package/lib/{chunk-PG2R7P7G.mjs → chunk-ADSMWGDJ.mjs} +4 -4
  195. package/lib/{chunk-H7CPKW53.js → chunk-AN3VHQEQ.js} +7 -7
  196. package/lib/{chunk-H7CPKW53.js.map → chunk-AN3VHQEQ.js.map} +1 -1
  197. package/lib/chunk-AOUFWACR.mjs +74 -0
  198. package/lib/chunk-AOUFWACR.mjs.map +1 -0
  199. package/lib/{chunk-WK4O3HH4.js → chunk-AY7HKAG2.js} +2 -3
  200. package/lib/chunk-AY7HKAG2.js.map +1 -0
  201. package/lib/{chunk-NNFYXHLU.mjs → chunk-BUXOCPHI.mjs} +3 -3
  202. package/lib/chunk-BUXOCPHI.mjs.map +1 -0
  203. package/lib/{chunk-RYVUYVEE.mjs → chunk-D42ISCFK.mjs} +2 -2
  204. package/lib/{chunk-KQKJASVB.js → chunk-EU3ZZF7Y.js} +13 -13
  205. package/lib/chunk-EU3ZZF7Y.js.map +1 -0
  206. package/lib/{chunk-NDQM5OL4.mjs → chunk-KBZUNXJB.mjs} +4 -4
  207. package/lib/chunk-KBZUNXJB.mjs.map +1 -0
  208. package/lib/chunk-LYNVPN3R.js +28 -0
  209. package/lib/chunk-LYNVPN3R.js.map +1 -0
  210. package/lib/{chunk-7XFLH6R2.mjs → chunk-NP64RC7B.mjs} +2 -3
  211. package/lib/chunk-NP64RC7B.mjs.map +1 -0
  212. package/lib/{chunk-3O4WCRC2.mjs → chunk-OHEMRF7Y.mjs} +3 -3
  213. package/lib/chunk-OHEMRF7Y.mjs.map +1 -0
  214. package/lib/chunk-OJSTQQ3N.js +20 -0
  215. package/lib/chunk-OJSTQQ3N.js.map +1 -0
  216. package/lib/{chunk-YUESB2WV.mjs → chunk-OKF3BVUD.mjs} +4 -4
  217. package/lib/{chunk-6TH3DBDK.js → chunk-OO6BTBVP.js} +11 -11
  218. package/lib/chunk-OO6BTBVP.js.map +1 -0
  219. package/lib/chunk-P6V6S6TZ.js +65 -0
  220. package/lib/chunk-P6V6S6TZ.js.map +1 -0
  221. package/lib/{chunk-DJSLA2ZV.js → chunk-PESVL5YJ.js} +7 -7
  222. package/lib/{chunk-DJSLA2ZV.js.map → chunk-PESVL5YJ.js.map} +1 -1
  223. package/lib/{chunk-IRG4OQAB.js → chunk-PIBDJJUU.js} +35 -21
  224. package/lib/chunk-PIBDJJUU.js.map +1 -0
  225. package/lib/{chunk-J4VKFJQK.js → chunk-SPWF5IFU.js} +5 -5
  226. package/lib/chunk-SPWF5IFU.js.map +1 -0
  227. package/lib/{chunk-P7IXNCJG.mjs → chunk-TQWUSDQD.mjs} +6 -6
  228. package/lib/chunk-TQWUSDQD.mjs.map +1 -0
  229. package/lib/{chunk-5BVJ6YMH.js → chunk-UZ2PWO4O.js} +6 -5
  230. package/lib/chunk-UZ2PWO4O.js.map +1 -0
  231. package/lib/chunk-VBTWYDEM.js +12 -0
  232. package/lib/chunk-VBTWYDEM.js.map +1 -0
  233. package/lib/{chunk-4CYIMDP2.js → chunk-W2GOLG3K.js} +5 -5
  234. package/lib/chunk-W2GOLG3K.js.map +1 -0
  235. package/lib/chunk-YBVMP4EI.mjs +12 -0
  236. package/lib/chunk-YBVMP4EI.mjs.map +1 -0
  237. package/lib/{chunk-CCBCDJXS.mjs → chunk-YPAFWVDL.mjs} +4 -4
  238. package/lib/chunk-YPAFWVDL.mjs.map +1 -0
  239. package/lib/chunk-ZMEQCIRN.mjs +65 -0
  240. package/lib/chunk-ZMEQCIRN.mjs.map +1 -0
  241. package/lib/{chunk-WBERBAL4.js → chunk-ZVW3IHBW.js} +8 -8
  242. package/lib/chunk-ZVW3IHBW.js.map +1 -0
  243. package/lib/{chunk-JPRCULRQ.mjs → chunk-ZWE5Q37U.mjs} +12 -10
  244. package/lib/chunk-ZWE5Q37U.mjs.map +1 -0
  245. package/lib/codeGen.d.mts +1 -1
  246. package/lib/codeGen.d.ts +1 -1
  247. package/lib/codeGen.js +5 -3
  248. package/lib/codeGen.js.map +1 -1
  249. package/lib/codeGen.mjs +4 -2
  250. package/lib/codeGen.mjs.map +1 -1
  251. package/lib/commonTypes.d.mts +1 -0
  252. package/lib/commonTypes.d.ts +1 -0
  253. package/lib/exceptions.js +2 -2
  254. package/lib/exceptions.mjs +1 -1
  255. package/lib/helpers/core.d.mts +1 -1
  256. package/lib/helpers/core.d.ts +1 -1
  257. package/lib/helpers/core.js +4 -3
  258. package/lib/helpers/core.js.map +1 -1
  259. package/lib/helpers/core.mjs +3 -2
  260. package/lib/helpers/isValidDateInner.d.mts +3 -0
  261. package/lib/helpers/isValidDateInner.d.ts +3 -0
  262. package/lib/helpers/isValidDateInner.js +7 -0
  263. package/lib/helpers/isValidDateInner.js.map +1 -0
  264. package/lib/helpers/isValidDateInner.mjs +7 -0
  265. package/lib/helpers/isValidDateInner.mjs.map +1 -0
  266. package/lib/helpers/setStrictType.d.mts +1 -1
  267. package/lib/helpers/setStrictType.d.ts +1 -1
  268. package/lib/helpers/setStrictType.js +5 -4
  269. package/lib/helpers/setStrictType.js.map +1 -1
  270. package/lib/helpers/setStrictType.mjs +4 -3
  271. package/lib/index.d.mts +3 -7
  272. package/lib/index.d.ts +3 -7
  273. package/lib/index.js +7 -40
  274. package/lib/index.js.map +1 -1
  275. package/lib/index.mjs +7 -40
  276. package/lib/parse.d.mts +3 -1
  277. package/lib/parse.d.ts +3 -1
  278. package/lib/parse.js +6 -5
  279. package/lib/parse.js.map +1 -1
  280. package/lib/parse.mjs +5 -4
  281. package/lib/parseOrFail.d.mts +3 -1
  282. package/lib/parseOrFail.d.ts +3 -1
  283. package/lib/parseOrFail.js +6 -5
  284. package/lib/parseOrFail.js.map +1 -1
  285. package/lib/parseOrFail.mjs +5 -4
  286. package/lib/schemas/ArraySchema.d.mts +2 -2
  287. package/lib/schemas/ArraySchema.d.ts +2 -2
  288. package/lib/schemas/ArraySchema.js +8 -5
  289. package/lib/schemas/ArraySchema.js.map +1 -1
  290. package/lib/schemas/ArraySchema.mjs +7 -4
  291. package/lib/schemas/BigIntSchema.d.mts +33 -0
  292. package/lib/schemas/BigIntSchema.d.ts +33 -0
  293. package/lib/schemas/BigIntSchema.js +17 -0
  294. package/lib/schemas/BigIntSchema.js.map +1 -0
  295. package/lib/schemas/BigIntSchema.mjs +17 -0
  296. package/lib/schemas/BigIntSchema.mjs.map +1 -0
  297. package/lib/schemas/BooleanSchema.d.mts +2 -2
  298. package/lib/schemas/BooleanSchema.d.ts +2 -2
  299. package/lib/schemas/BooleanSchema.js +9 -6
  300. package/lib/schemas/BooleanSchema.js.map +1 -1
  301. package/lib/schemas/BooleanSchema.mjs +8 -5
  302. package/lib/schemas/CommonSchema.d.mts +1 -1
  303. package/lib/schemas/CommonSchema.d.ts +1 -1
  304. package/lib/schemas/CommonSchema.js +7 -4
  305. package/lib/schemas/CommonSchema.js.map +1 -1
  306. package/lib/schemas/CommonSchema.mjs +6 -3
  307. package/lib/schemas/DateSchema.d.mts +9 -0
  308. package/lib/schemas/DateSchema.d.ts +9 -0
  309. package/lib/schemas/DateSchema.js +13 -0
  310. package/lib/schemas/DateSchema.js.map +1 -0
  311. package/lib/schemas/DateSchema.mjs +13 -0
  312. package/lib/schemas/DateSchema.mjs.map +1 -0
  313. package/lib/schemas/NumberSchema.d.mts +2 -2
  314. package/lib/schemas/NumberSchema.d.ts +2 -2
  315. package/lib/schemas/NumberSchema.js +11 -9
  316. package/lib/schemas/NumberSchema.js.map +1 -1
  317. package/lib/schemas/NumberSchema.mjs +10 -8
  318. package/lib/schemas/ObjectSchema.d.mts +2 -2
  319. package/lib/schemas/ObjectSchema.d.ts +2 -2
  320. package/lib/schemas/ObjectSchema.js +8 -5
  321. package/lib/schemas/ObjectSchema.js.map +1 -1
  322. package/lib/schemas/ObjectSchema.mjs +7 -4
  323. package/lib/schemas/StringSchema.d.mts +3 -2
  324. package/lib/schemas/StringSchema.d.ts +3 -2
  325. package/lib/schemas/StringSchema.js +11 -9
  326. package/lib/schemas/StringSchema.js.map +1 -1
  327. package/lib/schemas/StringSchema.mjs +10 -8
  328. package/lib/translationMap.js +3 -3
  329. package/lib/translationMap.mjs +2 -2
  330. package/package.json +6 -1
  331. package/lib/chunk-2PM3K3OE.mjs +0 -13
  332. package/lib/chunk-2PM3K3OE.mjs.map +0 -1
  333. package/lib/chunk-32RSTOZ4.mjs +0 -13
  334. package/lib/chunk-32RSTOZ4.mjs.map +0 -1
  335. package/lib/chunk-3HTYHE2X.mjs.map +0 -1
  336. package/lib/chunk-3O4WCRC2.mjs.map +0 -1
  337. package/lib/chunk-4CYIMDP2.js.map +0 -1
  338. package/lib/chunk-5BVJ6YMH.js.map +0 -1
  339. package/lib/chunk-6TH3DBDK.js.map +0 -1
  340. package/lib/chunk-7XFLH6R2.mjs.map +0 -1
  341. package/lib/chunk-CCBCDJXS.mjs.map +0 -1
  342. package/lib/chunk-DPBE7TAQ.mjs +0 -42
  343. package/lib/chunk-DPBE7TAQ.mjs.map +0 -1
  344. package/lib/chunk-EGEHSELT.js +0 -42
  345. package/lib/chunk-EGEHSELT.js.map +0 -1
  346. package/lib/chunk-HDSGCAHH.js +0 -13
  347. package/lib/chunk-HDSGCAHH.js.map +0 -1
  348. package/lib/chunk-IEUXIOL6.js +0 -13
  349. package/lib/chunk-IEUXIOL6.js.map +0 -1
  350. package/lib/chunk-IRG4OQAB.js.map +0 -1
  351. package/lib/chunk-J4VKFJQK.js.map +0 -1
  352. package/lib/chunk-JDGZCBXF.mjs +0 -13
  353. package/lib/chunk-JDGZCBXF.mjs.map +0 -1
  354. package/lib/chunk-JPRCULRQ.mjs.map +0 -1
  355. package/lib/chunk-JSGZ7DKT.js +0 -14
  356. package/lib/chunk-KQKJASVB.js.map +0 -1
  357. package/lib/chunk-LEQCDD66.js.map +0 -1
  358. package/lib/chunk-MRISXZQ4.mjs +0 -13
  359. package/lib/chunk-MRISXZQ4.mjs.map +0 -1
  360. package/lib/chunk-NDQM5OL4.mjs.map +0 -1
  361. package/lib/chunk-NNFYXHLU.mjs.map +0 -1
  362. package/lib/chunk-P7IXNCJG.mjs.map +0 -1
  363. package/lib/chunk-PH2PMUZP.mjs.map +0 -1
  364. package/lib/chunk-PXBAS3GA.mjs +0 -13
  365. package/lib/chunk-PXBAS3GA.mjs.map +0 -1
  366. package/lib/chunk-QQNQ4IDN.js +0 -13
  367. package/lib/chunk-QQNQ4IDN.js.map +0 -1
  368. package/lib/chunk-RD6TBCPQ.js +0 -13
  369. package/lib/chunk-RD6TBCPQ.js.map +0 -1
  370. package/lib/chunk-RRQOET3X.js +0 -28
  371. package/lib/chunk-RRQOET3X.js.map +0 -1
  372. package/lib/chunk-TCQY2R3U.mjs.map +0 -1
  373. package/lib/chunk-TKZ6FLLR.js +0 -13
  374. package/lib/chunk-TKZ6FLLR.js.map +0 -1
  375. package/lib/chunk-VHEA4JZ5.js +0 -13
  376. package/lib/chunk-VHEA4JZ5.js.map +0 -1
  377. package/lib/chunk-WBERBAL4.js.map +0 -1
  378. package/lib/chunk-WK4O3HH4.js.map +0 -1
  379. package/lib/chunk-YML32TPA.mjs +0 -13
  380. package/lib/chunk-YML32TPA.mjs.map +0 -1
  381. /package/lib/{chunk-PG2R7P7G.mjs.map → chunk-ADSMWGDJ.mjs.map} +0 -0
  382. /package/lib/{chunk-RYVUYVEE.mjs.map → chunk-D42ISCFK.mjs.map} +0 -0
  383. /package/lib/{chunk-YUESB2WV.mjs.map → chunk-OKF3BVUD.mjs.map} +0 -0
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';
@@ -111,7 +116,7 @@ This would output a string:
111
116
  }
112
117
  ```
113
118
 
114
- 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.
119
+ > **Notice:** 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.
115
120
 
116
121
  #### Generating Named TypeScript Types with `codeGenWithName`
117
122
 
@@ -251,14 +256,25 @@ Explanation
251
256
 
252
257
  ### Chaining Methods
253
258
 
254
- - `nullable()`: Allows the value to be null.
255
- - `optional()`: Allows the value to be undefined.
259
+ - `nullable()`: Allows the value to be `null`.
260
+ - `optional()`: Allows the value to be `undefined`.
261
+ - `default(value: unknown)`: Sets a default value if the received value is `undefined`.
262
+
263
+
264
+ > **Notice:** You cannot chain `default()` and `optional()` together, as they are contradictory. The `optional()` method allows the value to be `undefined`, while the `default()` method assigns a value if `undefined`. Attempting to chain both will throw a `BuildSchemaError` with the message: `"Cannot call method 'default' after method 'optional'"`.
265
+
266
+
267
+ > **Notice:** Additionally, `default()` must be the last method in the chain because it validates during schema build time that the default value is compatible with the rest of the schema. For example, if the schema is `number()`, the default value cannot be a `string`.
268
+
256
269
 
257
270
  Example:
258
271
 
259
272
  ```typeScript
273
+ const schemaWithDefault = string().nullable().default('defaultString');
274
+ // This schema allows null values and sets 'defaultString' if the value is undefined.
260
275
 
261
- const schema = string().nullable().optional();
276
+ const optionalSchema = string().nullable().optional();
277
+ // This schema allows both null and undefined values, but it does not provide a default value.
262
278
  ```
263
279
 
264
280
  - String Literals:
@@ -399,6 +415,7 @@ We have two sets of translations: common errors and specific assertions.
399
415
  'c:requiredProperty': 'Missing required property in the object',
400
416
  'c:invalidType': 'Invalid type of data',
401
417
  'c:isBoolean': 'The received value is not {{e}}',
418
+ 'c:date': 'The received value is not a valid instance of Date',
402
419
  ```
403
420
 
404
421
  <b>Custom Assertion Translations</b>:
@@ -418,6 +435,7 @@ Keys are constructed as `'{typeId}:{functionName}'`, where `typeId` represents:
418
435
  - f - function
419
436
  - bi - bigint
420
437
  - m - mixed
438
+ - dt - date
421
439
 
422
440
  Each `typeId` maps to the folder from which custom assertions are retrieved (except 'common', as explained above).
423
441
 
@@ -444,164 +462,73 @@ console.log(maxLength.message); // Output: 'The received value length is greater
444
462
 
445
463
  <b>3.</b> IDE Support:
446
464
  Each key and message will be visible in text editors that support JSDoc IntelliSense.
465
+
447
466
  ### Built-in Custom Assert Documentation {#builtin_custom_assert_documentation}
448
467
 
449
- #### mix
450
-
451
- ##### equalTo (mix)
452
-
453
- ```typescript
454
- import { equalTo } from 'bguard/mix/equalTo';
455
- ```
456
-
457
- * _Description_ Creates a custom assertion that checks if a value is equal to the expected value.
458
- * > **Notice:** It has already been implemented in the number and string schema. There is no need to use it as a custom assert.
459
- * _Param_ {unknown} expected The value that the received value is expected to match.
460
- * _Throws_ {ValidationError} If the received value does not match the expected value.
461
- * _Example_
462
- ```typescript
463
- const schema = number().custom(equalTo(5)); // Define a schema with a custom assertion
464
- parseOrFail(schema, 5); // Valid
465
- parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'
466
- ```
467
- * _See_ Error Translation Key = 'm:equalTo'
468
-
469
-
470
- ##### oneOfValues (mix)
471
-
472
- ```typescript
473
- import { oneOfValues } from 'bguard/mix/oneOfValues';
474
- ```
475
-
476
- * _Description_ Creates a custom assertion that checks if a value is equal to the one of expected values.
477
- * > **Notice:** It has already been implemented in the number and string schema. There is no need to use it as a custom assert.
478
- * _Param_ {unknown} expected The value that the received value is expected to match.
479
- * _Throws_ {ValidationError} If the received value does not match at least one of the expected values.
480
- * _Example_
481
- ```typescript
482
- const schema = number().custom(oneOfValues([5, 4])); // Define a schema with a custom assertion
483
- parseOrFail(schema, 5); // Valid
484
- parseOrFail(schema, 4); // Valid
485
- parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'
486
- ```
487
- * _See_ Error Translation Key = 'm:oneOfValues'
488
-
489
- #### number
490
-
491
- ##### max (number)
492
-
493
- ```typescript
494
- import { max } from 'bguard/number/max';
495
- ```
496
-
497
- * _Description_ Asserts that a number value does not exceed a specified maximum value.
498
- * _Param_ {number} expected The maximum allowable value.
499
- * _Throws_ {ValidationError} if the received value exceeds the expected maximum value.
500
- * _Example_
501
- ```typescript
502
- const schema = number().custom(max(100));
503
- parseOrFail(schema, 99); // Valid
504
- parseOrFail(schema, 100); // Valid
505
- parseOrFail(schema, 101); // Throws an error: 'The received value is greater than expected'
506
- ```
507
- * _See_ Error Translation Key = 'n:max'
508
-
509
-
510
- ##### maxExcluded (number)
511
-
512
- ```typescript
513
- import { maxExcluded } from 'bguard/number/maxExcluded';
514
- ```
515
-
516
- * _Description_ - Asserts that a number value is strictly less than a specified maximum value (i.e., the maximum value is excluded).
517
- * _Param_ {number} expected - The maximum allowable value, which is excluded.
518
- * _Throws_ {ValidationError} if the received value is greater than or equal to the expected maximum value.
519
- * _Example_
520
- ```typescript
521
- const schema = number().custom(maxExcluded(100));
522
- parseOrFail(schema, 99); // Valid
523
- parseOrFail(schema, 100); // Throws an error: 'The received value is greater than or equal to expected'
524
- parseOrFail(schema, 101); // Throws an error: 'The received value is greater than or equal to expected'
525
- ```
526
- * _See_ Error Translation Key = 'n:maxExcluded'
527
-
528
-
529
- ##### min (number)
530
-
531
- ```typescript
532
- import { min } from 'bguard/number/min';
533
- ```
534
-
535
- * _Description_ Asserts that a number value is not less than a specified minimum value.
536
- * _Param_ {number} expected The minimum allowable value.
537
- * _Throws_ {ValidationError} if the received value is less than the expected minimum value.
538
- * _Example_
539
- ```typescript
540
- const schema = number().custom(min(10));
541
- parseOrFail(schema, 11); // Valid
542
- parseOrFail(schema, 10); // Valid
543
- parseOrFail(schema, 9); // Throws an error: 'The received value is less than expected'
544
- ```
545
- * _See_ Error Translation Key = 'n:min'
546
-
547
-
548
- ##### minExcluded (number)
549
-
550
- ```typescript
551
- import { minExcluded } from 'bguard/number/minExcluded';
552
- ```
553
-
554
- * _Description_ Asserts that a number value is strictly greater than a specified minimum value (i.e., the minimum value is excluded).
555
- * _Param_ {number} expected The minimum allowable value, which is excluded.
556
- * _Throws_ {ValidationError} if the received value is less than or equal to the expected minimum value.
557
- * _Example_
468
+ * [string](#assertdir_string)
469
+ * [atLeastOneDigit](#assert_atLeastOneDigit_string)
470
+ * [atLeastOneLowerChar](#assert_atLeastOneLowerChar_string)
471
+ * [atLeastOneSpecialChar](#assert_atLeastOneSpecialChar_string)
472
+ * [atLeastOneUpperChar](#assert_atLeastOneUpperChar_string)
473
+ * [contains](#assert_contains_string)
474
+ * [email](#assert_email_string)
475
+ * [endsWith](#assert_endsWith_string)
476
+ * [isValidDate](#assert_isValidDate_string)
477
+ * [isValidDateTime](#assert_isValidDateTime_string)
478
+ * [isValidTime](#assert_isValidTime_string)
479
+ * [lowerCase](#assert_lowerCase_string)
480
+ * [maxLength](#assert_maxLength_string)
481
+ * [minLength](#assert_minLength_string)
482
+ * [regExp](#assert_regExp_string)
483
+ * [startsWith](#assert_startsWith_string)
484
+ * [upperCase](#assert_upperCase_string)
485
+ * [uuid](#assert_uuid_string)
486
+ * [uuidV1](#assert_uuidV1_string)
487
+ * [uuidV2](#assert_uuidV2_string)
488
+ * [uuidV3](#assert_uuidV3_string)
489
+ * [uuidV4](#assert_uuidV4_string)
490
+ * [uuidV5](#assert_uuidV5_string)
491
+ * [validUrl](#assert_validUrl_string)
492
+ * [number](#assertdir_number)
493
+ * [max](#assert_max_number)
494
+ * [maxExcluded](#assert_maxExcluded_number)
495
+ * [min](#assert_min_number)
496
+ * [minExcluded](#assert_minExcluded_number)
497
+ * [negative](#assert_negative_number)
498
+ * [positive](#assert_positive_number)
499
+ * [array](#assertdir_array)
500
+ * [maxArrayLength](#assert_maxArrayLength_array)
501
+ * [minArrayLength](#assert_minArrayLength_array)
502
+ * [bigint](#assertdir_bigint)
503
+ * [bigintMax](#assert_bigintMax_bigint)
504
+ * [bigintMaxExcluded](#assert_bigintMaxExcluded_bigint)
505
+ * [bigintMin](#assert_bigintMin_bigint)
506
+ * [bigintMinExcluded](#assert_bigintMinExcluded_bigint)
507
+ * [date](#assertdir_date)
508
+ * [dateMax](#assert_dateMax_date)
509
+ * [dateMin](#assert_dateMin_date)
510
+ * [mix](#assertdir_mix)
511
+ * [equalTo](#assert_equalTo_mix)
512
+ * [oneOfValues](#assert_oneOfValues_mix)
513
+
514
+ #### string {#assertdir_string}
515
+
516
+ <b>Prerequisites</b>
517
+
558
518
  ```typescript
559
- const schema = number().custom(minExcluded(10));
560
- parseOrFail(schema, 11); // Valid
561
- parseOrFail(schema, 10); // Throws an error: 'The received value is less than or equal to expected'
562
- parseOrFail(schema, 9); // Throws an error: 'The received value is less than or equal to expected'
563
- ```
564
- * _See_ Error Translation Key = 'n:minExcluded'
565
-
566
-
567
- ##### negative (number)
568
-
569
- ```typescript
570
- import { negative } from 'bguard/number/negative';
519
+ import { string } from 'bguard/string';
571
520
  ```
572
-
573
- * _Description_ Asserts that a number value is negative (less than zero).
574
- * _Throws_ {ValidationError} if the received value is not negative.
521
+
522
+ * _Description_ Creates a new schema for validating string values.
575
523
  * _Example_
576
524
  ```typescript
577
- const schema = number().custom(negative());
578
- parseOrFail(schema, -10); // Valid
579
- parseOrFail(schema, 0); // Throws an error: 'The received value is not a negative number'
580
- parseOrFail(schema, 5); // Throws an error: 'The received value is not a negative number'
525
+ const schema = string();
526
+ parseOrFail(schema, 'hello'); // Validates successfully
527
+ parseOrFail(schema, 123); // Throws a validation error
581
528
  ```
582
- * _See_ - Error Translation Key = 'n:negative'
583
-
529
+
584
530
 
585
- ##### positive (number)
586
-
587
- ```typescript
588
- import { positive } from 'bguard/number/positive';
589
- ```
590
-
591
- * _Description_ Asserts that a number value is positive (greater than zero).
592
- * _Throws_ {ValidationError} if the received value is not positive.
593
- * _Example_
594
- ```typescript
595
- const schema = number().custom(positive());
596
- parseOrFail(schema, 10); // Valid
597
- parseOrFail(schema, 0); // Throws an error: 'The received value is not a positive number'
598
- parseOrFail(schema, -5); // Throws an error: 'The received value is not a positive number'
599
- ```
600
- * _See_ Error Translation Key = 'n:positive'
601
-
602
- #### string
603
-
604
- ##### atLeastOneDigit (string)
531
+ ##### atLeastOneDigit (string) {#assert_atLeastOneDigit_string}
605
532
 
606
533
  ```typescript
607
534
  import { atLeastOneDigit } from 'bguard/string/atLeastOneDigit';
@@ -618,7 +545,7 @@ import { atLeastOneDigit } from 'bguard/string/atLeastOneDigit';
618
545
  * _See_ Error Translation Key = 's:atLeastOneDigit'
619
546
 
620
547
 
621
- ##### atLeastOneLowerChar (string)
548
+ ##### atLeastOneLowerChar (string) {#assert_atLeastOneLowerChar_string}
622
549
 
623
550
  ```typescript
624
551
  import { atLeastOneLowerChar } from 'bguard/string/atLeastOneLowerChar';
@@ -635,7 +562,7 @@ import { atLeastOneLowerChar } from 'bguard/string/atLeastOneLowerChar';
635
562
  * _See_ Error Translation Key = 's:atLeastOneLowerChar'
636
563
 
637
564
 
638
- ##### atLeastOneSpecialChar (string)
565
+ ##### atLeastOneSpecialChar (string) {#assert_atLeastOneSpecialChar_string}
639
566
 
640
567
  ```typescript
641
568
  import { atLeastOneSpecialChar } from 'bguard/string/atLeastOneSpecialChar';
@@ -657,7 +584,7 @@ import { atLeastOneSpecialChar } from 'bguard/string/atLeastOneSpecialChar';
657
584
  * _See_ Error Translation Key = 's:atLeastOneSpecialChar'
658
585
 
659
586
 
660
- ##### atLeastOneUpperChar (string)
587
+ ##### atLeastOneUpperChar (string) {#assert_atLeastOneUpperChar_string}
661
588
 
662
589
  ```typescript
663
590
  import { atLeastOneUpperChar } from 'bguard/string/atLeastOneUpperChar';
@@ -674,7 +601,7 @@ import { atLeastOneUpperChar } from 'bguard/string/atLeastOneUpperChar';
674
601
  * _See_ Error Translation Key = 's:atLeastOneUpperChar'
675
602
 
676
603
 
677
- ##### contains (string)
604
+ ##### contains (string) {#assert_contains_string}
678
605
 
679
606
  ```typescript
680
607
  import { contains } from 'bguard/string/contains';
@@ -692,7 +619,7 @@ import { contains } from 'bguard/string/contains';
692
619
  * _See_ Error Translation Key = 's:contains'
693
620
 
694
621
 
695
- ##### email (string)
622
+ ##### email (string) {#assert_email_string}
696
623
 
697
624
  ```typescript
698
625
  import { email } from 'bguard/string/email';
@@ -709,7 +636,7 @@ import { email } from 'bguard/string/email';
709
636
  * _See_ - Error Translation Key = 's:email'
710
637
 
711
638
 
712
- ##### endsWith (string)
639
+ ##### endsWith (string) {#assert_endsWith_string}
713
640
 
714
641
  ```typescript
715
642
  import { endsWith } from 'bguard/string/endsWith';
@@ -727,7 +654,76 @@ import { endsWith } from 'bguard/string/endsWith';
727
654
  * _See_ Error Translation Key = 's:endsWith'
728
655
 
729
656
 
730
- ##### lowerCase (string)
657
+ ##### isValidDate (string) {#assert_isValidDate_string}
658
+
659
+ ```typescript
660
+ import { isValidDate } from 'bguard/string/isValidDate';
661
+ ```
662
+
663
+ * _Description_ Asserts that a string is a valid date in the format YYYY-MM-DD.
664
+ * _Throws_ {ValidationError} if the received string is not a valid date.
665
+ * _Example_
666
+ ```typescript
667
+ const schema = string().custom(isValidDate());
668
+ parseOrFail(schema, "2020-01-01"); // Valid
669
+ parseOrFail(schema, "2020-1-1"); // Throws an error: 'The received value is not a valid date'
670
+ parseOrFail(schema, "2020-01-32"); // Throws an error: 'The received value is not a valid date'
671
+ ```
672
+ * _See_ Error Translation Key = 's:isValidDate'
673
+
674
+
675
+ ##### isValidDateTime (string) {#assert_isValidDateTime_string}
676
+
677
+ ```typescript
678
+ import { isValidDateTime } from 'bguard/string/isValidDateTime';
679
+ ```
680
+
681
+ * _Description_ Asserts that a string value is a valid ISO 8601 datetime string.
682
+ * _Param_ {DateTimeOptions} options Options to control the validation:
683
+ - `offset`: If `true`, allows timezone offsets in the datetime string.
684
+ - `precision`: Specify the exact number of fractional second digits allowed (e.g., 3 for milliseconds).
685
+ * _Throws_ {ValidationError} if the received value is not a valid datetime string according to the options.
686
+ * _Example_
687
+ ```typescript
688
+ const schema = string().custom(isValidDateTime());
689
+ parseOrFail(schema, "2024-01-01T00:00:00Z"); // Valid
690
+ parseOrFail(schema, "2024-01-01T00:00:00.123Z"); // Valid
691
+ parseOrFail(schema, "2024-01-01T00:00:00+03:00"); // Invalid (no offsets allowed)
692
+
693
+ const schemaWithOffset = string().custom(isValidDateTime({ offset: true }));
694
+ parseOrFail(schemaWithOffset, "2024-01-01T00:00:00+04:00"); // Valid
695
+
696
+ const schemaWithPrecision = string().custom(isValidDateTime({ precision: 3 }));
697
+ parseOrFail(schemaWithPrecision, "2024-01-01T00:00:00.123Z"); // Valid
698
+ parseOrFail(schemaWithPrecision, "2024-01-01T00:00:00.123456Z"); // Invalid
699
+ ```
700
+ * _See_ Error Translation Key = 's:isValidDateTime'
701
+
702
+
703
+ ##### isValidTime (string) {#assert_isValidTime_string}
704
+
705
+ ```typescript
706
+ import { isValidTime } from 'bguard/string/isValidTime';
707
+ ```
708
+
709
+ * _Description_ Asserts that a string is a valid time in the format HH:mm:ss, with optional fractional seconds.
710
+ * _Param_ {IsValidTimeOptions} options Optional settings to configure the validation.
711
+ * _Throws_ {ValidationError} if the received string is not a valid time.
712
+ * _Example_
713
+ ```typescript
714
+ const schema = string().custom(isValidTime());
715
+ parseOrFail(schema, "00:00:00"); // Valid
716
+ parseOrFail(schema, "23:59:59.9999999"); // Valid
717
+ parseOrFail(schema, "00:00:00.256Z"); // Throws an error: 'The received value is not a valid time'
718
+
719
+ const schemaWithPrecision = string().custom(isValidTime({ precision: 3 }));
720
+ parseOrFail(schemaWithPrecision, "00:00:00.256"); // Valid
721
+ parseOrFail(schemaWithPrecision, "00:00:00"); // Throws an error: 'The received value is not a valid time'
722
+ ```
723
+ * _See_ Error Translation Key = 's:isValidTime'
724
+
725
+
726
+ ##### lowerCase (string) {#assert_lowerCase_string}
731
727
 
732
728
  ```typescript
733
729
  import { lowerCase } from 'bguard/string/lowerCase';
@@ -744,7 +740,7 @@ import { lowerCase } from 'bguard/string/lowerCase';
744
740
  * _See_ Error Translation Key = 's:lowerCase'
745
741
 
746
742
 
747
- ##### maxLength (string)
743
+ ##### maxLength (string) {#assert_maxLength_string}
748
744
 
749
745
  ```typescript
750
746
  import { maxLength } from 'bguard/string/maxLength';
@@ -762,7 +758,7 @@ import { maxLength } from 'bguard/string/maxLength';
762
758
  * _See_ Error Translation Key = 's:maxLength'
763
759
 
764
760
 
765
- ##### minLength (string)
761
+ ##### minLength (string) {#assert_minLength_string}
766
762
 
767
763
  ```typescript
768
764
  import { minLength } from 'bguard/string/minLength';
@@ -780,7 +776,7 @@ import { minLength } from 'bguard/string/minLength';
780
776
  * _See_ Error Translation Key = 's:minLength'
781
777
 
782
778
 
783
- ##### regExp (string)
779
+ ##### regExp (string) {#assert_regExp_string}
784
780
 
785
781
  ```typescript
786
782
  import { regExp } from 'bguard/string/regExp';
@@ -798,7 +794,7 @@ import { regExp } from 'bguard/string/regExp';
798
794
  * _See_ Error Translation Key = 's:regExp'
799
795
 
800
796
 
801
- ##### startsWith (string)
797
+ ##### startsWith (string) {#assert_startsWith_string}
802
798
 
803
799
  ```typescript
804
800
  import { startsWith } from 'bguard/string/startsWith';
@@ -816,7 +812,7 @@ import { startsWith } from 'bguard/string/startsWith';
816
812
  * _See_ Error Translation Key = 's:startsWith'
817
813
 
818
814
 
819
- ##### upperCase (string)
815
+ ##### upperCase (string) {#assert_upperCase_string}
820
816
 
821
817
  ```typescript
822
818
  import { upperCase } from 'bguard/string/upperCase';
@@ -834,7 +830,7 @@ import { upperCase } from 'bguard/string/upperCase';
834
830
  * _See_ Error Translation Key = 's:upperCase'
835
831
 
836
832
 
837
- ##### uuid (string)
833
+ ##### uuid (string) {#assert_uuid_string}
838
834
 
839
835
  ```typescript
840
836
  import { uuid } from 'bguard/string/uuid';
@@ -851,7 +847,7 @@ import { uuid } from 'bguard/string/uuid';
851
847
  * _See_ Error Translation Key = 's:uuid'
852
848
 
853
849
 
854
- ##### uuidV1 (string)
850
+ ##### uuidV1 (string) {#assert_uuidV1_string}
855
851
 
856
852
  ```typescript
857
853
  import { uuidV1 } from 'bguard/string/uuidV1';
@@ -869,7 +865,7 @@ import { uuidV1 } from 'bguard/string/uuidV1';
869
865
  * _See_ Error Translation Key = 's:uuidV1'
870
866
 
871
867
 
872
- ##### uuidV2 (string)
868
+ ##### uuidV2 (string) {#assert_uuidV2_string}
873
869
 
874
870
  ```typescript
875
871
  import { uuidV2 } from 'bguard/string/uuidV2';
@@ -887,7 +883,7 @@ import { uuidV2 } from 'bguard/string/uuidV2';
887
883
  * _See_ Error Translation Key = 's:uuidV2'
888
884
 
889
885
 
890
- ##### uuidV3 (string)
886
+ ##### uuidV3 (string) {#assert_uuidV3_string}
891
887
 
892
888
  ```typescript
893
889
  import { uuidV3 } from 'bguard/string/uuidV3';
@@ -905,7 +901,7 @@ import { uuidV3 } from 'bguard/string/uuidV3';
905
901
  * _See_ Error Translation Key = 's:uuidV3'
906
902
 
907
903
 
908
- ##### uuidV4 (string)
904
+ ##### uuidV4 (string) {#assert_uuidV4_string}
909
905
 
910
906
  ```typescript
911
907
  import { uuidV4 } from 'bguard/string/uuidV4';
@@ -925,7 +921,7 @@ import { uuidV4 } from 'bguard/string/uuidV4';
925
921
  * _See_ Error Translation Key = 's:uuidV4'
926
922
 
927
923
 
928
- ##### uuidV5 (string)
924
+ ##### uuidV5 (string) {#assert_uuidV5_string}
929
925
 
930
926
  ```typescript
931
927
  import { uuidV5 } from 'bguard/string/uuidV5';
@@ -943,7 +939,7 @@ import { uuidV5 } from 'bguard/string/uuidV5';
943
939
  * _See_ Error Translation Key = 's:uuidV5'
944
940
 
945
941
 
946
- ##### validUrl (string)
942
+ ##### validUrl (string) {#assert_validUrl_string}
947
943
 
948
944
  ```typescript
949
945
  import { validUrl } from 'bguard/string/validUrl';
@@ -962,5 +958,395 @@ import { validUrl } from 'bguard/string/validUrl';
962
958
  ```
963
959
  * _See_ Error Translation Key = 's:url'
964
960
 
961
+ #### number {#assertdir_number}
962
+
963
+ <b>Prerequisites</b>
964
+
965
+ ```typescript
966
+ import { number } from 'bguard/number';
967
+ ```
968
+
969
+ * _Description_ Creates a new schema for validating number values.
970
+ * _Example_
971
+ ```typescript
972
+ const schema = number();
973
+ parseOrFail(schema, 42); // Validates successfully
974
+ parseOrFail(schema, '42'); // Throws a validation error
975
+ ```
976
+
977
+
978
+ ##### max (number) {#assert_max_number}
979
+
980
+ ```typescript
981
+ import { max } from 'bguard/number/max';
982
+ ```
983
+
984
+ * _Description_ Asserts that a number value does not exceed a specified maximum value.
985
+ * _Param_ {number} expected The maximum allowable value.
986
+ * _Throws_ {ValidationError} if the received value exceeds the expected maximum value.
987
+ * _Example_
988
+ ```typescript
989
+ const schema = number().custom(max(100));
990
+ parseOrFail(schema, 99); // Valid
991
+ parseOrFail(schema, 100); // Valid
992
+ parseOrFail(schema, 101); // Throws an error: 'The received value is greater than expected'
993
+ ```
994
+ * _See_ Error Translation Key = 'n:max'
995
+
996
+
997
+ ##### maxExcluded (number) {#assert_maxExcluded_number}
998
+
999
+ ```typescript
1000
+ import { maxExcluded } from 'bguard/number/maxExcluded';
1001
+ ```
1002
+
1003
+ * _Description_ - Asserts that a number value is strictly less than a specified maximum value (i.e., the maximum value is excluded).
1004
+ * _Param_ {number} expected - The maximum allowable value, which is excluded.
1005
+ * _Throws_ {ValidationError} if the received value is greater than or equal to the expected maximum value.
1006
+ * _Example_
1007
+ ```typescript
1008
+ const schema = number().custom(maxExcluded(100));
1009
+ parseOrFail(schema, 99); // Valid
1010
+ parseOrFail(schema, 100); // Throws an error: 'The received value is greater than or equal to expected'
1011
+ parseOrFail(schema, 101); // Throws an error: 'The received value is greater than or equal to expected'
1012
+ ```
1013
+ * _See_ Error Translation Key = 'n:maxExcluded'
1014
+
1015
+
1016
+ ##### min (number) {#assert_min_number}
1017
+
1018
+ ```typescript
1019
+ import { min } from 'bguard/number/min';
1020
+ ```
1021
+
1022
+ * _Description_ Asserts that a number value is not less than a specified minimum value.
1023
+ * _Param_ {number} expected The minimum allowable value.
1024
+ * _Throws_ {ValidationError} if the received value is less than the expected minimum value.
1025
+ * _Example_
1026
+ ```typescript
1027
+ const schema = number().custom(min(10));
1028
+ parseOrFail(schema, 11); // Valid
1029
+ parseOrFail(schema, 10); // Valid
1030
+ parseOrFail(schema, 9); // Throws an error: 'The received value is less than expected'
1031
+ ```
1032
+ * _See_ Error Translation Key = 'n:min'
1033
+
1034
+
1035
+ ##### minExcluded (number) {#assert_minExcluded_number}
1036
+
1037
+ ```typescript
1038
+ import { minExcluded } from 'bguard/number/minExcluded';
1039
+ ```
1040
+
1041
+ * _Description_ Asserts that a number value is strictly greater than a specified minimum value (i.e., the minimum value is excluded).
1042
+ * _Param_ {number} expected The minimum allowable value, which is excluded.
1043
+ * _Throws_ {ValidationError} if the received value is less than or equal to the expected minimum value.
1044
+ * _Example_
1045
+ ```typescript
1046
+ const schema = number().custom(minExcluded(10));
1047
+ parseOrFail(schema, 11); // Valid
1048
+ parseOrFail(schema, 10); // Throws an error: 'The received value is less than or equal to expected'
1049
+ parseOrFail(schema, 9); // Throws an error: 'The received value is less than or equal to expected'
1050
+ ```
1051
+ * _See_ Error Translation Key = 'n:minExcluded'
1052
+
1053
+
1054
+ ##### negative (number) {#assert_negative_number}
1055
+
1056
+ ```typescript
1057
+ import { negative } from 'bguard/number/negative';
1058
+ ```
1059
+
1060
+ * _Description_ Asserts that a number value is negative (less than zero).
1061
+ * _Throws_ {ValidationError} if the received value is not negative.
1062
+ * _Example_
1063
+ ```typescript
1064
+ const schema = number().custom(negative());
1065
+ parseOrFail(schema, -10); // Valid
1066
+ parseOrFail(schema, 0); // Throws an error: 'The received value is not a negative number'
1067
+ parseOrFail(schema, 5); // Throws an error: 'The received value is not a negative number'
1068
+ ```
1069
+ * _See_ - Error Translation Key = 'n:negative'
1070
+
1071
+
1072
+ ##### positive (number) {#assert_positive_number}
1073
+
1074
+ ```typescript
1075
+ import { positive } from 'bguard/number/positive';
1076
+ ```
1077
+
1078
+ * _Description_ Asserts that a number value is positive (greater than zero).
1079
+ * _Throws_ {ValidationError} if the received value is not positive.
1080
+ * _Example_
1081
+ ```typescript
1082
+ const schema = number().custom(positive());
1083
+ parseOrFail(schema, 10); // Valid
1084
+ parseOrFail(schema, 0); // Throws an error: 'The received value is not a positive number'
1085
+ parseOrFail(schema, -5); // Throws an error: 'The received value is not a positive number'
1086
+ ```
1087
+ * _See_ Error Translation Key = 'n:positive'
1088
+
1089
+ #### array {#assertdir_array}
1090
+
1091
+ <b>Prerequisites</b>
1092
+
1093
+ ```typescript
1094
+ import { array } from 'bguard/array';
1095
+ ```
1096
+
1097
+ * _Description_ Creates a new schema for validating arrays where each element must match the specified schema.
1098
+
1099
+ * _Param_ {T} arraySchema - The schema that each element of the array must match.
1100
+ * _Example_
1101
+ ```typescript
1102
+ const schema = array(string());
1103
+ parseOrFail(schema, ['hello', 'world']); // Validates successfully
1104
+ parseOrFail(schema, ['hello', 123]); // Throws a validation error
1105
+ ```
1106
+
1107
+
1108
+ ##### maxArrayLength (array) {#assert_maxArrayLength_array}
1109
+
1110
+ ```typescript
1111
+ import { maxArrayLength } from 'bguard/array/maxArrayLength';
1112
+ ```
1113
+
1114
+ * _Description_ Asserts that the length of an array is not greater than a specified maximum length.
1115
+ * _Param_ {number} expected The maximum allowed length for the array.
1116
+ * _Throws_ {ValidationError} if the length of the received value is greater than the expected length.
1117
+ * _Example_
1118
+ ```typescript
1119
+ const schema = array(string()).custom(maxArrayLength(3));
1120
+ parseOrFail(schema, ['adequate', 'array']); // Valid
1121
+ parseOrFail(schema, ['adequate', 'array', 'length']); // Valid
1122
+ parseOrFail(schema, ['adequate', 'array', 'length', 'test']); // Throws an error: 'The received value length is greater than expected'
1123
+ ```
1124
+ * _See_ Error Translation Key = 'a:maxArrayLength'
1125
+
1126
+
1127
+ ##### minArrayLength (array) {#assert_minArrayLength_array}
1128
+
1129
+ ```typescript
1130
+ import { minArrayLength } from 'bguard/array/minArrayLength';
1131
+ ```
1132
+
1133
+ * _Description_ Asserts that the length of na array is not less than a specified minimum length.
1134
+ * _Param_ {number} expected The minimum required length for the array.
1135
+ * _Throws_ {ValidationError} if the length of the received value is less than the expected length.
1136
+ * _Example_
1137
+ ```typescript
1138
+ const schema = array(string()).custom(minArrayLength(3));
1139
+ parseOrFail(schema, ['short', 'array']); // Throws an error: 'The received value length is less than expected'
1140
+ parseOrFail(schema, ['adequate', 'array', 'length']); // Valid
1141
+ parseOrFail(schema, ['adequate', 'array', 'length', 'test']); // Valid
1142
+ ```
1143
+ * _See_ Error Translation Key = 'a:minArrayLength'
1144
+
1145
+ #### bigint {#assertdir_bigint}
1146
+
1147
+ <b>Prerequisites</b>
1148
+
1149
+ ```typescript
1150
+ import { bigint } from 'bguard/bigint';
1151
+ ```
1152
+
1153
+ * _Description_ Creates a new schema for validating bigint values.
1154
+ * _Example_
1155
+ ```typescript
1156
+ const schema = bigint();
1157
+ parseOrFail(schema, 42n); // Validates successfully
1158
+ parseOrFail(schema, 42); // Throws a validation error
1159
+ parseOrFail(schema, '42'); // Throws a validation error
1160
+ ```
1161
+
1162
+
1163
+ ##### bigintMax (bigint) {#assert_bigintMax_bigint}
1164
+
1165
+ ```typescript
1166
+ import { bigintMax } from 'bguard/bigint/bigintMax';
1167
+ ```
1168
+
1169
+ * _Description_ Asserts that a bigint value does not exceed a specified maximum value.
1170
+ * _Param_ {bigint} expected The maximum allowable value.
1171
+ * _Throws_ {ValidationError} if the received value exceeds the expected maximum value.
1172
+ * _Example_
1173
+ ```typescript
1174
+ const schema = bigint().custom(bigintMax(100n));
1175
+ parseOrFail(schema, 99n); // Valid
1176
+ parseOrFail(schema, 100n); // Valid
1177
+ parseOrFail(schema, 101n); // Throws an error: 'The received value is greater than expected'
1178
+ ```
1179
+ * _See_ Error Translation Key = 'bi:max'
1180
+
1181
+
1182
+ ##### bigintMaxExcluded (bigint) {#assert_bigintMaxExcluded_bigint}
1183
+
1184
+ ```typescript
1185
+ import { bigintMaxExcluded } from 'bguard/bigint/bigintMaxExcluded';
1186
+ ```
1187
+
1188
+ * _Description_ - Asserts that a bigint value is strictly less than a specified maximum value (i.e., the maximum value is excluded).
1189
+ * _Param_ {bigint} expected - The maximum allowable value, which is excluded.
1190
+ * _Throws_ {ValidationError} if the received value is greater than or equal to the expected maximum value.
1191
+ * _Example_
1192
+ ```typescript
1193
+ const schema = bigint().custom(bigintMaxExcluded(100n));
1194
+ parseOrFail(schema, 99n); // Valid
1195
+ parseOrFail(schema, 100n); // Throws an error: 'The received value is greater than or equal to expected'
1196
+ parseOrFail(schema, 101n); // Throws an error: 'The received value is greater than or equal to expected'
1197
+ ```
1198
+ * _See_ Error Translation Key = 'bi:maxExcluded'
1199
+
1200
+
1201
+ ##### bigintMin (bigint) {#assert_bigintMin_bigint}
1202
+
1203
+ ```typescript
1204
+ import { bigintMin } from 'bguard/bigint/bigintMin';
1205
+ ```
1206
+
1207
+ * _Description_ Asserts that a bigint value is not less than a specified minimum value.
1208
+ * _Param_ {bigint} expected The minimum allowable value.
1209
+ * _Throws_ {ValidationError} if the received value is less than the expected minimum value.
1210
+ * _Example_
1211
+ ```typescript
1212
+ const schema = bigint().custom(bigintMin(10n));
1213
+ parseOrFail(schema, 11n); // Valid
1214
+ parseOrFail(schema, 10n); // Valid
1215
+ parseOrFail(schema, 9n); // Throws an error: 'The received value is less than expected'
1216
+ ```
1217
+ * _See_ Error Translation Key = 'bi:min'
1218
+
1219
+
1220
+ ##### bigintMinExcluded (bigint) {#assert_bigintMinExcluded_bigint}
1221
+
1222
+ ```typescript
1223
+ import { bigintMinExcluded } from 'bguard/bigint/bigintMinExcluded';
1224
+ ```
1225
+
1226
+ * _Description_ Asserts that a bigint value is strictly greater than a specified minimum value (i.e., the minimum value is excluded).
1227
+ * _Param_ {bigint} expected The minimum allowable value, which is excluded.
1228
+ * _Throws_ {ValidationError} if the received value is less than or equal to the expected minimum value.
1229
+ * _Example_
1230
+ ```typescript
1231
+ const schema = bigint().custom(bigintMinExcluded(10n));
1232
+ parseOrFail(schema, 11n); // Valid
1233
+ parseOrFail(schema, 10n); // Throws an error: 'The received value is less than or equal to expected'
1234
+ parseOrFail(schema, 9n); // Throws an error: 'The received value is less than or equal to expected'
1235
+ ```
1236
+ * _See_ Error Translation Key = 'bi:minExcluded'
1237
+
1238
+ #### date {#assertdir_date}
1239
+
1240
+ <b>Prerequisites</b>
1241
+
1242
+ ```typescript
1243
+ import { date } from 'bguard/date';
1244
+ ```
1245
+
1246
+ * _Description_ Creates a new schema for validating date values.
1247
+ * _Example_
1248
+ ```typescript
1249
+ const schema = date();
1250
+ parseOrFail(schema, true); // Validates successfully
1251
+ parseOrFail(schema, 'true'); // Throws a validation error
1252
+ ```
1253
+
1254
+
1255
+ ##### dateMax (date) {#assert_dateMax_date}
1256
+
1257
+ ```typescript
1258
+ import { dateMax } from 'bguard/date/dateMax';
1259
+ ```
1260
+
1261
+ * _Description_ Asserts that a date value is not greater than a specified maximum value.
1262
+ * _Param_ {Date | string} expected The maximum allowable value.
1263
+ * _Throws_ {ValidationError} if the received value is greater than the expected maximum value.
1264
+ * _Example_
1265
+ ```typescript
1266
+ const schema = date().custom(dateMax('2024-12-31'));
1267
+ parseOrFail(schema, new Date('2024-12-30')); // Valid
1268
+ parseOrFail(schema, new Date('2024-12-31')); // Valid
1269
+ parseOrFail(schema, new Date('2025-01-01')); // Throws an error: 'The received value is greater than expected'
1270
+ ```
1271
+ * _See_ Error Translation Key = 'dt:max'
1272
+
1273
+
1274
+ ##### dateMin (date) {#assert_dateMin_date}
1275
+
1276
+ ```typescript
1277
+ import { dateMin } from 'bguard/date/dateMin';
1278
+ ```
1279
+
1280
+ * _Description_ Asserts that a number value is not less than a specified minimum value.
1281
+ * _Param_ {Date | string} expected The minimum allowable value.
1282
+ * _Throws_ {ValidationError} if the received value is less than the expected minimum value.
1283
+ * _Example_
1284
+ ```typescript
1285
+ const schema = date().custom(dateMin('2023-01-01'));
1286
+ parseOrFail(schema, new Date('2023-01-02')); // Valid
1287
+ parseOrFail(schema, new Date('2023-01-01')); // Valid
1288
+ parseOrFail(schema, new Date('2022-12-31')); // Throws an error: 'The received value is less than expected'
1289
+ ```
1290
+ * _See_ Error Translation Key = 'dt:min'
1291
+
1292
+ #### mix {#assertdir_mix}
1293
+
1294
+ <b>Prerequisites</b>
1295
+
1296
+ ```typescript
1297
+ import { oneOfTypes } from 'bguard/mix';
1298
+ ```
1299
+
1300
+ * _Description_ Creates a new schema for validating values that can match any one of the specified primitive types.
1301
+
1302
+
1303
+ * _Param_ {T} valueTypes - An array of primitive types that the value can match.
1304
+ * _Example_
1305
+ ```typescript
1306
+ const schema = oneOfTypes(['string', 'number']);
1307
+ parseOrFail(schema, 'hello'); // Validates successfully
1308
+ parseOrFail(schema, 42); // Validates successfully
1309
+ parseOrFail(schema, true); // Throws a validation error
1310
+ ```
1311
+
1312
+
1313
+ ##### equalTo (mix) {#assert_equalTo_mix}
1314
+
1315
+ ```typescript
1316
+ import { equalTo } from 'bguard/mix/equalTo';
1317
+ ```
1318
+
1319
+ * _Description_ Creates a custom assertion that checks if a value is equal to the expected value.
1320
+ * > **Notice:** It has already been implemented in the number, bigint and string schema. There is no need to use it as a custom assert.
1321
+ * _Param_ {unknown} expected The value that the received value is expected to match.
1322
+ * _Throws_ {ValidationError} If the received value does not match the expected value.
1323
+ * _Example_
1324
+ ```typescript
1325
+ const schema = number().custom(equalTo(5)); // Define a schema with a custom assertion
1326
+ parseOrFail(schema, 5); // Valid
1327
+ parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'
1328
+ ```
1329
+ * _See_ Error Translation Key = 'm:equalTo'
1330
+
1331
+
1332
+ ##### oneOfValues (mix) {#assert_oneOfValues_mix}
1333
+
1334
+ ```typescript
1335
+ import { oneOfValues } from 'bguard/mix/oneOfValues';
1336
+ ```
1337
+
1338
+ * _Description_ Creates a custom assertion that checks if a value is equal to the one of expected values.
1339
+ * > **Notice:** It has already been implemented in the number, bigint and string schema. There is no need to use it as a custom assert.
1340
+ * _Param_ {unknown} expected The value that the received value is expected to match.
1341
+ * _Throws_ {ValidationError} If the received value does not match at least one of the expected values.
1342
+ * _Example_
1343
+ ```typescript
1344
+ const schema = number().custom(oneOfValues([5, 4])); // Define a schema with a custom assertion
1345
+ parseOrFail(schema, 5); // Valid
1346
+ parseOrFail(schema, 4); // Valid
1347
+ parseOrFail(schema, 3); // Throws an error: 'The received value is not equal to expected'
1348
+ ```
1349
+ * _See_ Error Translation Key = 'm:oneOfValues'
1350
+
965
1351
  ### Contributing
966
- Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.
1352
+ Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.