@warlock.js/seal 4.0.48 → 4.0.60

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 (733) hide show
  1. package/cjs/config.d.ts +48 -0
  2. package/cjs/config.d.ts.map +1 -0
  3. package/cjs/config.js +42 -0
  4. package/cjs/config.js.map +1 -0
  5. package/cjs/factory/index.d.ts +3 -0
  6. package/cjs/factory/index.d.ts.map +1 -0
  7. package/cjs/factory/validate.d.ts +8 -0
  8. package/cjs/factory/validate.d.ts.map +1 -0
  9. package/cjs/factory/validate.js +23 -0
  10. package/cjs/factory/validate.js.map +1 -0
  11. package/cjs/factory/validators.d.ts +41 -0
  12. package/cjs/factory/validators.d.ts.map +1 -0
  13. package/cjs/factory/validators.js +45 -0
  14. package/cjs/factory/validators.js.map +1 -0
  15. package/cjs/helpers/date-helpers.d.ts +16 -0
  16. package/cjs/helpers/date-helpers.d.ts.map +1 -0
  17. package/cjs/helpers/date-helpers.js +20 -0
  18. package/cjs/helpers/date-helpers.js.map +1 -0
  19. package/cjs/helpers/file.utils.d.ts +8 -0
  20. package/cjs/helpers/file.utils.d.ts.map +1 -0
  21. package/cjs/helpers/file.utils.js +29 -0
  22. package/cjs/helpers/file.utils.js.map +1 -0
  23. package/cjs/helpers/get-field-value.d.ts +37 -0
  24. package/cjs/helpers/get-field-value.d.ts.map +1 -0
  25. package/cjs/helpers/get-field-value.js +40 -0
  26. package/cjs/helpers/get-field-value.js.map +1 -0
  27. package/cjs/helpers/index.d.ts +6 -0
  28. package/cjs/helpers/index.d.ts.map +1 -0
  29. package/cjs/helpers/is-empty-value.d.ts +2 -0
  30. package/cjs/helpers/is-empty-value.d.ts.map +1 -0
  31. package/cjs/helpers/is-empty-value.js +3 -0
  32. package/cjs/helpers/is-empty-value.js.map +1 -0
  33. package/cjs/helpers/path-helpers.d.ts +5 -0
  34. package/cjs/helpers/path-helpers.d.ts.map +1 -0
  35. package/cjs/helpers/path-helpers.js +8 -0
  36. package/cjs/helpers/path-helpers.js.map +1 -0
  37. package/cjs/helpers/validation-helpers.d.ts +4 -0
  38. package/cjs/helpers/validation-helpers.d.ts.map +1 -0
  39. package/cjs/helpers/validation-helpers.js +48 -0
  40. package/cjs/helpers/validation-helpers.js.map +1 -0
  41. package/cjs/index.d.ts +29 -0
  42. package/cjs/index.d.ts.map +1 -0
  43. package/cjs/index.js +1 -63
  44. package/cjs/index.js.map +1 -1
  45. package/cjs/mutators/array-mutators.d.ts +12 -0
  46. package/cjs/mutators/array-mutators.d.ts.map +1 -0
  47. package/cjs/mutators/array-mutators.js +37 -0
  48. package/cjs/mutators/array-mutators.js.map +1 -0
  49. package/cjs/mutators/date-mutators.d.ts +39 -0
  50. package/cjs/mutators/date-mutators.d.ts.map +1 -0
  51. package/cjs/mutators/date-mutators.js +120 -0
  52. package/cjs/mutators/date-mutators.js.map +1 -0
  53. package/cjs/mutators/index.d.ts +7 -0
  54. package/cjs/mutators/index.d.ts.map +1 -0
  55. package/cjs/mutators/number-mutators.d.ts +9 -0
  56. package/cjs/mutators/number-mutators.d.ts.map +1 -0
  57. package/cjs/mutators/number-mutators.js +23 -0
  58. package/cjs/mutators/number-mutators.js.map +1 -0
  59. package/cjs/mutators/object-mutators.d.ts +8 -0
  60. package/cjs/mutators/object-mutators.d.ts.map +1 -0
  61. package/cjs/mutators/object-mutators.js +50 -0
  62. package/cjs/mutators/object-mutators.js.map +1 -0
  63. package/cjs/mutators/scalar-mutators.d.ts +3 -0
  64. package/cjs/mutators/scalar-mutators.d.ts.map +1 -0
  65. package/cjs/mutators/scalar-mutators.js +6 -0
  66. package/cjs/mutators/scalar-mutators.js.map +1 -0
  67. package/cjs/mutators/string-mutators.d.ts +72 -0
  68. package/cjs/mutators/string-mutators.d.ts.map +1 -0
  69. package/cjs/mutators/string-mutators.js +193 -0
  70. package/cjs/mutators/string-mutators.js.map +1 -0
  71. package/cjs/plugins/index.d.ts +7 -0
  72. package/cjs/plugins/index.d.ts.map +1 -0
  73. package/cjs/plugins/plugin-system.d.ts +71 -0
  74. package/cjs/plugins/plugin-system.d.ts.map +1 -0
  75. package/cjs/plugins/plugin-system.js +68 -0
  76. package/cjs/plugins/plugin-system.js.map +1 -0
  77. package/cjs/rules/array/array-rules.d.ts +12 -0
  78. package/cjs/rules/array/array-rules.d.ts.map +1 -0
  79. package/cjs/rules/array/array-rules.js +44 -0
  80. package/cjs/rules/array/array-rules.js.map +1 -0
  81. package/cjs/rules/array/index.d.ts +2 -0
  82. package/cjs/rules/array/index.d.ts.map +1 -0
  83. package/cjs/rules/color/color-rules.d.ts +30 -0
  84. package/cjs/rules/color/color-rules.d.ts.map +1 -0
  85. package/cjs/rules/color/color-rules.js +120 -0
  86. package/cjs/rules/color/color-rules.js.map +1 -0
  87. package/cjs/rules/color/index.d.ts +2 -0
  88. package/cjs/rules/color/index.d.ts.map +1 -0
  89. package/cjs/rules/common/enum.d.ts +26 -0
  90. package/cjs/rules/common/enum.d.ts.map +1 -0
  91. package/cjs/rules/common/enum.js +55 -0
  92. package/cjs/rules/common/enum.js.map +1 -0
  93. package/cjs/rules/common/equals-field-rules.d.ts +18 -0
  94. package/cjs/rules/common/equals-field-rules.d.ts.map +1 -0
  95. package/cjs/rules/common/equals-field-rules.js +38 -0
  96. package/cjs/rules/common/equals-field-rules.js.map +1 -0
  97. package/cjs/rules/common/index.d.ts +5 -0
  98. package/cjs/rules/common/index.d.ts.map +1 -0
  99. package/cjs/rules/common/type-rules.d.ts +34 -0
  100. package/cjs/rules/common/type-rules.d.ts.map +1 -0
  101. package/cjs/rules/common/type-rules.js +104 -0
  102. package/cjs/rules/common/type-rules.js.map +1 -0
  103. package/cjs/rules/common/unknown-key.d.ts +9 -0
  104. package/cjs/rules/common/unknown-key.d.ts.map +1 -0
  105. package/cjs/rules/common/unknown-key.js +18 -0
  106. package/cjs/rules/common/unknown-key.js.map +1 -0
  107. package/cjs/rules/conditional/forbidden-if-rules.d.ts +54 -0
  108. package/cjs/rules/conditional/forbidden-if-rules.d.ts.map +1 -0
  109. package/cjs/rules/conditional/forbidden-if-rules.js +112 -0
  110. package/cjs/rules/conditional/forbidden-if-rules.js.map +1 -0
  111. package/cjs/rules/conditional/index.d.ts +10 -0
  112. package/cjs/rules/conditional/index.d.ts.map +1 -0
  113. package/cjs/rules/conditional/present-if-rules.d.ts +45 -0
  114. package/cjs/rules/conditional/present-if-rules.d.ts.map +1 -0
  115. package/cjs/rules/conditional/present-if-rules.js +98 -0
  116. package/cjs/rules/conditional/present-if-rules.js.map +1 -0
  117. package/cjs/rules/conditional/present-unless-rules.d.ts +11 -0
  118. package/cjs/rules/conditional/present-unless-rules.d.ts.map +1 -0
  119. package/cjs/rules/conditional/present-unless-rules.js +20 -0
  120. package/cjs/rules/conditional/present-unless-rules.js.map +1 -0
  121. package/cjs/rules/conditional/present-with-rules.d.ts +26 -0
  122. package/cjs/rules/conditional/present-with-rules.d.ts.map +1 -0
  123. package/cjs/rules/conditional/present-with-rules.js +63 -0
  124. package/cjs/rules/conditional/present-with-rules.js.map +1 -0
  125. package/cjs/rules/conditional/present-without-rules.d.ts +26 -0
  126. package/cjs/rules/conditional/present-without-rules.d.ts.map +1 -0
  127. package/cjs/rules/conditional/present-without-rules.js +63 -0
  128. package/cjs/rules/conditional/present-without-rules.js.map +1 -0
  129. package/cjs/rules/conditional/required-if-rules.d.ts +45 -0
  130. package/cjs/rules/conditional/required-if-rules.d.ts.map +1 -0
  131. package/cjs/rules/conditional/required-if-rules.js +98 -0
  132. package/cjs/rules/conditional/required-if-rules.js.map +1 -0
  133. package/cjs/rules/conditional/required-unless-rules.d.ts +11 -0
  134. package/cjs/rules/conditional/required-unless-rules.d.ts.map +1 -0
  135. package/cjs/rules/conditional/required-unless-rules.js +20 -0
  136. package/cjs/rules/conditional/required-unless-rules.js.map +1 -0
  137. package/cjs/rules/conditional/required-with-rules.d.ts +26 -0
  138. package/cjs/rules/conditional/required-with-rules.d.ts.map +1 -0
  139. package/cjs/rules/conditional/required-with-rules.js +63 -0
  140. package/cjs/rules/conditional/required-with-rules.js.map +1 -0
  141. package/cjs/rules/conditional/required-without-rules.d.ts +26 -0
  142. package/cjs/rules/conditional/required-without-rules.d.ts.map +1 -0
  143. package/cjs/rules/conditional/required-without-rules.js +63 -0
  144. package/cjs/rules/conditional/required-without-rules.js.map +1 -0
  145. package/cjs/rules/core/equal.d.ts +8 -0
  146. package/cjs/rules/core/equal.d.ts.map +1 -0
  147. package/cjs/rules/core/equal.js +13 -0
  148. package/cjs/rules/core/equal.js.map +1 -0
  149. package/cjs/rules/core/forbidden.d.ts +6 -0
  150. package/cjs/rules/core/forbidden.d.ts.map +1 -0
  151. package/cjs/rules/core/forbidden.js +13 -0
  152. package/cjs/rules/core/forbidden.js.map +1 -0
  153. package/cjs/rules/core/index.d.ts +6 -0
  154. package/cjs/rules/core/index.d.ts.map +1 -0
  155. package/cjs/rules/core/required.d.ts +11 -0
  156. package/cjs/rules/core/required.d.ts.map +1 -0
  157. package/cjs/rules/core/required.js +31 -0
  158. package/cjs/rules/core/required.js.map +1 -0
  159. package/cjs/rules/core/union.d.ts +9 -0
  160. package/cjs/rules/core/union.d.ts.map +1 -0
  161. package/cjs/rules/core/union.js +40 -0
  162. package/cjs/rules/core/union.js.map +1 -0
  163. package/cjs/rules/core/when.d.ts +6 -0
  164. package/cjs/rules/core/when.d.ts.map +1 -0
  165. package/cjs/rules/core/when.js +40 -0
  166. package/cjs/rules/core/when.js.map +1 -0
  167. package/cjs/rules/date/date-comparison-rules.d.ts +25 -0
  168. package/cjs/rules/date/date-comparison-rules.d.ts.map +1 -0
  169. package/cjs/rules/date/date-comparison-rules.js +78 -0
  170. package/cjs/rules/date/date-comparison-rules.js.map +1 -0
  171. package/cjs/rules/date/date-day-rules.d.ts +21 -0
  172. package/cjs/rules/date/date-day-rules.d.ts.map +1 -0
  173. package/cjs/rules/date/date-day-rules.js +65 -0
  174. package/cjs/rules/date/date-day-rules.js.map +1 -0
  175. package/cjs/rules/date/date-field-comparison-rules.d.ts +28 -0
  176. package/cjs/rules/date/date-field-comparison-rules.d.ts.map +1 -0
  177. package/cjs/rules/date/date-field-comparison-rules.js +90 -0
  178. package/cjs/rules/date/date-field-comparison-rules.js.map +1 -0
  179. package/cjs/rules/date/date-period-rules.d.ts +108 -0
  180. package/cjs/rules/date/date-period-rules.d.ts.map +1 -0
  181. package/cjs/rules/date/date-period-rules.js +566 -0
  182. package/cjs/rules/date/date-period-rules.js.map +1 -0
  183. package/cjs/rules/date/date-relative-rules.d.ts +20 -0
  184. package/cjs/rules/date/date-relative-rules.d.ts.map +1 -0
  185. package/cjs/rules/date/date-relative-rules.js +57 -0
  186. package/cjs/rules/date/date-relative-rules.js.map +1 -0
  187. package/cjs/rules/date/date-special-rules.d.ts +20 -0
  188. package/cjs/rules/date/date-special-rules.d.ts.map +1 -0
  189. package/cjs/rules/date/date-special-rules.js +72 -0
  190. package/cjs/rules/date/date-special-rules.js.map +1 -0
  191. package/cjs/rules/date/date.d.ts +93 -0
  192. package/cjs/rules/date/date.d.ts.map +1 -0
  193. package/cjs/rules/date/date.js +279 -0
  194. package/cjs/rules/date/date.js.map +1 -0
  195. package/cjs/rules/date/index.d.ts +8 -0
  196. package/cjs/rules/date/index.d.ts.map +1 -0
  197. package/cjs/rules/file/dimensions.d.ts +26 -0
  198. package/cjs/rules/file/dimensions.d.ts.map +1 -0
  199. package/cjs/rules/file/dimensions.js +56 -0
  200. package/cjs/rules/file/dimensions.js.map +1 -0
  201. package/cjs/rules/file/file-size.d.ts +14 -0
  202. package/cjs/rules/file/file-size.d.ts.map +1 -0
  203. package/cjs/rules/file/file-size.js +48 -0
  204. package/cjs/rules/file/file-size.js.map +1 -0
  205. package/cjs/rules/file/index.d.ts +11 -0
  206. package/cjs/rules/file/index.d.ts.map +1 -0
  207. package/cjs/rules/index.d.ts +19 -0
  208. package/cjs/rules/index.d.ts.map +1 -0
  209. package/cjs/rules/length/index.d.ts +2 -0
  210. package/cjs/rules/length/index.d.ts.map +1 -0
  211. package/cjs/rules/length/length-rules.d.ts +49 -0
  212. package/cjs/rules/length/length-rules.d.ts.map +1 -0
  213. package/cjs/rules/length/length-rules.js +116 -0
  214. package/cjs/rules/length/length-rules.js.map +1 -0
  215. package/cjs/rules/number/index.d.ts +2 -0
  216. package/cjs/rules/number/index.d.ts.map +1 -0
  217. package/cjs/rules/number/number-rules.d.ts +65 -0
  218. package/cjs/rules/number/number-rules.d.ts.map +1 -0
  219. package/cjs/rules/number/number-rules.js +234 -0
  220. package/cjs/rules/number/number-rules.js.map +1 -0
  221. package/cjs/rules/scalar/accepted-rule.d.ts +39 -0
  222. package/cjs/rules/scalar/accepted-rule.d.ts.map +1 -0
  223. package/cjs/rules/scalar/accepted-rule.js +110 -0
  224. package/cjs/rules/scalar/accepted-rule.js.map +1 -0
  225. package/cjs/rules/scalar/declined-rule.d.ts +39 -0
  226. package/cjs/rules/scalar/declined-rule.d.ts.map +1 -0
  227. package/cjs/rules/scalar/declined-rule.js +110 -0
  228. package/cjs/rules/scalar/declined-rule.js.map +1 -0
  229. package/cjs/rules/scalar/index.d.ts +3 -0
  230. package/cjs/rules/scalar/index.d.ts.map +1 -0
  231. package/cjs/rules/string/alpha.d.ts +14 -0
  232. package/cjs/rules/string/alpha.d.ts.map +1 -0
  233. package/cjs/rules/string/alpha.js +39 -0
  234. package/cjs/rules/string/alpha.js.map +1 -0
  235. package/cjs/rules/string/credit-card.d.ts +6 -0
  236. package/cjs/rules/string/credit-card.d.ts.map +1 -0
  237. package/cjs/rules/string/credit-card.js +31 -0
  238. package/cjs/rules/string/credit-card.js.map +1 -0
  239. package/cjs/rules/string/email.d.ts +6 -0
  240. package/cjs/rules/string/email.d.ts.map +1 -0
  241. package/cjs/rules/string/email.js +13 -0
  242. package/cjs/rules/string/email.js.map +1 -0
  243. package/cjs/rules/string/index.d.ts +17 -0
  244. package/cjs/rules/string/index.d.ts.map +1 -0
  245. package/cjs/rules/string/ip.d.ts +14 -0
  246. package/cjs/rules/string/ip.d.ts.map +1 -0
  247. package/cjs/rules/string/ip.js +39 -0
  248. package/cjs/rules/string/ip.js.map +1 -0
  249. package/cjs/rules/string/matches.d.ts +8 -0
  250. package/cjs/rules/string/matches.d.ts.map +1 -0
  251. package/cjs/rules/string/matches.js +14 -0
  252. package/cjs/rules/string/matches.js.map +1 -0
  253. package/cjs/rules/string/pattern.d.ts +8 -0
  254. package/cjs/rules/string/pattern.d.ts.map +1 -0
  255. package/cjs/rules/string/pattern.js +13 -0
  256. package/cjs/rules/string/pattern.js.map +1 -0
  257. package/cjs/rules/string/string-comparison.d.ts +26 -0
  258. package/cjs/rules/string/string-comparison.d.ts.map +1 -0
  259. package/cjs/rules/string/string-comparison.js +52 -0
  260. package/cjs/rules/string/string-comparison.js.map +1 -0
  261. package/cjs/rules/string/strong-password-rule.d.ts +14 -0
  262. package/cjs/rules/string/strong-password-rule.d.ts.map +1 -0
  263. package/cjs/rules/string/strong-password-rule.js +38 -0
  264. package/cjs/rules/string/strong-password-rule.js.map +1 -0
  265. package/cjs/rules/string/url.d.ts +6 -0
  266. package/cjs/rules/string/url.d.ts.map +1 -0
  267. package/cjs/rules/string/url.js +16 -0
  268. package/cjs/rules/string/url.js.map +1 -0
  269. package/cjs/rules/string/without-whitespace.d.ts +6 -0
  270. package/cjs/rules/string/without-whitespace.d.ts.map +1 -0
  271. package/cjs/rules/string/without-whitespace.js +13 -0
  272. package/cjs/rules/string/without-whitespace.js.map +1 -0
  273. package/cjs/types/conditional-types.d.ts +15 -0
  274. package/cjs/types/conditional-types.d.ts.map +1 -0
  275. package/cjs/types/context-types.d.ts +48 -0
  276. package/cjs/types/context-types.d.ts.map +1 -0
  277. package/cjs/types/data-transformer-types.d.ts +25 -0
  278. package/cjs/types/data-transformer-types.d.ts.map +1 -0
  279. package/cjs/types/date-types.d.ts +9 -0
  280. package/cjs/types/date-types.d.ts.map +1 -0
  281. package/cjs/types/date-types.js +12 -0
  282. package/cjs/types/date-types.js.map +1 -0
  283. package/cjs/types/file.types.d.ts +5 -0
  284. package/cjs/types/file.types.d.ts.map +1 -0
  285. package/cjs/types/index.d.ts +11 -0
  286. package/cjs/types/index.d.ts.map +1 -0
  287. package/cjs/types/inference-types.d.ts +27 -0
  288. package/cjs/types/inference-types.d.ts.map +1 -0
  289. package/cjs/types/mutator-types.d.ts +27 -0
  290. package/cjs/types/mutator-types.d.ts.map +1 -0
  291. package/cjs/types/result-types.d.ts +19 -0
  292. package/cjs/types/result-types.d.ts.map +1 -0
  293. package/cjs/types/rule-types.d.ts +54 -0
  294. package/cjs/types/rule-types.d.ts.map +1 -0
  295. package/cjs/types/schema-types.d.ts +6 -0
  296. package/cjs/types/schema-types.d.ts.map +1 -0
  297. package/cjs/validators/any-validator.d.ts +7 -0
  298. package/cjs/validators/any-validator.d.ts.map +1 -0
  299. package/cjs/validators/any-validator.js +5 -0
  300. package/cjs/validators/any-validator.js.map +1 -0
  301. package/cjs/validators/array-validator.d.ts +59 -0
  302. package/cjs/validators/array-validator.d.ts.map +1 -0
  303. package/cjs/validators/array-validator.js +134 -0
  304. package/cjs/validators/array-validator.js.map +1 -0
  305. package/cjs/validators/base-validator.d.ts +610 -0
  306. package/cjs/validators/base-validator.d.ts.map +1 -0
  307. package/cjs/validators/base-validator.js +1160 -0
  308. package/cjs/validators/base-validator.js.map +1 -0
  309. package/cjs/validators/boolean-validator.d.ts +47 -0
  310. package/cjs/validators/boolean-validator.d.ts.map +1 -0
  311. package/cjs/validators/boolean-validator.js +54 -0
  312. package/cjs/validators/boolean-validator.js.map +1 -0
  313. package/cjs/validators/computed-validator.d.ts +64 -0
  314. package/cjs/validators/computed-validator.d.ts.map +1 -0
  315. package/cjs/validators/computed-validator.js +109 -0
  316. package/cjs/validators/computed-validator.js.map +1 -0
  317. package/cjs/validators/date-validator.d.ts +307 -0
  318. package/cjs/validators/date-validator.d.ts.map +1 -0
  319. package/cjs/validators/date-validator.js +645 -0
  320. package/cjs/validators/date-validator.js.map +1 -0
  321. package/cjs/validators/float-validator.d.ts +8 -0
  322. package/cjs/validators/float-validator.d.ts.map +1 -0
  323. package/cjs/validators/float-validator.js +9 -0
  324. package/cjs/validators/float-validator.js.map +1 -0
  325. package/cjs/validators/index.d.ts +26 -0
  326. package/cjs/validators/index.d.ts.map +1 -0
  327. package/cjs/validators/int-validator.d.ts +8 -0
  328. package/cjs/validators/int-validator.d.ts.map +1 -0
  329. package/cjs/validators/int-validator.js +9 -0
  330. package/cjs/validators/int-validator.js.map +1 -0
  331. package/cjs/validators/managed-validator.d.ts +38 -0
  332. package/cjs/validators/managed-validator.d.ts.map +1 -0
  333. package/cjs/validators/managed-validator.js +34 -0
  334. package/cjs/validators/managed-validator.js.map +1 -0
  335. package/cjs/validators/number-validator.d.ts +113 -0
  336. package/cjs/validators/number-validator.d.ts.map +1 -0
  337. package/cjs/validators/number-validator.js +192 -0
  338. package/cjs/validators/number-validator.js.map +1 -0
  339. package/cjs/validators/numeric-validator.d.ts +15 -0
  340. package/cjs/validators/numeric-validator.d.ts.map +1 -0
  341. package/cjs/validators/numeric-validator.js +18 -0
  342. package/cjs/validators/numeric-validator.js.map +1 -0
  343. package/cjs/validators/object-validator.d.ts +187 -0
  344. package/cjs/validators/object-validator.d.ts.map +1 -0
  345. package/cjs/validators/object-validator.js +416 -0
  346. package/cjs/validators/object-validator.js.map +1 -0
  347. package/cjs/validators/record-validator.d.ts +33 -0
  348. package/cjs/validators/record-validator.d.ts.map +1 -0
  349. package/cjs/validators/record-validator.js +70 -0
  350. package/cjs/validators/record-validator.js.map +1 -0
  351. package/cjs/validators/scalar-validator.d.ts +82 -0
  352. package/cjs/validators/scalar-validator.d.ts.map +1 -0
  353. package/cjs/validators/scalar-validator.js +160 -0
  354. package/cjs/validators/scalar-validator.js.map +1 -0
  355. package/cjs/validators/string-validator.d.ts +191 -0
  356. package/cjs/validators/string-validator.d.ts.map +1 -0
  357. package/cjs/validators/string-validator.js +410 -0
  358. package/cjs/validators/string-validator.js.map +1 -0
  359. package/cjs/validators/tuple-validator.d.ts +34 -0
  360. package/cjs/validators/tuple-validator.d.ts.map +1 -0
  361. package/cjs/validators/tuple-validator.js +79 -0
  362. package/cjs/validators/tuple-validator.js.map +1 -0
  363. package/cjs/validators/union-validator.d.ts +42 -0
  364. package/cjs/validators/union-validator.d.ts.map +1 -0
  365. package/cjs/validators/union-validator.js +44 -0
  366. package/cjs/validators/union-validator.js.map +1 -0
  367. package/esm/config.d.ts +48 -0
  368. package/esm/config.d.ts.map +1 -0
  369. package/esm/config.js +42 -0
  370. package/esm/config.js.map +1 -0
  371. package/esm/factory/index.d.ts +3 -0
  372. package/esm/factory/index.d.ts.map +1 -0
  373. package/esm/factory/validate.d.ts +8 -0
  374. package/esm/factory/validate.d.ts.map +1 -0
  375. package/esm/factory/validate.js +23 -0
  376. package/esm/factory/validate.js.map +1 -0
  377. package/esm/factory/validators.d.ts +41 -0
  378. package/esm/factory/validators.d.ts.map +1 -0
  379. package/esm/factory/validators.js +45 -0
  380. package/esm/factory/validators.js.map +1 -0
  381. package/esm/helpers/date-helpers.d.ts +16 -0
  382. package/esm/helpers/date-helpers.d.ts.map +1 -0
  383. package/esm/helpers/date-helpers.js +20 -0
  384. package/esm/helpers/date-helpers.js.map +1 -0
  385. package/esm/helpers/file.utils.d.ts +8 -0
  386. package/esm/helpers/file.utils.d.ts.map +1 -0
  387. package/esm/helpers/file.utils.js +29 -0
  388. package/esm/helpers/file.utils.js.map +1 -0
  389. package/esm/helpers/get-field-value.d.ts +37 -0
  390. package/esm/helpers/get-field-value.d.ts.map +1 -0
  391. package/esm/helpers/get-field-value.js +40 -0
  392. package/esm/helpers/get-field-value.js.map +1 -0
  393. package/esm/helpers/index.d.ts +6 -0
  394. package/esm/helpers/index.d.ts.map +1 -0
  395. package/esm/helpers/is-empty-value.d.ts +2 -0
  396. package/esm/helpers/is-empty-value.d.ts.map +1 -0
  397. package/esm/helpers/is-empty-value.js +3 -0
  398. package/esm/helpers/is-empty-value.js.map +1 -0
  399. package/esm/helpers/path-helpers.d.ts +5 -0
  400. package/esm/helpers/path-helpers.d.ts.map +1 -0
  401. package/esm/helpers/path-helpers.js +8 -0
  402. package/esm/helpers/path-helpers.js.map +1 -0
  403. package/esm/helpers/validation-helpers.d.ts +4 -0
  404. package/esm/helpers/validation-helpers.d.ts.map +1 -0
  405. package/esm/helpers/validation-helpers.js +48 -0
  406. package/esm/helpers/validation-helpers.js.map +1 -0
  407. package/esm/index.d.ts +29 -0
  408. package/esm/index.d.ts.map +1 -0
  409. package/esm/index.js +1 -10
  410. package/esm/index.js.map +1 -1
  411. package/esm/mutators/array-mutators.d.ts +12 -0
  412. package/esm/mutators/array-mutators.d.ts.map +1 -0
  413. package/esm/mutators/array-mutators.js +37 -0
  414. package/esm/mutators/array-mutators.js.map +1 -0
  415. package/esm/mutators/date-mutators.d.ts +39 -0
  416. package/esm/mutators/date-mutators.d.ts.map +1 -0
  417. package/esm/mutators/date-mutators.js +120 -0
  418. package/esm/mutators/date-mutators.js.map +1 -0
  419. package/esm/mutators/index.d.ts +7 -0
  420. package/esm/mutators/index.d.ts.map +1 -0
  421. package/esm/mutators/number-mutators.d.ts +9 -0
  422. package/esm/mutators/number-mutators.d.ts.map +1 -0
  423. package/esm/mutators/number-mutators.js +23 -0
  424. package/esm/mutators/number-mutators.js.map +1 -0
  425. package/esm/mutators/object-mutators.d.ts +8 -0
  426. package/esm/mutators/object-mutators.d.ts.map +1 -0
  427. package/esm/mutators/object-mutators.js +50 -0
  428. package/esm/mutators/object-mutators.js.map +1 -0
  429. package/esm/mutators/scalar-mutators.d.ts +3 -0
  430. package/esm/mutators/scalar-mutators.d.ts.map +1 -0
  431. package/esm/mutators/scalar-mutators.js +6 -0
  432. package/esm/mutators/scalar-mutators.js.map +1 -0
  433. package/esm/mutators/string-mutators.d.ts +72 -0
  434. package/esm/mutators/string-mutators.d.ts.map +1 -0
  435. package/esm/mutators/string-mutators.js +193 -0
  436. package/esm/mutators/string-mutators.js.map +1 -0
  437. package/esm/plugins/index.d.ts +7 -0
  438. package/esm/plugins/index.d.ts.map +1 -0
  439. package/esm/plugins/plugin-system.d.ts +71 -0
  440. package/esm/plugins/plugin-system.d.ts.map +1 -0
  441. package/esm/plugins/plugin-system.js +68 -0
  442. package/esm/plugins/plugin-system.js.map +1 -0
  443. package/esm/rules/array/array-rules.d.ts +12 -0
  444. package/esm/rules/array/array-rules.d.ts.map +1 -0
  445. package/esm/rules/array/array-rules.js +44 -0
  446. package/esm/rules/array/array-rules.js.map +1 -0
  447. package/esm/rules/array/index.d.ts +2 -0
  448. package/esm/rules/array/index.d.ts.map +1 -0
  449. package/esm/rules/color/color-rules.d.ts +30 -0
  450. package/esm/rules/color/color-rules.d.ts.map +1 -0
  451. package/esm/rules/color/color-rules.js +120 -0
  452. package/esm/rules/color/color-rules.js.map +1 -0
  453. package/esm/rules/color/index.d.ts +2 -0
  454. package/esm/rules/color/index.d.ts.map +1 -0
  455. package/esm/rules/common/enum.d.ts +26 -0
  456. package/esm/rules/common/enum.d.ts.map +1 -0
  457. package/esm/rules/common/enum.js +55 -0
  458. package/esm/rules/common/enum.js.map +1 -0
  459. package/esm/rules/common/equals-field-rules.d.ts +18 -0
  460. package/esm/rules/common/equals-field-rules.d.ts.map +1 -0
  461. package/esm/rules/common/equals-field-rules.js +38 -0
  462. package/esm/rules/common/equals-field-rules.js.map +1 -0
  463. package/esm/rules/common/index.d.ts +5 -0
  464. package/esm/rules/common/index.d.ts.map +1 -0
  465. package/esm/rules/common/type-rules.d.ts +34 -0
  466. package/esm/rules/common/type-rules.d.ts.map +1 -0
  467. package/esm/rules/common/type-rules.js +104 -0
  468. package/esm/rules/common/type-rules.js.map +1 -0
  469. package/esm/rules/common/unknown-key.d.ts +9 -0
  470. package/esm/rules/common/unknown-key.d.ts.map +1 -0
  471. package/esm/rules/common/unknown-key.js +18 -0
  472. package/esm/rules/common/unknown-key.js.map +1 -0
  473. package/esm/rules/conditional/forbidden-if-rules.d.ts +54 -0
  474. package/esm/rules/conditional/forbidden-if-rules.d.ts.map +1 -0
  475. package/esm/rules/conditional/forbidden-if-rules.js +112 -0
  476. package/esm/rules/conditional/forbidden-if-rules.js.map +1 -0
  477. package/esm/rules/conditional/index.d.ts +10 -0
  478. package/esm/rules/conditional/index.d.ts.map +1 -0
  479. package/esm/rules/conditional/present-if-rules.d.ts +45 -0
  480. package/esm/rules/conditional/present-if-rules.d.ts.map +1 -0
  481. package/esm/rules/conditional/present-if-rules.js +98 -0
  482. package/esm/rules/conditional/present-if-rules.js.map +1 -0
  483. package/esm/rules/conditional/present-unless-rules.d.ts +11 -0
  484. package/esm/rules/conditional/present-unless-rules.d.ts.map +1 -0
  485. package/esm/rules/conditional/present-unless-rules.js +20 -0
  486. package/esm/rules/conditional/present-unless-rules.js.map +1 -0
  487. package/esm/rules/conditional/present-with-rules.d.ts +26 -0
  488. package/esm/rules/conditional/present-with-rules.d.ts.map +1 -0
  489. package/esm/rules/conditional/present-with-rules.js +63 -0
  490. package/esm/rules/conditional/present-with-rules.js.map +1 -0
  491. package/esm/rules/conditional/present-without-rules.d.ts +26 -0
  492. package/esm/rules/conditional/present-without-rules.d.ts.map +1 -0
  493. package/esm/rules/conditional/present-without-rules.js +63 -0
  494. package/esm/rules/conditional/present-without-rules.js.map +1 -0
  495. package/esm/rules/conditional/required-if-rules.d.ts +45 -0
  496. package/esm/rules/conditional/required-if-rules.d.ts.map +1 -0
  497. package/esm/rules/conditional/required-if-rules.js +98 -0
  498. package/esm/rules/conditional/required-if-rules.js.map +1 -0
  499. package/esm/rules/conditional/required-unless-rules.d.ts +11 -0
  500. package/esm/rules/conditional/required-unless-rules.d.ts.map +1 -0
  501. package/esm/rules/conditional/required-unless-rules.js +20 -0
  502. package/esm/rules/conditional/required-unless-rules.js.map +1 -0
  503. package/esm/rules/conditional/required-with-rules.d.ts +26 -0
  504. package/esm/rules/conditional/required-with-rules.d.ts.map +1 -0
  505. package/esm/rules/conditional/required-with-rules.js +63 -0
  506. package/esm/rules/conditional/required-with-rules.js.map +1 -0
  507. package/esm/rules/conditional/required-without-rules.d.ts +26 -0
  508. package/esm/rules/conditional/required-without-rules.d.ts.map +1 -0
  509. package/esm/rules/conditional/required-without-rules.js +63 -0
  510. package/esm/rules/conditional/required-without-rules.js.map +1 -0
  511. package/esm/rules/core/equal.d.ts +8 -0
  512. package/esm/rules/core/equal.d.ts.map +1 -0
  513. package/esm/rules/core/equal.js +13 -0
  514. package/esm/rules/core/equal.js.map +1 -0
  515. package/esm/rules/core/forbidden.d.ts +6 -0
  516. package/esm/rules/core/forbidden.d.ts.map +1 -0
  517. package/esm/rules/core/forbidden.js +13 -0
  518. package/esm/rules/core/forbidden.js.map +1 -0
  519. package/esm/rules/core/index.d.ts +6 -0
  520. package/esm/rules/core/index.d.ts.map +1 -0
  521. package/esm/rules/core/required.d.ts +11 -0
  522. package/esm/rules/core/required.d.ts.map +1 -0
  523. package/esm/rules/core/required.js +31 -0
  524. package/esm/rules/core/required.js.map +1 -0
  525. package/esm/rules/core/union.d.ts +9 -0
  526. package/esm/rules/core/union.d.ts.map +1 -0
  527. package/esm/rules/core/union.js +40 -0
  528. package/esm/rules/core/union.js.map +1 -0
  529. package/esm/rules/core/when.d.ts +6 -0
  530. package/esm/rules/core/when.d.ts.map +1 -0
  531. package/esm/rules/core/when.js +40 -0
  532. package/esm/rules/core/when.js.map +1 -0
  533. package/esm/rules/date/date-comparison-rules.d.ts +25 -0
  534. package/esm/rules/date/date-comparison-rules.d.ts.map +1 -0
  535. package/esm/rules/date/date-comparison-rules.js +78 -0
  536. package/esm/rules/date/date-comparison-rules.js.map +1 -0
  537. package/esm/rules/date/date-day-rules.d.ts +21 -0
  538. package/esm/rules/date/date-day-rules.d.ts.map +1 -0
  539. package/esm/rules/date/date-day-rules.js +65 -0
  540. package/esm/rules/date/date-day-rules.js.map +1 -0
  541. package/esm/rules/date/date-field-comparison-rules.d.ts +28 -0
  542. package/esm/rules/date/date-field-comparison-rules.d.ts.map +1 -0
  543. package/esm/rules/date/date-field-comparison-rules.js +90 -0
  544. package/esm/rules/date/date-field-comparison-rules.js.map +1 -0
  545. package/esm/rules/date/date-period-rules.d.ts +108 -0
  546. package/esm/rules/date/date-period-rules.d.ts.map +1 -0
  547. package/esm/rules/date/date-period-rules.js +566 -0
  548. package/esm/rules/date/date-period-rules.js.map +1 -0
  549. package/esm/rules/date/date-relative-rules.d.ts +20 -0
  550. package/esm/rules/date/date-relative-rules.d.ts.map +1 -0
  551. package/esm/rules/date/date-relative-rules.js +57 -0
  552. package/esm/rules/date/date-relative-rules.js.map +1 -0
  553. package/esm/rules/date/date-special-rules.d.ts +20 -0
  554. package/esm/rules/date/date-special-rules.d.ts.map +1 -0
  555. package/esm/rules/date/date-special-rules.js +72 -0
  556. package/esm/rules/date/date-special-rules.js.map +1 -0
  557. package/esm/rules/date/date.d.ts +93 -0
  558. package/esm/rules/date/date.d.ts.map +1 -0
  559. package/esm/rules/date/date.js +279 -0
  560. package/esm/rules/date/date.js.map +1 -0
  561. package/esm/rules/date/index.d.ts +8 -0
  562. package/esm/rules/date/index.d.ts.map +1 -0
  563. package/esm/rules/file/dimensions.d.ts +26 -0
  564. package/esm/rules/file/dimensions.d.ts.map +1 -0
  565. package/esm/rules/file/dimensions.js +56 -0
  566. package/esm/rules/file/dimensions.js.map +1 -0
  567. package/esm/rules/file/file-size.d.ts +14 -0
  568. package/esm/rules/file/file-size.d.ts.map +1 -0
  569. package/esm/rules/file/file-size.js +48 -0
  570. package/esm/rules/file/file-size.js.map +1 -0
  571. package/esm/rules/file/index.d.ts +11 -0
  572. package/esm/rules/file/index.d.ts.map +1 -0
  573. package/esm/rules/index.d.ts +19 -0
  574. package/esm/rules/index.d.ts.map +1 -0
  575. package/esm/rules/length/index.d.ts +2 -0
  576. package/esm/rules/length/index.d.ts.map +1 -0
  577. package/esm/rules/length/length-rules.d.ts +49 -0
  578. package/esm/rules/length/length-rules.d.ts.map +1 -0
  579. package/esm/rules/length/length-rules.js +116 -0
  580. package/esm/rules/length/length-rules.js.map +1 -0
  581. package/esm/rules/number/index.d.ts +2 -0
  582. package/esm/rules/number/index.d.ts.map +1 -0
  583. package/esm/rules/number/number-rules.d.ts +65 -0
  584. package/esm/rules/number/number-rules.d.ts.map +1 -0
  585. package/esm/rules/number/number-rules.js +234 -0
  586. package/esm/rules/number/number-rules.js.map +1 -0
  587. package/esm/rules/scalar/accepted-rule.d.ts +39 -0
  588. package/esm/rules/scalar/accepted-rule.d.ts.map +1 -0
  589. package/esm/rules/scalar/accepted-rule.js +110 -0
  590. package/esm/rules/scalar/accepted-rule.js.map +1 -0
  591. package/esm/rules/scalar/declined-rule.d.ts +39 -0
  592. package/esm/rules/scalar/declined-rule.d.ts.map +1 -0
  593. package/esm/rules/scalar/declined-rule.js +110 -0
  594. package/esm/rules/scalar/declined-rule.js.map +1 -0
  595. package/esm/rules/scalar/index.d.ts +3 -0
  596. package/esm/rules/scalar/index.d.ts.map +1 -0
  597. package/esm/rules/string/alpha.d.ts +14 -0
  598. package/esm/rules/string/alpha.d.ts.map +1 -0
  599. package/esm/rules/string/alpha.js +39 -0
  600. package/esm/rules/string/alpha.js.map +1 -0
  601. package/esm/rules/string/credit-card.d.ts +6 -0
  602. package/esm/rules/string/credit-card.d.ts.map +1 -0
  603. package/esm/rules/string/credit-card.js +31 -0
  604. package/esm/rules/string/credit-card.js.map +1 -0
  605. package/esm/rules/string/email.d.ts +6 -0
  606. package/esm/rules/string/email.d.ts.map +1 -0
  607. package/esm/rules/string/email.js +13 -0
  608. package/esm/rules/string/email.js.map +1 -0
  609. package/esm/rules/string/index.d.ts +17 -0
  610. package/esm/rules/string/index.d.ts.map +1 -0
  611. package/esm/rules/string/ip.d.ts +14 -0
  612. package/esm/rules/string/ip.d.ts.map +1 -0
  613. package/esm/rules/string/ip.js +39 -0
  614. package/esm/rules/string/ip.js.map +1 -0
  615. package/esm/rules/string/matches.d.ts +8 -0
  616. package/esm/rules/string/matches.d.ts.map +1 -0
  617. package/esm/rules/string/matches.js +14 -0
  618. package/esm/rules/string/matches.js.map +1 -0
  619. package/esm/rules/string/pattern.d.ts +8 -0
  620. package/esm/rules/string/pattern.d.ts.map +1 -0
  621. package/esm/rules/string/pattern.js +13 -0
  622. package/esm/rules/string/pattern.js.map +1 -0
  623. package/esm/rules/string/string-comparison.d.ts +26 -0
  624. package/esm/rules/string/string-comparison.d.ts.map +1 -0
  625. package/esm/rules/string/string-comparison.js +52 -0
  626. package/esm/rules/string/string-comparison.js.map +1 -0
  627. package/esm/rules/string/strong-password-rule.d.ts +14 -0
  628. package/esm/rules/string/strong-password-rule.d.ts.map +1 -0
  629. package/esm/rules/string/strong-password-rule.js +38 -0
  630. package/esm/rules/string/strong-password-rule.js.map +1 -0
  631. package/esm/rules/string/url.d.ts +6 -0
  632. package/esm/rules/string/url.d.ts.map +1 -0
  633. package/esm/rules/string/url.js +16 -0
  634. package/esm/rules/string/url.js.map +1 -0
  635. package/esm/rules/string/without-whitespace.d.ts +6 -0
  636. package/esm/rules/string/without-whitespace.d.ts.map +1 -0
  637. package/esm/rules/string/without-whitespace.js +13 -0
  638. package/esm/rules/string/without-whitespace.js.map +1 -0
  639. package/esm/types/conditional-types.d.ts +15 -0
  640. package/esm/types/conditional-types.d.ts.map +1 -0
  641. package/esm/types/context-types.d.ts +48 -0
  642. package/esm/types/context-types.d.ts.map +1 -0
  643. package/esm/types/data-transformer-types.d.ts +25 -0
  644. package/esm/types/data-transformer-types.d.ts.map +1 -0
  645. package/esm/types/date-types.d.ts +9 -0
  646. package/esm/types/date-types.d.ts.map +1 -0
  647. package/esm/types/date-types.js +12 -0
  648. package/esm/types/date-types.js.map +1 -0
  649. package/esm/types/file.types.d.ts +5 -0
  650. package/esm/types/file.types.d.ts.map +1 -0
  651. package/esm/types/index.d.ts +11 -0
  652. package/esm/types/index.d.ts.map +1 -0
  653. package/esm/types/inference-types.d.ts +27 -0
  654. package/esm/types/inference-types.d.ts.map +1 -0
  655. package/esm/types/mutator-types.d.ts +27 -0
  656. package/esm/types/mutator-types.d.ts.map +1 -0
  657. package/esm/types/result-types.d.ts +19 -0
  658. package/esm/types/result-types.d.ts.map +1 -0
  659. package/esm/types/rule-types.d.ts +54 -0
  660. package/esm/types/rule-types.d.ts.map +1 -0
  661. package/esm/types/schema-types.d.ts +6 -0
  662. package/esm/types/schema-types.d.ts.map +1 -0
  663. package/esm/validators/any-validator.d.ts +7 -0
  664. package/esm/validators/any-validator.d.ts.map +1 -0
  665. package/esm/validators/any-validator.js +5 -0
  666. package/esm/validators/any-validator.js.map +1 -0
  667. package/esm/validators/array-validator.d.ts +59 -0
  668. package/esm/validators/array-validator.d.ts.map +1 -0
  669. package/esm/validators/array-validator.js +134 -0
  670. package/esm/validators/array-validator.js.map +1 -0
  671. package/esm/validators/base-validator.d.ts +610 -0
  672. package/esm/validators/base-validator.d.ts.map +1 -0
  673. package/esm/validators/base-validator.js +1160 -0
  674. package/esm/validators/base-validator.js.map +1 -0
  675. package/esm/validators/boolean-validator.d.ts +47 -0
  676. package/esm/validators/boolean-validator.d.ts.map +1 -0
  677. package/esm/validators/boolean-validator.js +54 -0
  678. package/esm/validators/boolean-validator.js.map +1 -0
  679. package/esm/validators/computed-validator.d.ts +64 -0
  680. package/esm/validators/computed-validator.d.ts.map +1 -0
  681. package/esm/validators/computed-validator.js +109 -0
  682. package/esm/validators/computed-validator.js.map +1 -0
  683. package/esm/validators/date-validator.d.ts +307 -0
  684. package/esm/validators/date-validator.d.ts.map +1 -0
  685. package/esm/validators/date-validator.js +645 -0
  686. package/esm/validators/date-validator.js.map +1 -0
  687. package/esm/validators/float-validator.d.ts +8 -0
  688. package/esm/validators/float-validator.d.ts.map +1 -0
  689. package/esm/validators/float-validator.js +9 -0
  690. package/esm/validators/float-validator.js.map +1 -0
  691. package/esm/validators/index.d.ts +26 -0
  692. package/esm/validators/index.d.ts.map +1 -0
  693. package/esm/validators/int-validator.d.ts +8 -0
  694. package/esm/validators/int-validator.d.ts.map +1 -0
  695. package/esm/validators/int-validator.js +9 -0
  696. package/esm/validators/int-validator.js.map +1 -0
  697. package/esm/validators/managed-validator.d.ts +38 -0
  698. package/esm/validators/managed-validator.d.ts.map +1 -0
  699. package/esm/validators/managed-validator.js +34 -0
  700. package/esm/validators/managed-validator.js.map +1 -0
  701. package/esm/validators/number-validator.d.ts +113 -0
  702. package/esm/validators/number-validator.d.ts.map +1 -0
  703. package/esm/validators/number-validator.js +192 -0
  704. package/esm/validators/number-validator.js.map +1 -0
  705. package/esm/validators/numeric-validator.d.ts +15 -0
  706. package/esm/validators/numeric-validator.d.ts.map +1 -0
  707. package/esm/validators/numeric-validator.js +18 -0
  708. package/esm/validators/numeric-validator.js.map +1 -0
  709. package/esm/validators/object-validator.d.ts +187 -0
  710. package/esm/validators/object-validator.d.ts.map +1 -0
  711. package/esm/validators/object-validator.js +416 -0
  712. package/esm/validators/object-validator.js.map +1 -0
  713. package/esm/validators/record-validator.d.ts +33 -0
  714. package/esm/validators/record-validator.d.ts.map +1 -0
  715. package/esm/validators/record-validator.js +70 -0
  716. package/esm/validators/record-validator.js.map +1 -0
  717. package/esm/validators/scalar-validator.d.ts +82 -0
  718. package/esm/validators/scalar-validator.d.ts.map +1 -0
  719. package/esm/validators/scalar-validator.js +160 -0
  720. package/esm/validators/scalar-validator.js.map +1 -0
  721. package/esm/validators/string-validator.d.ts +191 -0
  722. package/esm/validators/string-validator.d.ts.map +1 -0
  723. package/esm/validators/string-validator.js +410 -0
  724. package/esm/validators/string-validator.js.map +1 -0
  725. package/esm/validators/tuple-validator.d.ts +34 -0
  726. package/esm/validators/tuple-validator.d.ts.map +1 -0
  727. package/esm/validators/tuple-validator.js +79 -0
  728. package/esm/validators/tuple-validator.js.map +1 -0
  729. package/esm/validators/union-validator.d.ts +42 -0
  730. package/esm/validators/union-validator.d.ts.map +1 -0
  731. package/esm/validators/union-validator.js +44 -0
  732. package/esm/validators/union-validator.js.map +1 -0
  733. package/package.json +47 -36
