@astral/validations 4.20.3 → 4.21.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 (453) hide show
  1. package/node/any/any.d.ts +23 -0
  2. package/node/any/any.js +29 -0
  3. package/node/any/index.d.ts +1 -0
  4. package/node/any/index.js +17 -0
  5. package/node/array/array.d.ts +15 -0
  6. package/node/array/array.js +25 -0
  7. package/node/array/constants.d.ts +2 -0
  8. package/node/array/constants.js +8 -0
  9. package/node/array/index.d.ts +2 -0
  10. package/node/array/index.js +18 -0
  11. package/node/arrayItem/arrayItem.d.ts +27 -0
  12. package/node/arrayItem/arrayItem.js +37 -0
  13. package/node/arrayItem/index.d.ts +1 -0
  14. package/node/arrayItem/index.js +17 -0
  15. package/node/boolean/boolean.d.ts +13 -0
  16. package/node/boolean/boolean.js +23 -0
  17. package/node/boolean/constants.d.ts +2 -0
  18. package/node/boolean/constants.js +8 -0
  19. package/node/boolean/index.d.ts +2 -0
  20. package/node/boolean/index.js +18 -0
  21. package/node/containsDifferentCases/constants.d.ts +2 -0
  22. package/node/containsDifferentCases/constants.js +5 -0
  23. package/node/containsDifferentCases/containsDifferentCases.d.ts +16 -0
  24. package/node/containsDifferentCases/containsDifferentCases.js +26 -0
  25. package/node/containsDifferentCases/index.d.ts +2 -0
  26. package/node/containsDifferentCases/index.js +18 -0
  27. package/node/containsNumbers/constants.d.ts +2 -0
  28. package/node/containsNumbers/constants.js +5 -0
  29. package/node/containsNumbers/containsNumbers.d.ts +16 -0
  30. package/node/containsNumbers/containsNumbers.js +24 -0
  31. package/node/containsNumbers/index.d.ts +2 -0
  32. package/node/containsNumbers/index.js +18 -0
  33. package/node/containsPunctuationMarks/constants.d.ts +2 -0
  34. package/node/containsPunctuationMarks/constants.js +5 -0
  35. package/node/containsPunctuationMarks/containsPunctuationMarks.d.ts +16 -0
  36. package/node/containsPunctuationMarks/containsPunctuationMarks.js +24 -0
  37. package/node/containsPunctuationMarks/index.d.ts +2 -0
  38. package/node/containsPunctuationMarks/index.js +18 -0
  39. package/node/core/compose/compose.d.ts +6 -0
  40. package/node/core/compose/compose.js +11 -0
  41. package/node/core/compose/index.d.ts +1 -0
  42. package/node/core/compose/index.js +17 -0
  43. package/node/core/composeAsync/composeAsync.d.ts +6 -0
  44. package/node/core/composeAsync/composeAsync.js +28 -0
  45. package/node/core/composeAsync/index.d.ts +1 -0
  46. package/node/core/composeAsync/index.js +17 -0
  47. package/node/core/context/createContext/createContext.d.ts +19 -0
  48. package/node/core/context/createContext/createContext.js +25 -0
  49. package/node/core/context/createContext/index.d.ts +1 -0
  50. package/node/core/context/createContext/index.js +17 -0
  51. package/node/core/context/index.d.ts +2 -0
  52. package/node/core/context/index.js +18 -0
  53. package/node/core/context/types.d.ts +37 -0
  54. package/node/core/context/types.js +2 -0
  55. package/node/core/errors/ArrayError/ArrayError.d.ts +18 -0
  56. package/node/core/errors/ArrayError/ArrayError.js +14 -0
  57. package/node/core/errors/ArrayError/createArrayError/createArrayError.d.ts +5 -0
  58. package/node/core/errors/ArrayError/createArrayError/createArrayError.js +15 -0
  59. package/node/core/errors/ArrayError/createArrayError/index.d.ts +1 -0
  60. package/node/core/errors/ArrayError/createArrayError/index.js +17 -0
  61. package/node/core/errors/ArrayError/index.d.ts +2 -0
  62. package/node/core/errors/ArrayError/index.js +18 -0
  63. package/node/core/errors/ErrorMap/ErrorMap.d.ts +21 -0
  64. package/node/core/errors/ErrorMap/ErrorMap.js +14 -0
  65. package/node/core/errors/ErrorMap/createErrorMap/createErrorMap.d.ts +5 -0
  66. package/node/core/errors/ErrorMap/createErrorMap/createErrorMap.js +14 -0
  67. package/node/core/errors/ErrorMap/createErrorMap/index.d.ts +1 -0
  68. package/node/core/errors/ErrorMap/createErrorMap/index.js +17 -0
  69. package/node/core/errors/ErrorMap/index.d.ts +2 -0
  70. package/node/core/errors/ErrorMap/index.js +18 -0
  71. package/node/core/errors/SimpleError/SimpleError.d.ts +16 -0
  72. package/node/core/errors/SimpleError/SimpleError.js +13 -0
  73. package/node/core/errors/SimpleError/createSimpleError/createSimpleError.d.ts +6 -0
  74. package/node/core/errors/SimpleError/createSimpleError/createSimpleError.js +9 -0
  75. package/node/core/errors/SimpleError/createSimpleError/index.d.ts +1 -0
  76. package/node/core/errors/SimpleError/createSimpleError/index.js +17 -0
  77. package/node/core/errors/SimpleError/index.d.ts +2 -0
  78. package/node/core/errors/SimpleError/index.js +18 -0
  79. package/node/core/errors/constants.d.ts +2 -0
  80. package/node/core/errors/constants.js +8 -0
  81. package/node/core/errors/createErrorCode/createErrorCode.d.ts +5 -0
  82. package/node/core/errors/createErrorCode/createErrorCode.js +8 -0
  83. package/node/core/errors/createErrorCode/index.d.ts +1 -0
  84. package/node/core/errors/createErrorCode/index.js +17 -0
  85. package/node/core/errors/index.d.ts +6 -0
  86. package/node/core/errors/index.js +22 -0
  87. package/node/core/errors/types.d.ts +18 -0
  88. package/node/core/errors/types.js +2 -0
  89. package/node/core/guard/createGuard/createGuard.d.ts +71 -0
  90. package/node/core/guard/createGuard/createGuard.js +28 -0
  91. package/node/core/guard/createGuard/index.d.ts +1 -0
  92. package/node/core/guard/createGuard/index.js +17 -0
  93. package/node/core/guard/index.d.ts +1 -0
  94. package/node/core/guard/index.js +17 -0
  95. package/node/core/index.d.ts +9 -0
  96. package/node/core/index.js +25 -0
  97. package/node/core/logger/index.d.ts +1 -0
  98. package/node/core/logger/index.js +17 -0
  99. package/node/core/logger/logger.d.ts +6 -0
  100. package/node/core/logger/logger.js +12 -0
  101. package/node/core/rule/callAsyncRule/callAsyncRule.d.ts +8 -0
  102. package/node/core/rule/callAsyncRule/callAsyncRule.js +29 -0
  103. package/node/core/rule/callAsyncRule/index.d.ts +1 -0
  104. package/node/core/rule/callAsyncRule/index.js +17 -0
  105. package/node/core/rule/callRule/callRule.d.ts +7 -0
  106. package/node/core/rule/callRule/callRule.js +13 -0
  107. package/node/core/rule/callRule/index.d.ts +1 -0
  108. package/node/core/rule/callRule/index.js +17 -0
  109. package/node/core/rule/createRule/createRule.d.ts +34 -0
  110. package/node/core/rule/createRule/createRule.js +31 -0
  111. package/node/core/rule/createRule/index.d.ts +1 -0
  112. package/node/core/rule/createRule/index.js +17 -0
  113. package/node/core/rule/index.d.ts +5 -0
  114. package/node/core/rule/index.js +21 -0
  115. package/node/core/rule/required/constants.d.ts +2 -0
  116. package/node/core/rule/required/constants.js +8 -0
  117. package/node/core/rule/required/index.d.ts +2 -0
  118. package/node/core/rule/required/index.js +18 -0
  119. package/node/core/rule/required/required.d.ts +11 -0
  120. package/node/core/rule/required/required.js +29 -0
  121. package/node/core/rule/types.d.ts +23 -0
  122. package/node/core/rule/types.js +2 -0
  123. package/node/core/types.d.ts +9 -0
  124. package/node/core/types.js +2 -0
  125. package/node/core/utils/index.d.ts +8 -0
  126. package/node/core/utils/index.js +24 -0
  127. package/node/core/utils/isDateEarlier/index.d.ts +1 -0
  128. package/node/core/utils/isDateEarlier/index.js +17 -0
  129. package/node/core/utils/isDateEarlier/isDateEarlier.d.ts +1 -0
  130. package/node/core/utils/isDateEarlier/isDateEarlier.js +8 -0
  131. package/node/core/utils/isFullNameValidCharacters/index.d.ts +1 -0
  132. package/node/core/utils/isFullNameValidCharacters/index.js +17 -0
  133. package/node/core/utils/isFullNameValidCharacters/isFullNameValidCharacters.d.ts +5 -0
  134. package/node/core/utils/isFullNameValidCharacters/isFullNameValidCharacters.js +9 -0
  135. package/node/core/utils/isHasConsecutiveChars/index.d.ts +1 -0
  136. package/node/core/utils/isHasConsecutiveChars/index.js +17 -0
  137. package/node/core/utils/isHasConsecutiveChars/isHasConsecutiveChars.d.ts +4 -0
  138. package/node/core/utils/isHasConsecutiveChars/isHasConsecutiveChars.js +8 -0
  139. package/node/core/utils/isNoDoubleZeroStart/index.d.ts +1 -0
  140. package/node/core/utils/isNoDoubleZeroStart/index.js +17 -0
  141. package/node/core/utils/isNoDoubleZeroStart/isNoDoubleZeroStart.d.ts +4 -0
  142. package/node/core/utils/isNoDoubleZeroStart/isNoDoubleZeroStart.js +8 -0
  143. package/node/core/utils/isStartsWithAndEndsWithLetter/index.d.ts +1 -0
  144. package/node/core/utils/isStartsWithAndEndsWithLetter/index.js +17 -0
  145. package/node/core/utils/isStartsWithAndEndsWithLetter/isStartsWithAndEndsWithLetter.d.ts +4 -0
  146. package/node/core/utils/isStartsWithAndEndsWithLetter/isStartsWithAndEndsWithLetter.js +8 -0
  147. package/node/core/utils/isStringOfZeros/index.d.ts +1 -0
  148. package/node/core/utils/isStringOfZeros/index.js +17 -0
  149. package/node/core/utils/isStringOfZeros/isStringOfZeros.d.ts +4 -0
  150. package/node/core/utils/isStringOfZeros/isStringOfZeros.js +13 -0
  151. package/node/core/utils/isValidFullNameLength/index.d.ts +1 -0
  152. package/node/core/utils/isValidFullNameLength/index.js +17 -0
  153. package/node/core/utils/isValidFullNameLength/isValidFullNameLength.d.ts +4 -0
  154. package/node/core/utils/isValidFullNameLength/isValidFullNameLength.js +8 -0
  155. package/node/core/utils/resetTime/index.d.ts +1 -0
  156. package/node/core/utils/resetTime/index.js +17 -0
  157. package/node/core/utils/resetTime/resetTime.d.ts +5 -0
  158. package/node/core/utils/resetTime/resetTime.js +16 -0
  159. package/node/date/constants.d.ts +3 -0
  160. package/node/date/constants.js +12 -0
  161. package/node/date/date.d.ts +19 -0
  162. package/node/date/date.js +28 -0
  163. package/node/date/index.d.ts +2 -0
  164. package/node/date/index.js +18 -0
  165. package/node/deepPartial/deepPartial.d.ts +21 -0
  166. package/node/deepPartial/deepPartial.js +25 -0
  167. package/node/deepPartial/index.d.ts +1 -0
  168. package/node/deepPartial/index.js +17 -0
  169. package/node/email/constants.d.ts +10 -0
  170. package/node/email/constants.js +22 -0
  171. package/node/email/email.d.ts +30 -0
  172. package/node/email/email.js +59 -0
  173. package/node/email/index.d.ts +2 -0
  174. package/node/email/index.js +18 -0
  175. package/node/enabled/enabled.d.ts +34 -0
  176. package/node/enabled/enabled.js +35 -0
  177. package/node/enabled/index.d.ts +1 -0
  178. package/node/enabled/index.js +17 -0
  179. package/node/guid/constants.d.ts +3 -0
  180. package/node/guid/constants.js +9 -0
  181. package/node/guid/guid.d.ts +16 -0
  182. package/node/guid/guid.js +20 -0
  183. package/node/guid/index.d.ts +2 -0
  184. package/node/guid/index.js +18 -0
  185. package/node/index.d.ts +53 -0
  186. package/node/index.js +185 -0
  187. package/node/innFL/constants.d.ts +2 -0
  188. package/node/innFL/constants.js +8 -0
  189. package/node/innFL/index.d.ts +2 -0
  190. package/node/innFL/index.js +18 -0
  191. package/node/innFL/innFL.d.ts +17 -0
  192. package/node/innFL/innFL.js +25 -0
  193. package/node/innIP/constants.d.ts +2 -0
  194. package/node/innIP/constants.js +8 -0
  195. package/node/innIP/index.d.ts +2 -0
  196. package/node/innIP/index.js +18 -0
  197. package/node/innIP/innIP.d.ts +17 -0
  198. package/node/innIP/innIP.js +31 -0
  199. package/node/innTwelveSymbols/constants.d.ts +5 -0
  200. package/node/innTwelveSymbols/constants.js +13 -0
  201. package/node/innTwelveSymbols/index.d.ts +2 -0
  202. package/node/innTwelveSymbols/index.js +18 -0
  203. package/node/innTwelveSymbols/innTwelveSymbols.d.ts +17 -0
  204. package/node/innTwelveSymbols/innTwelveSymbols.js +41 -0
  205. package/node/innUL/constants.d.ts +4 -0
  206. package/node/innUL/constants.js +10 -0
  207. package/node/innUL/index.d.ts +2 -0
  208. package/node/innUL/index.js +18 -0
  209. package/node/innUL/innUL.d.ts +17 -0
  210. package/node/innUL/innUL.js +43 -0
  211. package/node/integer/constants.d.ts +2 -0
  212. package/node/integer/constants.js +8 -0
  213. package/node/integer/index.d.ts +2 -0
  214. package/node/integer/index.js +18 -0
  215. package/node/integer/integer.d.ts +25 -0
  216. package/node/integer/integer.js +32 -0
  217. package/node/kpp/constants.d.ts +5 -0
  218. package/node/kpp/constants.js +17 -0
  219. package/node/kpp/index.d.ts +2 -0
  220. package/node/kpp/index.js +18 -0
  221. package/node/kpp/kpp.d.ts +17 -0
  222. package/node/kpp/kpp.js +30 -0
  223. package/node/length/constants.d.ts +2 -0
  224. package/node/length/constants.js +5 -0
  225. package/node/length/index.d.ts +2 -0
  226. package/node/length/index.js +18 -0
  227. package/node/length/length.d.ts +22 -0
  228. package/node/length/length.js +30 -0
  229. package/node/max/constants.d.ts +5 -0
  230. package/node/max/constants.js +8 -0
  231. package/node/max/index.d.ts +2 -0
  232. package/node/max/index.js +18 -0
  233. package/node/max/max.d.ts +26 -0
  234. package/node/max/max.js +46 -0
  235. package/node/min/constants.d.ts +5 -0
  236. package/node/min/constants.js +8 -0
  237. package/node/min/index.d.ts +2 -0
  238. package/node/min/index.js +18 -0
  239. package/node/min/min.d.ts +26 -0
  240. package/node/min/min.js +46 -0
  241. package/node/minYearsOld/constants.d.ts +4 -0
  242. package/node/minYearsOld/constants.js +7 -0
  243. package/node/minYearsOld/index.d.ts +2 -0
  244. package/node/minYearsOld/index.js +18 -0
  245. package/node/minYearsOld/minYearsOld.d.ts +24 -0
  246. package/node/minYearsOld/minYearsOld.js +48 -0
  247. package/node/mobilePhone/constants.d.ts +3 -0
  248. package/node/mobilePhone/constants.js +9 -0
  249. package/node/mobilePhone/index.d.ts +2 -0
  250. package/node/mobilePhone/index.js +18 -0
  251. package/node/mobilePhone/mobilePhone.d.ts +19 -0
  252. package/node/mobilePhone/mobilePhone.js +25 -0
  253. package/node/number/constants.d.ts +4 -0
  254. package/node/number/constants.js +16 -0
  255. package/node/number/index.d.ts +2 -0
  256. package/node/number/index.js +18 -0
  257. package/node/number/number.d.ts +19 -0
  258. package/node/number/number.js +30 -0
  259. package/node/object/constants.d.ts +2 -0
  260. package/node/object/constants.js +8 -0
  261. package/node/object/index.d.ts +3 -0
  262. package/node/object/index.js +19 -0
  263. package/node/object/isEmptyErrors/index.d.ts +1 -0
  264. package/node/object/isEmptyErrors/index.js +17 -0
  265. package/node/object/isEmptyErrors/isEmptyErrors.d.ts +5 -0
  266. package/node/object/isEmptyErrors/isEmptyErrors.js +8 -0
  267. package/node/object/object.d.ts +49 -0
  268. package/node/object/object.js +54 -0
  269. package/node/object/objectAsync/index.d.ts +1 -0
  270. package/node/object/objectAsync/index.js +17 -0
  271. package/node/object/objectAsync/objectAsync.d.ts +61 -0
  272. package/node/object/objectAsync/objectAsync.js +76 -0
  273. package/node/ogrnIP/constants.d.ts +3 -0
  274. package/node/ogrnIP/constants.js +9 -0
  275. package/node/ogrnIP/index.d.ts +2 -0
  276. package/node/ogrnIP/index.js +18 -0
  277. package/node/ogrnIP/ogrnIP.d.ts +17 -0
  278. package/node/ogrnIP/ogrnIP.js +31 -0
  279. package/node/ogrnUL/constants.d.ts +3 -0
  280. package/node/ogrnUL/constants.js +9 -0
  281. package/node/ogrnUL/index.d.ts +2 -0
  282. package/node/ogrnUL/index.js +18 -0
  283. package/node/ogrnUL/ogrnUL.d.ts +17 -0
  284. package/node/ogrnUL/ogrnUL.js +31 -0
  285. package/node/onlyNumber/constants.d.ts +2 -0
  286. package/node/onlyNumber/constants.js +5 -0
  287. package/node/onlyNumber/index.d.ts +2 -0
  288. package/node/onlyNumber/index.js +18 -0
  289. package/node/onlyNumber/onlyNumber.d.ts +16 -0
  290. package/node/onlyNumber/onlyNumber.js +24 -0
  291. package/node/optional/index.d.ts +2 -0
  292. package/node/optional/index.js +18 -0
  293. package/node/optional/optional.d.ts +6 -0
  294. package/node/optional/optional.js +10 -0
  295. package/node/optional/optionalAsync/index.d.ts +1 -0
  296. package/node/optional/optionalAsync/index.js +17 -0
  297. package/node/optional/optionalAsync/optionalAsync.d.ts +6 -0
  298. package/node/optional/optionalAsync/optionalAsync.js +22 -0
  299. package/node/or/index.d.ts +1 -0
  300. package/node/or/index.js +17 -0
  301. package/node/or/or.d.ts +14 -0
  302. package/node/or/or.js +25 -0
  303. package/node/partial/index.d.ts +1 -0
  304. package/node/partial/index.js +17 -0
  305. package/node/partial/partial.d.ts +9 -0
  306. package/node/partial/partial.js +10 -0
  307. package/node/passportCode/constants.d.ts +4 -0
  308. package/node/passportCode/constants.js +16 -0
  309. package/node/passportCode/index.d.ts +2 -0
  310. package/node/passportCode/index.js +18 -0
  311. package/node/passportCode/passportCode.d.ts +17 -0
  312. package/node/passportCode/passportCode.js +42 -0
  313. package/node/passportNumber/constants.d.ts +4 -0
  314. package/node/passportNumber/constants.js +16 -0
  315. package/node/passportNumber/index.d.ts +2 -0
  316. package/node/passportNumber/index.js +18 -0
  317. package/node/passportNumber/passportNumber.d.ts +17 -0
  318. package/node/passportNumber/passportNumber.js +36 -0
  319. package/node/passportSeries/constants.d.ts +4 -0
  320. package/node/passportSeries/constants.js +16 -0
  321. package/node/passportSeries/index.d.ts +2 -0
  322. package/node/passportSeries/index.js +18 -0
  323. package/node/passportSeries/passportSeries.d.ts +17 -0
  324. package/node/passportSeries/passportSeries.js +36 -0
  325. package/node/pattern/constants.d.ts +2 -0
  326. package/node/pattern/constants.js +5 -0
  327. package/node/pattern/index.d.ts +2 -0
  328. package/node/pattern/index.js +18 -0
  329. package/node/pattern/pattern.d.ts +18 -0
  330. package/node/pattern/pattern.js +26 -0
  331. package/node/personName/constants.d.ts +2 -0
  332. package/node/personName/constants.js +8 -0
  333. package/node/personName/index.d.ts +2 -0
  334. package/node/personName/index.js +18 -0
  335. package/node/personName/personName.d.ts +17 -0
  336. package/node/personName/personName.js +33 -0
  337. package/node/personPatronymic/constants.d.ts +2 -0
  338. package/node/personPatronymic/constants.js +8 -0
  339. package/node/personPatronymic/index.d.ts +2 -0
  340. package/node/personPatronymic/index.js +18 -0
  341. package/node/personPatronymic/personPatronymic.d.ts +17 -0
  342. package/node/personPatronymic/personPatronymic.js +33 -0
  343. package/node/personSurname/constants.d.ts +2 -0
  344. package/node/personSurname/constants.js +8 -0
  345. package/node/personSurname/index.d.ts +2 -0
  346. package/node/personSurname/index.js +18 -0
  347. package/node/personSurname/personSurname.d.ts +17 -0
  348. package/node/personSurname/personSurname.js +33 -0
  349. package/node/positiveNumber/constants.d.ts +2 -0
  350. package/node/positiveNumber/constants.js +8 -0
  351. package/node/positiveNumber/index.d.ts +2 -0
  352. package/node/positiveNumber/index.js +18 -0
  353. package/node/positiveNumber/positiveNumber.d.ts +25 -0
  354. package/node/positiveNumber/positiveNumber.js +35 -0
  355. package/node/rangeDate/constants.d.ts +7 -0
  356. package/node/rangeDate/constants.js +28 -0
  357. package/node/rangeDate/index.d.ts +2 -0
  358. package/node/rangeDate/index.js +18 -0
  359. package/node/rangeDate/rangeDate.d.ts +50 -0
  360. package/node/rangeDate/rangeDate.js +69 -0
  361. package/node/rangeDateInterval/constants.d.ts +7 -0
  362. package/node/rangeDateInterval/constants.js +17 -0
  363. package/node/rangeDateInterval/index.d.ts +2 -0
  364. package/node/rangeDateInterval/index.js +18 -0
  365. package/node/rangeDateInterval/rangeDateInterval.d.ts +23 -0
  366. package/node/rangeDateInterval/rangeDateInterval.js +40 -0
  367. package/node/rangeDateInterval/types.d.ts +6 -0
  368. package/node/rangeDateInterval/types.js +2 -0
  369. package/node/rangeDateMinMax/constants.d.ts +8 -0
  370. package/node/rangeDateMinMax/constants.js +16 -0
  371. package/node/rangeDateMinMax/index.d.ts +2 -0
  372. package/node/rangeDateMinMax/index.js +18 -0
  373. package/node/rangeDateMinMax/rangeDateMinMax.d.ts +34 -0
  374. package/node/rangeDateMinMax/rangeDateMinMax.js +78 -0
  375. package/node/rangeDateMinMax/types.d.ts +2 -0
  376. package/node/rangeDateMinMax/types.js +2 -0
  377. package/node/rangeDateNotEqual/constants.d.ts +2 -0
  378. package/node/rangeDateNotEqual/constants.js +8 -0
  379. package/node/rangeDateNotEqual/index.d.ts +2 -0
  380. package/node/rangeDateNotEqual/index.js +18 -0
  381. package/node/rangeDateNotEqual/rangeDateNotEqual.d.ts +20 -0
  382. package/node/rangeDateNotEqual/rangeDateNotEqual.js +33 -0
  383. package/node/snils/constants.d.ts +4 -0
  384. package/node/snils/constants.js +10 -0
  385. package/node/snils/index.d.ts +2 -0
  386. package/node/snils/index.js +18 -0
  387. package/node/snils/snils.d.ts +17 -0
  388. package/node/snils/snils.js +68 -0
  389. package/node/string/constants.d.ts +2 -0
  390. package/node/string/constants.js +8 -0
  391. package/node/string/index.d.ts +3 -0
  392. package/node/string/index.js +19 -0
  393. package/node/string/string.d.ts +2 -0
  394. package/node/string/string.js +13 -0
  395. package/node/string/stringAsync/index.d.ts +1 -0
  396. package/node/string/stringAsync/index.js +17 -0
  397. package/node/string/stringAsync/stringAsync.d.ts +6 -0
  398. package/node/string/stringAsync/stringAsync.js +27 -0
  399. package/node/string/utils/index.d.ts +1 -0
  400. package/node/string/utils/index.js +17 -0
  401. package/node/string/utils/isString/index.d.ts +1 -0
  402. package/node/string/utils/isString/index.js +17 -0
  403. package/node/string/utils/isString/isString.d.ts +1 -0
  404. package/node/string/utils/isString/isString.js +5 -0
  405. package/node/textField/constants.d.ts +5 -0
  406. package/node/textField/constants.js +14 -0
  407. package/node/textField/index.d.ts +2 -0
  408. package/node/textField/index.js +18 -0
  409. package/node/textField/textField.d.ts +24 -0
  410. package/node/textField/textField.js +23 -0
  411. package/node/toPlainError/index.d.ts +1 -0
  412. package/node/toPlainError/index.js +17 -0
  413. package/node/toPlainError/toPlainError.d.ts +35 -0
  414. package/node/toPlainError/toPlainError.js +53 -0
  415. package/node/toPlainError/utils/generateArrayPath/generateArrayPath.d.ts +4 -0
  416. package/node/toPlainError/utils/generateArrayPath/generateArrayPath.js +13 -0
  417. package/node/toPlainError/utils/generateArrayPath/index.d.ts +1 -0
  418. package/node/toPlainError/utils/generateArrayPath/index.js +17 -0
  419. package/node/toPlainError/utils/generateObjectPath/generateObjectPath.d.ts +4 -0
  420. package/node/toPlainError/utils/generateObjectPath/generateObjectPath.js +13 -0
  421. package/node/toPlainError/utils/generateObjectPath/index.d.ts +1 -0
  422. package/node/toPlainError/utils/generateObjectPath/index.js +17 -0
  423. package/node/toPlainError/utils/index.d.ts +2 -0
  424. package/node/toPlainError/utils/index.js +18 -0
  425. package/node/toPrettyError/index.d.ts +1 -0
  426. package/node/toPrettyError/index.js +17 -0
  427. package/node/toPrettyError/toPrettyError.d.ts +39 -0
  428. package/node/toPrettyError/toPrettyError.js +42 -0
  429. package/node/transform/index.d.ts +1 -0
  430. package/node/transform/index.js +17 -0
  431. package/node/transform/transform.d.ts +18 -0
  432. package/node/transform/transform.js +20 -0
  433. package/node/uploadedFile/constants.d.ts +5 -0
  434. package/node/uploadedFile/constants.js +20 -0
  435. package/node/uploadedFile/index.d.ts +2 -0
  436. package/node/uploadedFile/index.js +18 -0
  437. package/node/uploadedFile/types.d.ts +46 -0
  438. package/node/uploadedFile/types.js +2 -0
  439. package/node/uploadedFile/uploadedFile.d.ts +30 -0
  440. package/node/uploadedFile/uploadedFile.js +64 -0
  441. package/node/uploadedFileList/constants.d.ts +2 -0
  442. package/node/uploadedFileList/constants.js +8 -0
  443. package/node/uploadedFileList/index.d.ts +2 -0
  444. package/node/uploadedFileList/index.js +18 -0
  445. package/node/uploadedFileList/uploadedFileList.d.ts +24 -0
  446. package/node/uploadedFileList/uploadedFileList.js +47 -0
  447. package/node/when/index.d.ts +1 -0
  448. package/node/when/index.js +17 -0
  449. package/node/when/when.d.ts +39 -0
  450. package/node/when/when.js +33 -0
  451. package/object/object.js +1 -1
  452. package/object/objectAsync/objectAsync.js +1 -1
  453. package/package.json +9 -6
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CHECKED_SUM = exports.RESTRICTED_VALUES = exports.SNILS_ERROR_INFO = void 0;
4
+ const core_1 = require("../core");
5
+ exports.SNILS_ERROR_INFO = {
6
+ code: (0, core_1.createErrorCode)('snils'),
7
+ message: 'Проверьте СНИЛС',
8
+ };
9
+ exports.RESTRICTED_VALUES = ['00000000000'];
10
+ exports.DEFAULT_CHECKED_SUM = [0, 100, 101];
@@ -0,0 +1,2 @@
1
+ export * from './snils';
2
+ export * from './constants';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./snils"), exports);
18
+ __exportStar(require("./constants"), exports);
@@ -0,0 +1,17 @@
1
+ import { type CommonRuleParams } from '../core';
2
+ type SnilsParams = CommonRuleParams<string> & {
3
+ /**
4
+ * Замена стандартного сообщения ошибки.
5
+ */
6
+ message?: string;
7
+ };
8
+ /**
9
+ * Проверяет валиден ли СНИЛС
10
+ * @example
11
+ * ```ts
12
+ * const validate = string(snils());
13
+ * validate('15657325992');
14
+ * ```
15
+ */
16
+ export declare const snils: <TLastSchemaValues extends Record<string, unknown>>(params?: SnilsParams) => (value: string, prevCtx?: import("../core").ValidationContext<TLastSchemaValues> | undefined) => import("../core").ValidationResult;
17
+ export {};
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.snils = void 0;
4
+ const core_1 = require("../core");
5
+ const constants_1 = require("./constants");
6
+ const removeSpecialCharacters = (value) => {
7
+ return value.replace(/\D/g, '');
8
+ };
9
+ const calcCheckSumForSNILS = (digitsOfValue) => digitsOfValue
10
+ .slice(0, 9)
11
+ .split('')
12
+ .map(Number)
13
+ .reduce((sum, currentValue, index) => sum + currentValue * (9 - index), 0);
14
+ const compareCheckSum = (calculatedCheckSum, checkSum) => {
15
+ return (calculatedCheckSum % constants_1.DEFAULT_CHECKED_SUM[2] === checkSum ||
16
+ (calculatedCheckSum % constants_1.DEFAULT_CHECKED_SUM[2] === constants_1.DEFAULT_CHECKED_SUM[1] &&
17
+ checkSum === constants_1.DEFAULT_CHECKED_SUM[0]));
18
+ };
19
+ /**
20
+ * Проверяет валиден ли СНИЛС
21
+ * @example
22
+ * ```ts
23
+ * const validate = string(snils());
24
+ * validate('15657325992');
25
+ * ```
26
+ */
27
+ const snils = (params) => (0, core_1.createRule)((value, ctx) => {
28
+ const createSnilsError = () => ctx.createError({
29
+ message: (params === null || params === void 0 ? void 0 : params.message) || constants_1.SNILS_ERROR_INFO.message,
30
+ code: constants_1.SNILS_ERROR_INFO.code,
31
+ });
32
+ if ((0, core_1.isStringOfZeros)(value)) {
33
+ return createSnilsError();
34
+ }
35
+ const formattedValue = removeSpecialCharacters(value);
36
+ if (formattedValue.length !== value.length) {
37
+ return createSnilsError();
38
+ }
39
+ if (!/^(\d{11})$/.test(formattedValue)) {
40
+ return createSnilsError();
41
+ }
42
+ if (constants_1.RESTRICTED_VALUES.includes(formattedValue)) {
43
+ return createSnilsError();
44
+ }
45
+ const checkSum = Number(formattedValue.slice(9, 11));
46
+ const calculatedCheckSum = calcCheckSumForSNILS(formattedValue);
47
+ if (calculatedCheckSum < constants_1.DEFAULT_CHECKED_SUM[1]) {
48
+ if (calculatedCheckSum === checkSum) {
49
+ return undefined;
50
+ }
51
+ return createSnilsError();
52
+ }
53
+ if (calculatedCheckSum === constants_1.DEFAULT_CHECKED_SUM[1] ||
54
+ calculatedCheckSum === constants_1.DEFAULT_CHECKED_SUM[2]) {
55
+ if (checkSum === constants_1.DEFAULT_CHECKED_SUM[0]) {
56
+ return undefined;
57
+ }
58
+ return createSnilsError();
59
+ }
60
+ if (calculatedCheckSum > constants_1.DEFAULT_CHECKED_SUM[2]) {
61
+ if (compareCheckSum(calculatedCheckSum, checkSum)) {
62
+ return undefined;
63
+ }
64
+ return createSnilsError();
65
+ }
66
+ return undefined;
67
+ }, { exclude: params === null || params === void 0 ? void 0 : params.exclude });
68
+ exports.snils = snils;
@@ -0,0 +1,2 @@
1
+ import { type ErrorInfo } from '../core';
2
+ export declare const STRING_TYPE_ERROR_INFO: ErrorInfo;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STRING_TYPE_ERROR_INFO = void 0;
4
+ const core_1 = require("../core");
5
+ exports.STRING_TYPE_ERROR_INFO = {
6
+ code: (0, core_1.createErrorCode)('string'),
7
+ message: 'Не является строкой',
8
+ };
@@ -0,0 +1,3 @@
1
+ export * from './string';
2
+ export * from './stringAsync';
3
+ export * from './constants';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./string"), exports);
18
+ __exportStar(require("./stringAsync"), exports);
19
+ __exportStar(require("./constants"), exports);
@@ -0,0 +1,2 @@
1
+ import { type ValidationRule } from '../core';
2
+ export declare const string: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<string, TLastSchemaValues>[]) => import("../core").Guard<TLastSchemaValues, {}>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.string = void 0;
4
+ const core_1 = require("../core");
5
+ const constants_1 = require("./constants");
6
+ const utils_1 = require("./utils");
7
+ const string = (...rules) => (0, core_1.createGuard)((value, ctx, { typeErrorMessage }) => {
8
+ if (!(0, utils_1.isString)(value)) {
9
+ return ctx.createError(Object.assign(Object.assign({}, constants_1.STRING_TYPE_ERROR_INFO), { message: typeErrorMessage || constants_1.STRING_TYPE_ERROR_INFO.message }));
10
+ }
11
+ return (0, core_1.compose)(...rules)(value, ctx);
12
+ });
13
+ exports.string = string;
@@ -0,0 +1 @@
1
+ export * from './stringAsync';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./stringAsync"), exports);
@@ -0,0 +1,6 @@
1
+ import { type AsyncValidationRule, type ValidationRule } from '../../core';
2
+ /**
3
+ * Позволяет использовать для валидации асинхронные правила
4
+ * @example stringAsync(async () => undefined)
5
+ */
6
+ export declare const stringAsync: <TLastSchemaValues extends Record<string, unknown>>(...rules: Array<ValidationRule<string, TLastSchemaValues> | AsyncValidationRule<string, TLastSchemaValues>>) => import("../../core").AsyncGuard<TLastSchemaValues, {}>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.stringAsync = void 0;
13
+ const core_1 = require("../../core");
14
+ const utils_1 = require("../utils");
15
+ const constants_1 = require("../constants");
16
+ // TODO: необходимо реализовать переиспользование логики между string и stringAsync
17
+ /**
18
+ * Позволяет использовать для валидации асинхронные правила
19
+ * @example stringAsync(async () => undefined)
20
+ */
21
+ const stringAsync = (...rules) => (0, core_1.createGuard)((value_1, ctx_1, _a) => __awaiter(void 0, [value_1, ctx_1, _a], void 0, function* (value, ctx, { typeErrorMessage }) {
22
+ if (!(0, utils_1.isString)(value)) {
23
+ return ctx.createError(Object.assign(Object.assign({}, constants_1.STRING_TYPE_ERROR_INFO), { message: typeErrorMessage || constants_1.STRING_TYPE_ERROR_INFO.message }));
24
+ }
25
+ return (0, core_1.composeAsync)(...rules)(value, ctx);
26
+ }));
27
+ exports.stringAsync = stringAsync;
@@ -0,0 +1 @@
1
+ export * from './isString';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./isString"), exports);
@@ -0,0 +1 @@
1
+ export * from './isString';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./isString"), exports);
@@ -0,0 +1 @@
1
+ export declare const isString: (value: unknown) => value is string;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isString = void 0;
4
+ const isString = (value) => typeof value === 'string';
5
+ exports.isString = isString;
@@ -0,0 +1,5 @@
1
+ import { type ErrorInfo } from '../core';
2
+ export declare const TEXT_FIELD_REGEXP: RegExp;
3
+ export declare const TEXT_FIELD_MAX_LENGTH = 256;
4
+ export declare const INVALID_TEXT_FIELD_ERROR_INFO: ErrorInfo;
5
+ export declare const LENGTH_TEXT_FIELD_ERROR_INFO: ErrorInfo;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LENGTH_TEXT_FIELD_ERROR_INFO = exports.INVALID_TEXT_FIELD_ERROR_INFO = exports.TEXT_FIELD_MAX_LENGTH = exports.TEXT_FIELD_REGEXP = void 0;
4
+ const core_1 = require("../core");
5
+ exports.TEXT_FIELD_REGEXP = /^[a-zA-Zа-яА-Я0-9\s!@#$%^&*()-_=+\\|[\]{};:'",.<>/?]+$/;
6
+ exports.TEXT_FIELD_MAX_LENGTH = 256;
7
+ exports.INVALID_TEXT_FIELD_ERROR_INFO = {
8
+ code: (0, core_1.createErrorCode)('textField-invalid'),
9
+ message: 'Содержит запрещённые символы',
10
+ };
11
+ exports.LENGTH_TEXT_FIELD_ERROR_INFO = {
12
+ code: (0, core_1.createErrorCode)('textField-length'),
13
+ message: 'Превышено максимальное кол-во символов',
14
+ };
@@ -0,0 +1,2 @@
1
+ export * from './constants';
2
+ export * from './textField';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./textField"), exports);
@@ -0,0 +1,24 @@
1
+ type TextFieldParams = {
2
+ /**
3
+ * Замена стандартного сообщения ошибки.
4
+ */
5
+ customLength?: number;
6
+ /**
7
+ * Замена стандартного сообщения ошибки.
8
+ */
9
+ message?: string;
10
+ /**
11
+ * Замена стандартного сообщения ошибки при превышении допустимого количества символов.
12
+ */
13
+ invalidLengthMessage?: string;
14
+ };
15
+ /**
16
+ * Проверяет валидность текстового поля
17
+ * @example
18
+ * ```ts
19
+ * const validate = string(textField());
20
+ * validate('Авада кедавра...');
21
+ * ```
22
+ */
23
+ export declare const textField: <TLastSchemaValues extends Record<string, unknown>>(params?: TextFieldParams) => (value: string, prevCtx?: import("../core").ValidationContext<TLastSchemaValues> | undefined) => import("../core").ValidationResult;
24
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.textField = void 0;
4
+ const core_1 = require("../core");
5
+ const constants_1 = require("./constants");
6
+ /**
7
+ * Проверяет валидность текстового поля
8
+ * @example
9
+ * ```ts
10
+ * const validate = string(textField());
11
+ * validate('Авада кедавра...');
12
+ * ```
13
+ */
14
+ const textField = (params) => (0, core_1.createRule)((value, ctx) => {
15
+ if (value.length > ((params === null || params === void 0 ? void 0 : params.customLength) || constants_1.TEXT_FIELD_MAX_LENGTH)) {
16
+ return ctx.createError(Object.assign(Object.assign({}, constants_1.LENGTH_TEXT_FIELD_ERROR_INFO), { message: (params === null || params === void 0 ? void 0 : params.invalidLengthMessage) || constants_1.LENGTH_TEXT_FIELD_ERROR_INFO.message }));
17
+ }
18
+ if (!constants_1.TEXT_FIELD_REGEXP.test(value)) {
19
+ return ctx.createError(Object.assign(Object.assign({}, constants_1.INVALID_TEXT_FIELD_ERROR_INFO), { message: (params === null || params === void 0 ? void 0 : params.message) || constants_1.INVALID_TEXT_FIELD_ERROR_INFO.message }));
20
+ }
21
+ return undefined;
22
+ });
23
+ exports.textField = textField;
@@ -0,0 +1 @@
1
+ export * from './toPlainError';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./toPlainError"), exports);
@@ -0,0 +1,35 @@
1
+ import { type ValidationResult, type ValidationSimpleError } from '../core';
2
+ type PlainArrayResult<TPlainSimpleError> = Array<TPlainSimpleError | TPlainSimpleError[] | PlainErrorMap<TPlainSimpleError> | PlainArrayResult<TPlainSimpleError> | undefined>;
3
+ type PlainErrorMap<TPlainSimpleError> = {
4
+ [key: string]: TPlainSimpleError | PlainArrayResult<TPlainSimpleError> | PlainErrorMap<TPlainSimpleError>;
5
+ };
6
+ type FormatSimpleErrorFunc<TPlainSimpleError> = (error: ValidationSimpleError, params: {
7
+ path: string;
8
+ }) => TPlainSimpleError;
9
+ /**
10
+ * Результат валидации, преобразованный в простые структуры данных (исходные - это инстансы error)
11
+ */
12
+ export type PlainValidationResult<TPlainSimpleError> = undefined | TPlainSimpleError | PlainArrayResult<TPlainSimpleError> | PlainErrorMap<TPlainSimpleError>;
13
+ /**
14
+ * Форматирует все ошибки валидации в простые объекты. Необходим для интеграции с другими библиотеками
15
+ * @param validationResult
16
+ * @param formatErrorInfo - позволяет отформатировать объект ошибки при его формировании
17
+ * @param path - путь до ошибки в схеме
18
+ * @example
19
+ * ```ts
20
+ * const validate = object<{ info: Array<{ name: string }> }>({
21
+ * info: array(
22
+ * arrayItem(
23
+ * object<{ name: string }>(
24
+ * { name: string() }
25
+ * )
26
+ * )
27
+ ),
28
+ * }),
29
+ *
30
+ * // { info: [{ name: { code: Symbol(string), message: 'Не является строкой' } }] }
31
+ * console.log(toPlainError(validate({ info: [{ name: 22 }] })));
32
+ * ```
33
+ */
34
+ export declare const toPlainError: <TPlainSimpleError>(validationResult: ValidationResult, formatErrorInfo: FormatSimpleErrorFunc<TPlainSimpleError>, path?: string) => PlainValidationResult<TPlainSimpleError>;
35
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toPlainError = void 0;
4
+ const core_1 = require("../core");
5
+ const utils_1 = require("./utils");
6
+ const toPlainArrayResult = (error, formatErrorInfo, path) => error.cause.errorArray.map((errorItem, index) =>
7
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
8
+ (0, exports.toPlainError)(errorItem, formatErrorInfo, (0, utils_1.generateArrayPath)(index, path)));
9
+ function toPlainErrorMap(error, formatErrorInfo, path) {
10
+ return Object.entries(error.cause.errorMap).reduce((plainErrorMap, [key, currentError]) => {
11
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
12
+ const plainError = (0, exports.toPlainError)(currentError, formatErrorInfo, (0, utils_1.generateObjectPath)(key, path));
13
+ if (plainError === undefined) {
14
+ return plainErrorMap;
15
+ }
16
+ plainErrorMap[key] = plainError;
17
+ return plainErrorMap;
18
+ }, {});
19
+ }
20
+ /**
21
+ * Форматирует все ошибки валидации в простые объекты. Необходим для интеграции с другими библиотеками
22
+ * @param validationResult
23
+ * @param formatErrorInfo - позволяет отформатировать объект ошибки при его формировании
24
+ * @param path - путь до ошибки в схеме
25
+ * @example
26
+ * ```ts
27
+ * const validate = object<{ info: Array<{ name: string }> }>({
28
+ * info: array(
29
+ * arrayItem(
30
+ * object<{ name: string }>(
31
+ * { name: string() }
32
+ * )
33
+ * )
34
+ ),
35
+ * }),
36
+ *
37
+ * // { info: [{ name: { code: Symbol(string), message: 'Не является строкой' } }] }
38
+ * console.log(toPlainError(validate({ info: [{ name: 22 }] })));
39
+ * ```
40
+ */
41
+ const toPlainError = (validationResult, formatErrorInfo, path = '') => {
42
+ if (!validationResult) {
43
+ return undefined;
44
+ }
45
+ if (validationResult instanceof core_1.ValidationErrorMap) {
46
+ return toPlainErrorMap(validationResult, formatErrorInfo, path);
47
+ }
48
+ if (validationResult instanceof core_1.ValidationArrayError) {
49
+ return toPlainArrayResult(validationResult, formatErrorInfo, path);
50
+ }
51
+ return formatErrorInfo(validationResult, { path });
52
+ };
53
+ exports.toPlainError = toPlainError;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Гененирует path для массива
3
+ */
4
+ export declare const generateArrayPath: (index: number, prevPath?: string) => string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateArrayPath = void 0;
4
+ /**
5
+ * Гененирует path для массива
6
+ */
7
+ const generateArrayPath = (index, prevPath) => {
8
+ if (prevPath) {
9
+ return `${prevPath}.${index}`;
10
+ }
11
+ return String(index);
12
+ };
13
+ exports.generateArrayPath = generateArrayPath;
@@ -0,0 +1 @@
1
+ export * from './generateArrayPath';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./generateArrayPath"), exports);
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Гененирует path для объекта
3
+ */
4
+ export declare const generateObjectPath: (key: string, prevPath?: string) => string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateObjectPath = void 0;
4
+ /**
5
+ * Гененирует path для объекта
6
+ */
7
+ const generateObjectPath = (key, prevPath) => {
8
+ if (prevPath) {
9
+ return `${prevPath}.${key}`;
10
+ }
11
+ return key;
12
+ };
13
+ exports.generateObjectPath = generateObjectPath;
@@ -0,0 +1 @@
1
+ export * from './generateObjectPath';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./generateObjectPath"), exports);
@@ -0,0 +1,2 @@
1
+ export * from './generateObjectPath';
2
+ export * from './generateArrayPath';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./generateObjectPath"), exports);
18
+ __exportStar(require("./generateArrayPath"), exports);
@@ -0,0 +1 @@
1
+ export * from './toPrettyError';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./toPrettyError"), exports);