@@ -0,0 +1,1160 @@
1
+ import {clone}from'@mongez/reinforcements';import {invalidRule,VALID_RULE}from'../helpers/validation-helpers.js';import {isEmptyValue}from'../helpers/is-empty-value.js';import {equalRule}from'../rules/core/equal.js';import {forbiddenRule}from'../rules/core/forbidden.js';import {requiredRule,presentRule}from'../rules/core/required.js';import {whenRule}from'../rules/core/when.js';import'@mongez/supportive-is';import'net';import {requiredIfRule,requiredIfEmptyRule,requiredIfNotEmptyRule,requiredIfInRule,requiredIfNotInRule}from'../rules/conditional/required-if-rules.js';import {requiredUnlessRule}from'../rules/conditional/required-unless-rules.js';import {requiredWithRule,requiredWithAllRule,requiredWithAnyRule}from'../rules/conditional/required-with-rules.js';import {requiredWithoutRule,requiredWithoutAllRule,requiredWithoutAnyRule}from'../rules/conditional/required-without-rules.js';import {presentIfRule,presentIfEmptyRule,presentIfNotEmptyRule,presentIfInRule,presentIfNotInRule}from'../rules/conditional/present-if-rules.js';import {presentUnlessRule}from'../rules/conditional/present-unless-rules.js';import {presentWithRule,presentWithAllRule,presentWithAnyRule}from'../rules/conditional/present-with-rules.js';import {presentWithoutRule,presentWithoutAllRule,presentWithoutAnyRule}from'../rules/conditional/present-without-rules.js';import {forbiddenIfRule,forbiddenIfNotRule,forbiddenIfEmptyRule,forbiddenIfNotEmptyRule,forbiddenIfInRule,forbiddenIfNotInRule}from'../rules/conditional/forbidden-if-rules.js';import {equalsFieldRule,notEqualsFieldRule}from'../rules/common/equals-field-rules.js';/**
2
+ * Base validator class - foundation for all validators
3
+ */
4
+ class BaseValidator {
5
+ rules = [];
6
+ mutators = [];
7
+ defaultValue;
8
+ description;
9
+ shouldOmit = false;
10
+ isNullable = false;
11
+ /**
12
+ * Pipeline to transform the mutated/original data before returning it
13
+ */
14
+ dataTransformers = [];
15
+ /**
16
+ * Attributes text to be replaced on translations
17
+ * If the value is an object, it will be used as the attributes list for the rule
18
+ * If the value is a string, it will be used as the attributes list for the rule
19
+ */
20
+ attributesText = {};
21
+ /**
22
+ * Attributed that will be always using the attribute translator
23
+ */
24
+ translatedAttributes = {};
25
+ /**
26
+ * Get the default value
27
+ * Supports lazy evaluation via callbacks
28
+ */
29
+ getDefaultValue() {
30
+ return typeof this.defaultValue === "function" ? this.defaultValue() : this.defaultValue;
31
+ }
32
+ /**
33
+ * Determine if value accepts null value
34
+ */
35
+ nullable() {
36
+ this.isNullable = true;
37
+ return this;
38
+ }
39
+ /**
40
+ * Explicitly disallow null values after calling nullable
41
+ */
42
+ notNullable() {
43
+ this.isNullable = false;
44
+ return this;
45
+ }
46
+ /**
47
+ * Add transformer with optional options
48
+ *
49
+ * @param transform - The transformer callback function
50
+ * @param options - Optional options to pass to the transformer
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * // Without options
55
+ * v.date().addTransformer(data => data.toISOString())
56
+ *
57
+ * // With options
58
+ * v.date().addTransformer(
59
+ * (data, { options }) => dayjs(data).format(options.format),
60
+ * { format: 'YYYY-MM-DD' }
61
+ * )
62
+ * ```
63
+ */
64
+ addTransformer(transform, options = {}) {
65
+ this.dataTransformers.push({
66
+ transform,
67
+ options,
68
+ });
69
+ return this;
70
+ }
71
+ /**
72
+ * Transform the output value - simple one-time transformation
73
+ *
74
+ * @param callback - Simple callback receiving data and context
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * // Simple transformation
79
+ * v.string().outputAs(data => data.toUpperCase())
80
+ *
81
+ * // With context
82
+ * v.string().outputAs((data, context) => {
83
+ * console.log(`Transforming ${context.path}`);
84
+ * return data.toLowerCase();
85
+ * })
86
+ * ```
87
+ */
88
+ outputAs(callback) {
89
+ this.addTransformer((data, { context }) => callback(data, context));
90
+ return this;
91
+ }
92
+ /**
93
+ * Transform output to JSON string
94
+ *
95
+ * Works with any validator type (string, number, date, object, array, etc.)
96
+ *
97
+ * @param indent - Optional indentation for pretty printing (default: 0 for compact)
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * // Compact JSON
102
+ * v.object({ name: v.string() }).toJSON()
103
+ * // Output: '{"name":"John"}'
104
+ *
105
+ * // Pretty-printed JSON
106
+ * v.array(v.object({...})).toJSON(2)
107
+ * // Output:
108
+ * // [
109
+ * // {
110
+ * // "name": "John"
111
+ * // }
112
+ * // ]
113
+ *
114
+ * // Works with any type
115
+ * v.string().toJSON() // '"hello"'
116
+ * v.number().toJSON() // '42'
117
+ * v.date().toJSON() // '"2024-10-26T00:00:00.000Z"'
118
+ * ```
119
+ *
120
+ * @category Transformer
121
+ */
122
+ toJSON(indent) {
123
+ this.addTransformer((data, { options }) => JSON.stringify(data, null, options.indent), {
124
+ indent: indent ?? 0,
125
+ });
126
+ return this;
127
+ }
128
+ /**
129
+ * Start data transformation pipeline
130
+ * Context is passed at runtime, not stored
131
+ */
132
+ async startTransformationPipeline(data, context) {
133
+ for (const transformer of this.dataTransformers) {
134
+ data = await transformer.transform(data, {
135
+ options: transformer.options,
136
+ context,
137
+ });
138
+ }
139
+ return data;
140
+ }
141
+ /**
142
+ * Set attributes text to be replaced on translations
143
+ * If the value is an object, it will be used as the attributes list for the rule
144
+ * If the value is a string, it will be used as the attributes list for the rule
145
+ *
146
+ * @example
147
+ * v.string().attributes({
148
+ * name: "Name",
149
+ * email: "Email",
150
+ * });
151
+ * // Example 2: Add custom attributes for matches
152
+ * v.string().matches("confirmPassword").attributes({
153
+ * matches: {
154
+ * confirmPassword: "Confirm Password",
155
+ * },
156
+ * });
157
+ */
158
+ attributes(attributes) {
159
+ for (const key in attributes) {
160
+ this.attributesText[key] = attributes[key];
161
+ }
162
+ return this;
163
+ }
164
+ /**
165
+ * Define a lazy getter property for each attribute in the given object and use the config attribute translator
166
+ */
167
+ transAttributes(attributes) {
168
+ for (const key in attributes) {
169
+ this.translatedAttributes[key] = attributes[key];
170
+ }
171
+ return this;
172
+ }
173
+ /**
174
+ * Add description to the validator
175
+ */
176
+ describe(description) {
177
+ this.description = description;
178
+ return this;
179
+ }
180
+ /**
181
+ * Check if this validator can handle the given value's type
182
+ * Override this in specific validators to enable type-based routing in union validators
183
+ *
184
+ * Default: returns true (validator will attempt to validate any type)
185
+ *
186
+ * @param value - The value to check
187
+ * @returns True if this validator can handle this type
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * // StringValidator
192
+ * public matchesType(value: any): boolean {
193
+ * return typeof value === 'string';
194
+ * }
195
+ *
196
+ * // Custom FileValidator
197
+ * public matchesType(value: any): boolean {
198
+ * return value instanceof UploadedFile;
199
+ * }
200
+ * ```
201
+ */
202
+ matchesType(_value) {
203
+ return true; // Default: permissive, attempt to validate any type
204
+ }
205
+ /**
206
+ * Create a copy of this validator with the same configuration
207
+ * Copies all rules, mutators, transformers, default values, and settings
208
+ *
209
+ * @returns A new validator instance with copied configuration
210
+ *
211
+ * @example
212
+ * ```ts
213
+ * // Create reusable validator templates
214
+ * const baseString = v.string().required().trim().min(3);
215
+ * const emailField = baseString.clone().email();
216
+ * const usernameField = baseString.clone().alphanumeric().max(20);
217
+ *
218
+ * // Works with all validators
219
+ * const positiveInt = v.int().positive().required();
220
+ * const ageField = positiveInt.clone().min(18).max(120);
221
+ * ```
222
+ */
223
+ clone() {
224
+ // Create a new instance using Object.create to preserve the prototype chain
225
+ const Constructor = this.constructor;
226
+ const cloned = Object.create(Constructor.prototype);
227
+ // Copy all BaseValidator properties
228
+ cloned.rules = [...this.rules];
229
+ cloned.mutators = [...this.mutators];
230
+ cloned.dataTransformers = [...this.dataTransformers];
231
+ cloned.defaultValue = this.defaultValue;
232
+ cloned.shouldOmit = this.shouldOmit;
233
+ cloned.description = this.description;
234
+ cloned.attributesText = { ...this.attributesText };
235
+ cloned.isNullable = this.isNullable;
236
+ return cloned;
237
+ }
238
+ /**
239
+ * @deprecated This method is no longer needed and does nothing.
240
+ * Empty values are now automatically skipped for validation rules by default.
241
+ * Only presence validators (required, present, etc.) will check empty values.
242
+ * You can safely remove this call from your code.
243
+ */
244
+ ignoreEmptyValue(_ignoreEmptyValue = true) {
245
+ // No-op for backward compatibility
246
+ return this;
247
+ }
248
+ /**
249
+ * Omit this field from the validated data output
250
+ *
251
+ * Field will still be validated but not included in the final result.
252
+ * Useful for confirmation fields, captcha, terms acceptance, etc.
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * v.object({
257
+ * password: v.string().required(),
258
+ * confirmPassword: v.string().required().sameAs("password").omit(),
259
+ * acceptTerms: v.boolean().required().omit(),
260
+ * });
261
+ * // Output: { password: "..." }
262
+ * // confirmPassword and acceptTerms validated but omitted
263
+ * ```
264
+ */
265
+ omit() {
266
+ this.shouldOmit = true;
267
+ return this;
268
+ }
269
+ /**
270
+ * @alias omit
271
+ */
272
+ exclude() {
273
+ return this.omit();
274
+ }
275
+ /**
276
+ * Check if this field should be omitted from the output
277
+ */
278
+ isOmitted() {
279
+ return this.shouldOmit;
280
+ }
281
+ /**
282
+ * Value must be equal to the given value
283
+ */
284
+ equal(value, errorMessage) {
285
+ const rule = this.addRule(equalRule, errorMessage);
286
+ rule.context.options.value = value;
287
+ return this;
288
+ }
289
+ /**
290
+ * Value must be the same as another field's value
291
+ */
292
+ sameAs(field, errorMessage) {
293
+ const rule = this.addRule(equalsFieldRule, errorMessage);
294
+ rule.context.options.field = field;
295
+ rule.context.options.scope = "global";
296
+ return this;
297
+ }
298
+ /**
299
+ * Value must be the same as another sibling field's value
300
+ */
301
+ sameAsSibling(field, errorMessage) {
302
+ const rule = this.addRule(equalsFieldRule, errorMessage);
303
+ rule.context.options.field = field;
304
+ rule.context.options.scope = "sibling";
305
+ return this;
306
+ }
307
+ /**
308
+ * Value must be different from another field's value
309
+ */
310
+ differentFrom(field, errorMessage) {
311
+ const rule = this.addRule(notEqualsFieldRule, errorMessage);
312
+ rule.context.options.field = field;
313
+ rule.context.options.scope = "global";
314
+ return this;
315
+ }
316
+ /**
317
+ * Value must be different from another sibling field's value
318
+ */
319
+ differentFromSibling(field, errorMessage) {
320
+ const rule = this.addRule(notEqualsFieldRule, errorMessage);
321
+ rule.context.options.field = field;
322
+ rule.context.options.scope = "sibling";
323
+ return this;
324
+ }
325
+ /**
326
+ * Add rule to the validator
327
+ */
328
+ addRule(rule, errorMessage) {
329
+ const newRule = {
330
+ ...clone(rule),
331
+ context: {
332
+ errorMessage,
333
+ options: {},
334
+ attributesList: this.attributesText,
335
+ translatedAttributes: this.translatedAttributes,
336
+ },
337
+ };
338
+ if (errorMessage) {
339
+ newRule.errorMessage = errorMessage;
340
+ }
341
+ if (rule.sortOrder === undefined) {
342
+ newRule.sortOrder = this.rules.length + 1;
343
+ }
344
+ this.rules.push(newRule);
345
+ return newRule;
346
+ }
347
+ /**
348
+ * Use a custom or pre-built validation rule
349
+ *
350
+ * @param rule - The validation rule to apply
351
+ * @param options - Rule options including errorMessage and any rule-specific options
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * import { hexColorRule } from "@warlock.js/seal";
356
+ *
357
+ * v.string().useRule(hexColorRule, { errorMessage: "Invalid color" });
358
+ * ```
359
+ *
360
+ * @example
361
+ * ```ts
362
+ * // With rule options
363
+ * v.string().useRule(myCustomRule, {
364
+ * customOption: true,
365
+ * errorMessage: "Custom validation failed"
366
+ * });
367
+ * ```
368
+ */
369
+ useRule(rule, options) {
370
+ const { errorMessage, ...ruleOptions } = options || {};
371
+ const ruleInstance = this.addRule(rule, errorMessage);
372
+ // Assign rule-specific options
373
+ if (Object.keys(ruleOptions).length > 0) {
374
+ Object.assign(ruleInstance.context.options, ruleOptions);
375
+ }
376
+ return this;
377
+ }
378
+ /**
379
+ * Define custom rule
380
+ */
381
+ refine(callback) {
382
+ this.addRule({
383
+ name: "custom",
384
+ async validate(value, context) {
385
+ const result = await callback(value, context);
386
+ if (result) {
387
+ this.context.errorMessage = result;
388
+ return invalidRule(this, context);
389
+ }
390
+ return VALID_RULE;
391
+ },
392
+ });
393
+ return this;
394
+ }
395
+ /**
396
+ * Add mutator to the validator
397
+ */
398
+ addMutator(mutator, options = {}) {
399
+ this.mutators.push({
400
+ mutate: mutator,
401
+ context: {
402
+ options,
403
+ ctx: {},
404
+ },
405
+ });
406
+ return this;
407
+ }
408
+ /**
409
+ * Set default value for the field
410
+ */
411
+ default(value) {
412
+ this.defaultValue = value;
413
+ return this;
414
+ }
415
+ // ==================== UNCONDITIONAL STATES ====================
416
+ /**
417
+ * This value must be present and has a value
418
+ */
419
+ required(errorMessage) {
420
+ this.addRule(requiredRule, errorMessage);
421
+ return this;
422
+ }
423
+ /**
424
+ * Value must be present but not necessarily has a value
425
+ */
426
+ present(errorMessage) {
427
+ this.addRule(presentRule, errorMessage);
428
+ return this;
429
+ }
430
+ /**
431
+ * Mark the field as optional, so pass it if it has no value or has a value
432
+ * Because this is the default behavior, this method is just syntactic sugar
433
+ */
434
+ optional() {
435
+ return this;
436
+ }
437
+ // ==================== REQUIRED: BASED ON FIELD PRESENCE ====================
438
+ /**
439
+ * Value is required if another field exists
440
+ */
441
+ requiredWith(field, errorMessage) {
442
+ const rule = this.addRule(requiredWithRule, errorMessage);
443
+ rule.context.options.field = field;
444
+ rule.context.options.scope = "global";
445
+ return this;
446
+ }
447
+ /**
448
+ * Value is required if another sibling field exists
449
+ */
450
+ requiredWithSibling(field, errorMessage) {
451
+ const rule = this.addRule(requiredWithRule, errorMessage);
452
+ rule.context.options.field = field;
453
+ rule.context.options.scope = "sibling";
454
+ return this;
455
+ }
456
+ /**
457
+ * Value is required if another field is missing
458
+ */
459
+ requiredWithout(field, errorMessage) {
460
+ const rule = this.addRule(requiredWithoutRule, errorMessage);
461
+ rule.context.options.field = field;
462
+ rule.context.options.scope = "global";
463
+ return this;
464
+ }
465
+ /**
466
+ * Value is required if another sibling field is missing
467
+ */
468
+ requiredWithoutSibling(field, errorMessage) {
469
+ const rule = this.addRule(requiredWithoutRule, errorMessage);
470
+ rule.context.options.field = field;
471
+ rule.context.options.scope = "sibling";
472
+ return this;
473
+ }
474
+ // ==================== REQUIRED: BASED ON FIELD VALUE ====================
475
+ /**
476
+ * Value is required if another field equals a specific value
477
+ */
478
+ requiredIf(field, value, errorMessage) {
479
+ const rule = this.addRule(requiredIfRule, errorMessage);
480
+ rule.context.options.field = field;
481
+ rule.context.options.value = value;
482
+ rule.context.options.scope = "global";
483
+ return this;
484
+ }
485
+ /**
486
+ * Value is required if another sibling field equals a specific value
487
+ */
488
+ requiredIfSibling(field, value, errorMessage) {
489
+ const rule = this.addRule(requiredIfRule, errorMessage);
490
+ rule.context.options.field = field;
491
+ rule.context.options.value = value;
492
+ rule.context.options.scope = "sibling";
493
+ return this;
494
+ }
495
+ /**
496
+ * Value is required unless another field equals a specific value
497
+ */
498
+ requiredUnless(field, value, errorMessage) {
499
+ const rule = this.addRule(requiredUnlessRule, errorMessage);
500
+ rule.context.options.field = field;
501
+ rule.context.options.value = value;
502
+ rule.context.options.scope = "global";
503
+ return this;
504
+ }
505
+ /**
506
+ * Value is required unless another sibling field equals a specific value
507
+ */
508
+ requiredUnlessSibling(field, value, errorMessage) {
509
+ const rule = this.addRule(requiredUnlessRule, errorMessage);
510
+ rule.context.options.field = field;
511
+ rule.context.options.value = value;
512
+ rule.context.options.scope = "sibling";
513
+ return this;
514
+ }
515
+ // ==================== REQUIRED: BASED ON FIELD EMPTY STATE ====================
516
+ /**
517
+ * Value is required if another field is empty
518
+ */
519
+ requiredIfEmpty(field, errorMessage) {
520
+ const rule = this.addRule(requiredIfEmptyRule, errorMessage);
521
+ rule.context.options.field = field;
522
+ rule.context.options.scope = "global";
523
+ return this;
524
+ }
525
+ /**
526
+ * Value is required if another sibling field is empty
527
+ */
528
+ requiredIfEmptySibling(field, errorMessage) {
529
+ const rule = this.addRule(requiredIfEmptyRule, errorMessage);
530
+ rule.context.options.field = field;
531
+ rule.context.options.scope = "sibling";
532
+ return this;
533
+ }
534
+ /**
535
+ * Value is required if another field is not empty
536
+ */
537
+ requiredIfNotEmpty(field, errorMessage) {
538
+ const rule = this.addRule(requiredIfNotEmptyRule, errorMessage);
539
+ rule.context.options.field = field;
540
+ rule.context.options.scope = "global";
541
+ return this;
542
+ }
543
+ /**
544
+ * Value is required if another sibling field is not empty
545
+ */
546
+ requiredIfNotEmptySibling(field, errorMessage) {
547
+ const rule = this.addRule(requiredIfNotEmptyRule, errorMessage);
548
+ rule.context.options.field = field;
549
+ rule.context.options.scope = "sibling";
550
+ return this;
551
+ }
552
+ /**
553
+ * Value is required if another field's value is in the given array
554
+ */
555
+ requiredIfIn(field, values, errorMessage) {
556
+ const rule = this.addRule(requiredIfInRule, errorMessage);
557
+ rule.context.options.field = field;
558
+ rule.context.options.values = values;
559
+ rule.context.options.scope = "global";
560
+ return this;
561
+ }
562
+ /**
563
+ * Value is required if another sibling field's value is in the given array
564
+ */
565
+ requiredIfInSibling(field, values, errorMessage) {
566
+ const rule = this.addRule(requiredIfInRule, errorMessage);
567
+ rule.context.options.field = field;
568
+ rule.context.options.values = values;
569
+ rule.context.options.scope = "sibling";
570
+ return this;
571
+ }
572
+ /**
573
+ * Value is required if another field's value is NOT in the given array
574
+ */
575
+ requiredIfNotIn(field, values, errorMessage) {
576
+ const rule = this.addRule(requiredIfNotInRule, errorMessage);
577
+ rule.context.options.field = field;
578
+ rule.context.options.values = values;
579
+ rule.context.options.scope = "global";
580
+ return this;
581
+ }
582
+ /**
583
+ * Value is required if another sibling field's value is NOT in the given array
584
+ */
585
+ requiredIfNotInSibling(field, values, errorMessage) {
586
+ const rule = this.addRule(requiredIfNotInRule, errorMessage);
587
+ rule.context.options.field = field;
588
+ rule.context.options.values = values;
589
+ rule.context.options.scope = "sibling";
590
+ return this;
591
+ }
592
+ // ==================== REQUIRED: BASED ON MULTIPLE FIELDS (ALL) ====================
593
+ /**
594
+ * Value is required if all specified fields exist
595
+ */
596
+ requiredWithAll(fields, errorMessage) {
597
+ const rule = this.addRule(requiredWithAllRule, errorMessage);
598
+ rule.context.options.fields = fields;
599
+ rule.context.options.scope = "global";
600
+ return this;
601
+ }
602
+ /**
603
+ * Value is required if all specified sibling fields exist
604
+ */
605
+ requiredWithAllSiblings(fields, errorMessage) {
606
+ const rule = this.addRule(requiredWithAllRule, errorMessage);
607
+ rule.context.options.fields = fields;
608
+ rule.context.options.scope = "sibling";
609
+ return this;
610
+ }
611
+ /**
612
+ * Value is required if all specified fields are missing
613
+ */
614
+ requiredWithoutAll(fields, errorMessage) {
615
+ const rule = this.addRule(requiredWithoutAllRule, errorMessage);
616
+ rule.context.options.fields = fields;
617
+ rule.context.options.scope = "global";
618
+ return this;
619
+ }
620
+ /**
621
+ * Value is required if all specified sibling fields are missing
622
+ */
623
+ requiredWithoutAllSiblings(fields, errorMessage) {
624
+ const rule = this.addRule(requiredWithoutAllRule, errorMessage);
625
+ rule.context.options.fields = fields;
626
+ rule.context.options.scope = "sibling";
627
+ return this;
628
+ }
629
+ // ==================== REQUIRED: BASED ON MULTIPLE FIELDS (ANY) ====================
630
+ /**
631
+ * Value is required if any of the specified fields exists
632
+ */
633
+ requiredWithAny(fields, errorMessage) {
634
+ const rule = this.addRule(requiredWithAnyRule, errorMessage);
635
+ rule.context.options.fields = fields;
636
+ rule.context.options.scope = "global";
637
+ return this;
638
+ }
639
+ /**
640
+ * Value is required if any of the specified sibling fields exists
641
+ */
642
+ requiredWithAnySiblings(fields, errorMessage) {
643
+ const rule = this.addRule(requiredWithAnyRule, errorMessage);
644
+ rule.context.options.fields = fields;
645
+ rule.context.options.scope = "sibling";
646
+ return this;
647
+ }
648
+ /**
649
+ * Value is required if any of the specified fields is missing
650
+ */
651
+ requiredWithoutAny(fields, errorMessage) {
652
+ const rule = this.addRule(requiredWithoutAnyRule, errorMessage);
653
+ rule.context.options.fields = fields;
654
+ rule.context.options.scope = "global";
655
+ return this;
656
+ }
657
+ /**
658
+ * Value is required if any of the specified sibling fields is missing
659
+ */
660
+ requiredWithoutAnySiblings(fields, errorMessage) {
661
+ const rule = this.addRule(requiredWithoutAnyRule, errorMessage);
662
+ rule.context.options.fields = fields;
663
+ rule.context.options.scope = "sibling";
664
+ return this;
665
+ }
666
+ // ==================== PRESENT: BASED ON FIELD PRESENCE ====================
667
+ /**
668
+ * Field must be present if another field exists
669
+ */
670
+ presentWith(field, errorMessage) {
671
+ const rule = this.addRule(presentWithRule, errorMessage);
672
+ rule.context.options.field = field;
673
+ rule.context.options.scope = "global";
674
+ return this;
675
+ }
676
+ /**
677
+ * Field must be present if another sibling field exists
678
+ */
679
+ presentWithSibling(field, errorMessage) {
680
+ const rule = this.addRule(presentWithRule, errorMessage);
681
+ rule.context.options.field = field;
682
+ rule.context.options.scope = "sibling";
683
+ return this;
684
+ }
685
+ /**
686
+ * Field must be present if another field is missing
687
+ */
688
+ presentWithout(field, errorMessage) {
689
+ const rule = this.addRule(presentWithoutRule, errorMessage);
690
+ rule.context.options.field = field;
691
+ rule.context.options.scope = "global";
692
+ return this;
693
+ }
694
+ /**
695
+ * Field must be present if another sibling field is missing
696
+ */
697
+ presentWithoutSibling(field, errorMessage) {
698
+ const rule = this.addRule(presentWithoutRule, errorMessage);
699
+ rule.context.options.field = field;
700
+ rule.context.options.scope = "sibling";
701
+ return this;
702
+ }
703
+ // ==================== PRESENT: BASED ON FIELD VALUE ====================
704
+ /**
705
+ * Field must be present if another field equals a specific value
706
+ */
707
+ presentIf(field, value, errorMessage) {
708
+ const rule = this.addRule(presentIfRule, errorMessage);
709
+ rule.context.options.field = field;
710
+ rule.context.options.value = value;
711
+ rule.context.options.scope = "global";
712
+ return this;
713
+ }
714
+ /**
715
+ * Field must be present if another sibling field equals a specific value
716
+ */
717
+ presentIfSibling(field, value, errorMessage) {
718
+ const rule = this.addRule(presentIfRule, errorMessage);
719
+ rule.context.options.field = field;
720
+ rule.context.options.value = value;
721
+ rule.context.options.scope = "sibling";
722
+ return this;
723
+ }
724
+ /**
725
+ * Field must be present unless another field equals a specific value
726
+ */
727
+ presentUnless(field, value, errorMessage) {
728
+ const rule = this.addRule(presentUnlessRule, errorMessage);
729
+ rule.context.options.field = field;
730
+ rule.context.options.value = value;
731
+ rule.context.options.scope = "global";
732
+ return this;
733
+ }
734
+ /**
735
+ * Field must be present unless another sibling field equals a specific value
736
+ */
737
+ presentUnlessSibling(field, value, errorMessage) {
738
+ const rule = this.addRule(presentUnlessRule, errorMessage);
739
+ rule.context.options.field = field;
740
+ rule.context.options.value = value;
741
+ rule.context.options.scope = "sibling";
742
+ return this;
743
+ }
744
+ // ==================== PRESENT: BASED ON FIELD EMPTY STATE ====================
745
+ /**
746
+ * Field must be present if another field is empty
747
+ */
748
+ presentIfEmpty(field, errorMessage) {
749
+ const rule = this.addRule(presentIfEmptyRule, errorMessage);
750
+ rule.context.options.field = field;
751
+ rule.context.options.scope = "global";
752
+ return this;
753
+ }
754
+ /**
755
+ * Field must be present if another sibling field is empty
756
+ */
757
+ presentIfEmptySibling(field, errorMessage) {
758
+ const rule = this.addRule(presentIfEmptyRule, errorMessage);
759
+ rule.context.options.field = field;
760
+ rule.context.options.scope = "sibling";
761
+ return this;
762
+ }
763
+ /**
764
+ * Field must be present if another field is not empty
765
+ */
766
+ presentIfNotEmpty(field, errorMessage) {
767
+ const rule = this.addRule(presentIfNotEmptyRule, errorMessage);
768
+ rule.context.options.field = field;
769
+ rule.context.options.scope = "global";
770
+ return this;
771
+ }
772
+ /**
773
+ * Field must be present if another sibling field is not empty
774
+ */
775
+ presentIfNotEmptySibling(field, errorMessage) {
776
+ const rule = this.addRule(presentIfNotEmptyRule, errorMessage);
777
+ rule.context.options.field = field;
778
+ rule.context.options.scope = "sibling";
779
+ return this;
780
+ }
781
+ /**
782
+ * Field must be present if another field's value is in the given array
783
+ */
784
+ presentIfIn(field, values, errorMessage) {
785
+ const rule = this.addRule(presentIfInRule, errorMessage);
786
+ rule.context.options.field = field;
787
+ rule.context.options.values = values;
788
+ rule.context.options.scope = "global";
789
+ return this;
790
+ }
791
+ /**
792
+ * Field must be present if another sibling field's value is in the given array
793
+ */
794
+ presentIfInSibling(field, values, errorMessage) {
795
+ const rule = this.addRule(presentIfInRule, errorMessage);
796
+ rule.context.options.field = field;
797
+ rule.context.options.values = values;
798
+ rule.context.options.scope = "sibling";
799
+ return this;
800
+ }
801
+ /**
802
+ * Field must be present if another field's value is NOT in the given array
803
+ */
804
+ presentIfNotIn(field, values, errorMessage) {
805
+ const rule = this.addRule(presentIfNotInRule, errorMessage);
806
+ rule.context.options.field = field;
807
+ rule.context.options.values = values;
808
+ rule.context.options.scope = "global";
809
+ return this;
810
+ }
811
+ /**
812
+ * Field must be present if another sibling field's value is NOT in the given array
813
+ */
814
+ presentIfNotInSibling(field, values, errorMessage) {
815
+ const rule = this.addRule(presentIfNotInRule, errorMessage);
816
+ rule.context.options.field = field;
817
+ rule.context.options.values = values;
818
+ rule.context.options.scope = "sibling";
819
+ return this;
820
+ }
821
+ // ==================== PRESENT: BASED ON MULTIPLE FIELDS (ALL) ====================
822
+ /**
823
+ * Field must be present if all specified fields exist
824
+ */
825
+ presentWithAll(fields, errorMessage) {
826
+ const rule = this.addRule(presentWithAllRule, errorMessage);
827
+ rule.context.options.fields = fields;
828
+ rule.context.options.scope = "global";
829
+ return this;
830
+ }
831
+ /**
832
+ * Field must be present if all specified sibling fields exist
833
+ */
834
+ presentWithAllSiblings(fields, errorMessage) {
835
+ const rule = this.addRule(presentWithAllRule, errorMessage);
836
+ rule.context.options.fields = fields;
837
+ rule.context.options.scope = "sibling";
838
+ return this;
839
+ }
840
+ /**
841
+ * Field must be present if all specified fields are missing
842
+ */
843
+ presentWithoutAll(fields, errorMessage) {
844
+ const rule = this.addRule(presentWithoutAllRule, errorMessage);
845
+ rule.context.options.fields = fields;
846
+ rule.context.options.scope = "global";
847
+ return this;
848
+ }
849
+ /**
850
+ * Field must be present if all specified sibling fields are missing
851
+ */
852
+ presentWithoutAllSiblings(fields, errorMessage) {
853
+ const rule = this.addRule(presentWithoutAllRule, errorMessage);
854
+ rule.context.options.fields = fields;
855
+ rule.context.options.scope = "sibling";
856
+ return this;
857
+ }
858
+ // ==================== PRESENT: BASED ON MULTIPLE FIELDS (ANY) ====================
859
+ /**
860
+ * Field must be present if any of the specified fields exists
861
+ */
862
+ presentWithAny(fields, errorMessage) {
863
+ const rule = this.addRule(presentWithAnyRule, errorMessage);
864
+ rule.context.options.fields = fields;
865
+ rule.context.options.scope = "global";
866
+ return this;
867
+ }
868
+ /**
869
+ * Field must be present if any of the specified sibling fields exists
870
+ */
871
+ presentWithAnySiblings(fields, errorMessage) {
872
+ const rule = this.addRule(presentWithAnyRule, errorMessage);
873
+ rule.context.options.fields = fields;
874
+ rule.context.options.scope = "sibling";
875
+ return this;
876
+ }
877
+ /**
878
+ * Field must be present if any of the specified fields is missing
879
+ */
880
+ presentWithoutAny(fields, errorMessage) {
881
+ const rule = this.addRule(presentWithoutAnyRule, errorMessage);
882
+ rule.context.options.fields = fields;
883
+ rule.context.options.scope = "global";
884
+ return this;
885
+ }
886
+ /**
887
+ * Field must be present if any of the specified sibling fields is missing
888
+ */
889
+ presentWithoutAnySiblings(fields, errorMessage) {
890
+ const rule = this.addRule(presentWithoutAnyRule, errorMessage);
891
+ rule.context.options.fields = fields;
892
+ rule.context.options.scope = "sibling";
893
+ return this;
894
+ }
895
+ /**
896
+ * Mutate the data
897
+ */
898
+ async mutate(data, context) {
899
+ let mutatedData = data;
900
+ for (const mutator of this.mutators) {
901
+ mutator.context.ctx = context;
902
+ mutatedData = await mutator.mutate(mutatedData, mutator.context);
903
+ }
904
+ return mutatedData;
905
+ }
906
+ /**
907
+ * Value is forbidden to be present
908
+ */
909
+ forbidden(errorMessage) {
910
+ this.addRule(forbiddenRule, errorMessage);
911
+ return this;
912
+ }
913
+ /**
914
+ * Value is forbidden if another field equals a specific value (global scope)
915
+ */
916
+ forbiddenIf(field, value, errorMessage) {
917
+ const rule = this.addRule(forbiddenIfRule, errorMessage);
918
+ rule.context.options.field = field;
919
+ rule.context.options.value = value;
920
+ rule.context.options.scope = "global";
921
+ return this;
922
+ }
923
+ /**
924
+ * Value is forbidden if another field equals a specific value (sibling scope)
925
+ */
926
+ forbiddenIfSibling(field, value, errorMessage) {
927
+ const rule = this.addRule(forbiddenIfRule, errorMessage);
928
+ rule.context.options.field = field;
929
+ rule.context.options.value = value;
930
+ rule.context.options.scope = "sibling";
931
+ return this;
932
+ }
933
+ /**
934
+ * Value is forbidden if another field does NOT equal a specific value (global scope)
935
+ */
936
+ forbiddenIfNot(field, value, errorMessage) {
937
+ const rule = this.addRule(forbiddenIfNotRule, errorMessage);
938
+ rule.context.options.field = field;
939
+ rule.context.options.value = value;
940
+ rule.context.options.scope = "global";
941
+ return this;
942
+ }
943
+ /**
944
+ * Value is forbidden if another field does NOT equal a specific value (sibling scope)
945
+ */
946
+ forbiddenIfNotSibling(field, value, errorMessage) {
947
+ const rule = this.addRule(forbiddenIfNotRule, errorMessage);
948
+ rule.context.options.field = field;
949
+ rule.context.options.value = value;
950
+ rule.context.options.scope = "sibling";
951
+ return this;
952
+ }
953
+ /**
954
+ * Value is forbidden if another field is empty (global scope)
955
+ */
956
+ forbiddenIfEmpty(field, errorMessage) {
957
+ const rule = this.addRule(forbiddenIfEmptyRule, errorMessage);
958
+ rule.context.options.field = field;
959
+ rule.context.options.scope = "global";
960
+ return this;
961
+ }
962
+ /**
963
+ * Value is forbidden if another field is empty (sibling scope)
964
+ */
965
+ forbiddenIfEmptySibling(field, errorMessage) {
966
+ const rule = this.addRule(forbiddenIfEmptyRule, errorMessage);
967
+ rule.context.options.field = field;
968
+ rule.context.options.scope = "sibling";
969
+ return this;
970
+ }
971
+ /**
972
+ * Value is forbidden if another field is not empty (global scope)
973
+ */
974
+ forbiddenIfNotEmpty(field, errorMessage) {
975
+ const rule = this.addRule(forbiddenIfNotEmptyRule, errorMessage);
976
+ rule.context.options.field = field;
977
+ rule.context.options.scope = "global";
978
+ return this;
979
+ }
980
+ /**
981
+ * Value is forbidden if another field is not empty (sibling scope)
982
+ */
983
+ forbiddenIfNotEmptySibling(field, errorMessage) {
984
+ const rule = this.addRule(forbiddenIfNotEmptyRule, errorMessage);
985
+ rule.context.options.field = field;
986
+ rule.context.options.scope = "sibling";
987
+ return this;
988
+ }
989
+ /**
990
+ * Value is forbidden if another field's value is in the given array (global scope)
991
+ */
992
+ forbiddenIfIn(field, values, errorMessage) {
993
+ const rule = this.addRule(forbiddenIfInRule, errorMessage);
994
+ rule.context.options.field = field;
995
+ rule.context.options.values = values;
996
+ rule.context.options.scope = "global";
997
+ return this;
998
+ }
999
+ /**
1000
+ * Value is forbidden if another field's value is in the given array (sibling scope)
1001
+ */
1002
+ forbiddenIfInSibling(field, values, errorMessage) {
1003
+ const rule = this.addRule(forbiddenIfInRule, errorMessage);
1004
+ rule.context.options.field = field;
1005
+ rule.context.options.values = values;
1006
+ rule.context.options.scope = "sibling";
1007
+ return this;
1008
+ }
1009
+ /**
1010
+ * Value is forbidden if another field's value is NOT in the given array (global scope)
1011
+ */
1012
+ forbiddenIfNotIn(field, values, errorMessage) {
1013
+ const rule = this.addRule(forbiddenIfNotInRule, errorMessage);
1014
+ rule.context.options.field = field;
1015
+ rule.context.options.values = values;
1016
+ rule.context.options.scope = "global";
1017
+ return this;
1018
+ }
1019
+ /**
1020
+ * Value is forbidden if another field's value is NOT in the given array (sibling scope)
1021
+ */
1022
+ forbiddenIfNotInSibling(field, values, errorMessage) {
1023
+ const rule = this.addRule(forbiddenIfNotInRule, errorMessage);
1024
+ rule.context.options.field = field;
1025
+ rule.context.options.values = values;
1026
+ rule.context.options.scope = "sibling";
1027
+ return this;
1028
+ }
1029
+ /**
1030
+ * Apply different validation rules based on another field's value (global scope)
1031
+ *
1032
+ * Use this when you need to apply completely different validators
1033
+ * based on another field's value (not just required/optional).
1034
+ *
1035
+ * @param field - Field name to check (can be nested with dot notation)
1036
+ * @param options - Validation options per field value
1037
+ *
1038
+ * @example
1039
+ * ```ts
1040
+ * // Different allowed values based on user type
1041
+ * v.object({
1042
+ * userType: v.string().in(['admin', 'user']),
1043
+ * role: v.string().when('userType', {
1044
+ * is: {
1045
+ * admin: v.string().in(['super', 'moderator']),
1046
+ * user: v.string().in(['member', 'guest'])
1047
+ * },
1048
+ * otherwise: v.string().optional()
1049
+ * })
1050
+ * })
1051
+ *
1052
+ * // Different validation rules based on type
1053
+ * v.object({
1054
+ * contactType: v.string().in(['email', 'phone']),
1055
+ * contact: v.string().when('contactType', {
1056
+ * is: {
1057
+ * email: v.string().email(),
1058
+ * phone: v.string().pattern(/^\d{10}$/)
1059
+ * }
1060
+ * })
1061
+ * })
1062
+ * ```
1063
+ * @category Conditional Validation
1064
+ */
1065
+ when(field, options) {
1066
+ const rule = this.addRule(whenRule);
1067
+ rule.context.options.field = field;
1068
+ rule.context.options.is = options.is;
1069
+ rule.context.options.otherwise = options.otherwise;
1070
+ rule.context.options.scope = "global";
1071
+ return this;
1072
+ }
1073
+ /**
1074
+ * Apply different validation rules based on sibling field's value
1075
+ *
1076
+ * Use this for nested objects where you need to check a field
1077
+ * within the same parent object.
1078
+ *
1079
+ * @param siblingField - Sibling field name to check
1080
+ * @param options - Validation options per field value
1081
+ *
1082
+ * @example
1083
+ * ```ts
1084
+ * // Array of users with role-based permissions
1085
+ * v.array(v.object({
1086
+ * userType: v.string().in(['admin', 'user']),
1087
+ * permissions: v.string().whenSibling('userType', {
1088
+ * is: {
1089
+ * admin: v.string().in(['read', 'write', 'delete']),
1090
+ * user: v.string().in(['read'])
1091
+ * }
1092
+ * })
1093
+ * }))
1094
+ * ```
1095
+ * @category Conditional Validation
1096
+ */
1097
+ whenSibling(siblingField, options) {
1098
+ const rule = this.addRule(whenRule);
1099
+ rule.context.options.field = siblingField;
1100
+ rule.context.options.is = options.is;
1101
+ rule.context.options.otherwise = options.otherwise;
1102
+ rule.context.options.scope = "sibling";
1103
+ return this;
1104
+ }
1105
+ /**
1106
+ * Set the label for the validator that will be matching the :input attribute
1107
+ */
1108
+ label(label) {
1109
+ this.attributesText.input = label;
1110
+ return this;
1111
+ }
1112
+ /**
1113
+ * Validate the data
1114
+ */
1115
+ async validate(data, context) {
1116
+ if (data === null && this.isNullable) {
1117
+ return { isValid: true, errors: [], data: null };
1118
+ }
1119
+ const valueForMutation = data ?? this.defaultValue;
1120
+ const mutatedData = await this.mutate(valueForMutation, context);
1121
+ const valueForRules = valueForMutation;
1122
+ const errors = [];
1123
+ let isValid = true;
1124
+ const isFirstErrorOnly = context.configurations?.firstErrorOnly ?? true;
1125
+ const isEmpty = isEmptyValue(valueForRules);
1126
+ for (const rule of this.rules) {
1127
+ if ((rule.requiresValue ?? true) && isEmpty)
1128
+ continue;
1129
+ this.setRuleAttributesList(rule);
1130
+ const result = await rule.validate(mutatedData, context);
1131
+ if (result.isValid === false) {
1132
+ isValid = false;
1133
+ errors.push({
1134
+ type: rule.name,
1135
+ error: result.error,
1136
+ input: result.path ?? context.path,
1137
+ });
1138
+ if (isFirstErrorOnly) {
1139
+ break;
1140
+ }
1141
+ }
1142
+ }
1143
+ return {
1144
+ isValid,
1145
+ errors,
1146
+ data: mutatedData !== undefined
1147
+ ? await this.startTransformationPipeline(mutatedData, context)
1148
+ : undefined,
1149
+ };
1150
+ }
1151
+ /**
1152
+ * Set rule attributes list
1153
+ */
1154
+ setRuleAttributesList(rule) {
1155
+ rule.context.attributesList =
1156
+ typeof this.attributesText[rule.name] === "object"
1157
+ ? this.attributesText[rule.name]
1158
+ : this.attributesText;
1159
+ }
1160
+ }export{BaseValidator};//# sourceMappingURL=base-validator.js.map