@warlock.js/seal 5.30.0 → 5.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (318) hide show
  1. package/CHANGELOG.md +46 -7
  2. package/README.md +57 -9
  3. package/cjs/index.cjs +41 -29
  4. package/cjs/index.cjs.map +1 -1
  5. package/cjs/{object--LXRt5RF.cjs → object-BoVGJ68E.cjs} +43 -24
  6. package/cjs/object-BoVGJ68E.cjs.map +1 -0
  7. package/cjs/object.cjs +2 -2
  8. package/cjs/{required-methods-DYsRO9aZ.cjs → required-methods-BJlnLnwa.cjs} +343 -258
  9. package/cjs/required-methods-BJlnLnwa.cjs.map +1 -0
  10. package/cjs/{string-DsqnKoSB.cjs → string-CM8x0u2w.cjs} +46 -44
  11. package/cjs/string-CM8x0u2w.cjs.map +1 -0
  12. package/cjs/string.cjs +2 -2
  13. package/esm/config.d.mts +7 -8
  14. package/esm/config.d.mts.map +1 -1
  15. package/esm/config.mjs.map +1 -1
  16. package/esm/factory/index.d.mts +2 -1
  17. package/esm/factory/index.mjs +1 -1
  18. package/esm/factory/validate.d.mts +3 -6
  19. package/esm/factory/validate.d.mts.map +1 -1
  20. package/esm/factory/validators.d.mts +16 -13
  21. package/esm/factory/validators.d.mts.map +1 -1
  22. package/esm/factory/validators.mjs +7 -1
  23. package/esm/factory/validators.mjs.map +1 -1
  24. package/esm/helpers/date-helpers.d.mts +1 -2
  25. package/esm/helpers/date-helpers.d.mts.map +1 -1
  26. package/esm/helpers/file.utils.d.mts +2 -4
  27. package/esm/helpers/file.utils.d.mts.map +1 -1
  28. package/esm/helpers/get-field-value.d.mts +2 -3
  29. package/esm/helpers/get-field-value.d.mts.map +1 -1
  30. package/esm/helpers/get-field-value.mjs +2 -1
  31. package/esm/helpers/get-field-value.mjs.map +1 -1
  32. package/esm/helpers/index.d.mts +6 -0
  33. package/esm/helpers/index.mjs +1 -1
  34. package/esm/helpers/path-helpers.d.mts +1 -2
  35. package/esm/helpers/path-helpers.d.mts.map +1 -1
  36. package/esm/helpers/validation-helpers.d.mts +4 -10
  37. package/esm/helpers/validation-helpers.d.mts.map +1 -1
  38. package/esm/index.d.mts +7 -0
  39. package/esm/mutators/array-mutators.d.mts +6 -7
  40. package/esm/mutators/array-mutators.d.mts.map +1 -1
  41. package/esm/mutators/boolean-mutators.d.mts +3 -4
  42. package/esm/mutators/boolean-mutators.d.mts.map +1 -1
  43. package/esm/mutators/date-mutators.d.mts +18 -19
  44. package/esm/mutators/date-mutators.d.mts.map +1 -1
  45. package/esm/mutators/index.d.mts +8 -0
  46. package/esm/mutators/index.mjs +1 -1
  47. package/esm/mutators/number-mutators.d.mts +10 -11
  48. package/esm/mutators/number-mutators.d.mts.map +1 -1
  49. package/esm/mutators/object-mutators.d.mts +4 -5
  50. package/esm/mutators/object-mutators.d.mts.map +1 -1
  51. package/esm/mutators/object-mutators.mjs +5 -4
  52. package/esm/mutators/object-mutators.mjs.map +1 -1
  53. package/esm/mutators/scalar-mutators.d.mts +2 -3
  54. package/esm/mutators/scalar-mutators.d.mts.map +1 -1
  55. package/esm/mutators/string-mutators.d.mts +37 -38
  56. package/esm/mutators/string-mutators.d.mts.map +1 -1
  57. package/esm/mutators/string-mutators.mjs +5 -3
  58. package/esm/mutators/string-mutators.mjs.map +1 -1
  59. package/esm/object.d.mts +3 -5
  60. package/esm/object.d.mts.map +1 -1
  61. package/esm/object.mjs.map +1 -1
  62. package/esm/plugins/plugin-system.d.mts +11 -9
  63. package/esm/plugins/plugin-system.d.mts.map +1 -1
  64. package/esm/rules/array/array-rules.d.mts +3 -4
  65. package/esm/rules/array/array-rules.d.mts.map +1 -1
  66. package/esm/rules/array/index.d.mts +2 -0
  67. package/esm/rules/array/index.mjs +1 -1
  68. package/esm/rules/color/color-rules.d.mts +8 -9
  69. package/esm/rules/color/color-rules.d.mts.map +1 -1
  70. package/esm/rules/color/index.d.mts +2 -0
  71. package/esm/rules/color/index.mjs +1 -1
  72. package/esm/rules/common/enum.d.mts +5 -6
  73. package/esm/rules/common/enum.d.mts.map +1 -1
  74. package/esm/rules/common/equals-field-rules.d.mts +3 -4
  75. package/esm/rules/common/equals-field-rules.d.mts.map +1 -1
  76. package/esm/rules/common/index.d.mts +7 -0
  77. package/esm/rules/common/index.mjs +1 -1
  78. package/esm/rules/common/instanceof.d.mts +2 -3
  79. package/esm/rules/common/instanceof.d.mts.map +1 -1
  80. package/esm/rules/common/literal.d.mts +2 -3
  81. package/esm/rules/common/literal.d.mts.map +1 -1
  82. package/esm/rules/common/literal.mjs.map +1 -1
  83. package/esm/rules/common/type-rules.d.mts +10 -11
  84. package/esm/rules/common/type-rules.d.mts.map +1 -1
  85. package/esm/rules/common/unknown-key.d.mts +2 -3
  86. package/esm/rules/common/unknown-key.d.mts.map +1 -1
  87. package/esm/rules/conditional/forbidden-if-rules.d.mts +7 -8
  88. package/esm/rules/conditional/forbidden-if-rules.d.mts.map +1 -1
  89. package/esm/rules/conditional/index.d.mts +11 -0
  90. package/esm/rules/conditional/index.mjs +1 -1
  91. package/esm/rules/conditional/present-if-rules.d.mts +6 -7
  92. package/esm/rules/conditional/present-if-rules.d.mts.map +1 -1
  93. package/esm/rules/conditional/present-unless-rules.d.mts +2 -3
  94. package/esm/rules/conditional/present-unless-rules.d.mts.map +1 -1
  95. package/esm/rules/conditional/present-with-rules.d.mts +4 -5
  96. package/esm/rules/conditional/present-with-rules.d.mts.map +1 -1
  97. package/esm/rules/conditional/present-without-rules.d.mts +4 -5
  98. package/esm/rules/conditional/present-without-rules.d.mts.map +1 -1
  99. package/esm/rules/conditional/required-if-rules.d.mts +10 -11
  100. package/esm/rules/conditional/required-if-rules.d.mts.map +1 -1
  101. package/esm/rules/conditional/required-unless-rules.d.mts +2 -3
  102. package/esm/rules/conditional/required-unless-rules.d.mts.map +1 -1
  103. package/esm/rules/conditional/required-when-rule.d.mts +2 -3
  104. package/esm/rules/conditional/required-when-rule.d.mts.map +1 -1
  105. package/esm/rules/conditional/required-with-rules.d.mts +4 -5
  106. package/esm/rules/conditional/required-with-rules.d.mts.map +1 -1
  107. package/esm/rules/conditional/required-without-rules.d.mts +4 -5
  108. package/esm/rules/conditional/required-without-rules.d.mts.map +1 -1
  109. package/esm/rules/core/equal.d.mts +2 -3
  110. package/esm/rules/core/equal.d.mts.map +1 -1
  111. package/esm/rules/core/forbidden.d.mts +2 -3
  112. package/esm/rules/core/forbidden.d.mts.map +1 -1
  113. package/esm/rules/core/index.d.mts +6 -0
  114. package/esm/rules/core/index.mjs +1 -1
  115. package/esm/rules/core/required.d.mts +3 -4
  116. package/esm/rules/core/required.d.mts.map +1 -1
  117. package/esm/rules/core/union.d.mts +10 -4
  118. package/esm/rules/core/union.d.mts.map +1 -1
  119. package/esm/rules/core/union.mjs +56 -10
  120. package/esm/rules/core/union.mjs.map +1 -1
  121. package/esm/rules/core/when.d.mts +2 -3
  122. package/esm/rules/core/when.d.mts.map +1 -1
  123. package/esm/rules/core/when.mjs.map +1 -1
  124. package/esm/rules/date/date-comparison-rules.d.mts +6 -7
  125. package/esm/rules/date/date-comparison-rules.d.mts.map +1 -1
  126. package/esm/rules/date/date-day-rules.d.mts +5 -6
  127. package/esm/rules/date/date-day-rules.d.mts.map +1 -1
  128. package/esm/rules/date/date-field-comparison-rules.d.mts +4 -5
  129. package/esm/rules/date/date-field-comparison-rules.d.mts.map +1 -1
  130. package/esm/rules/date/date-field-comparison-rules.mjs +6 -3
  131. package/esm/rules/date/date-field-comparison-rules.mjs.map +1 -1
  132. package/esm/rules/date/date-period-rules.d.mts +16 -16
  133. package/esm/rules/date/date-period-rules.d.mts.map +1 -1
  134. package/esm/rules/date/date-period-rules.mjs +24 -12
  135. package/esm/rules/date/date-period-rules.mjs.map +1 -1
  136. package/esm/rules/date/date-relative-rules.d.mts +4 -5
  137. package/esm/rules/date/date-relative-rules.d.mts.map +1 -1
  138. package/esm/rules/date/date-relative-rules.mjs +3 -3
  139. package/esm/rules/date/date-relative-rules.mjs.map +1 -1
  140. package/esm/rules/date/date-special-rules.d.mts +4 -5
  141. package/esm/rules/date/date-special-rules.d.mts.map +1 -1
  142. package/esm/rules/date/date.d.mts +16 -17
  143. package/esm/rules/date/date.d.mts.map +1 -1
  144. package/esm/rules/date/date.mjs +4 -2
  145. package/esm/rules/date/date.mjs.map +1 -1
  146. package/esm/rules/date/index.d.mts +8 -0
  147. package/esm/rules/date/index.mjs +1 -1
  148. package/esm/rules/file/dimensions.d.mts +5 -6
  149. package/esm/rules/file/dimensions.d.mts.map +1 -1
  150. package/esm/rules/file/file-size.d.mts +3 -4
  151. package/esm/rules/file/file-size.d.mts.map +1 -1
  152. package/esm/rules/file/index.d.mts +3 -0
  153. package/esm/rules/file/index.mjs +1 -1
  154. package/esm/rules/index.d.mts +56 -0
  155. package/esm/rules/index.mjs +1 -1
  156. package/esm/rules/length/index.d.mts +2 -0
  157. package/esm/rules/length/index.mjs +1 -1
  158. package/esm/rules/length/length-rules.d.mts +8 -9
  159. package/esm/rules/length/length-rules.d.mts.map +1 -1
  160. package/esm/rules/number/index.d.mts +2 -0
  161. package/esm/rules/number/index.mjs +1 -1
  162. package/esm/rules/number/number-rules.d.mts +11 -12
  163. package/esm/rules/number/number-rules.d.mts.map +1 -1
  164. package/esm/rules/number/number-rules.mjs +12 -6
  165. package/esm/rules/number/number-rules.mjs.map +1 -1
  166. package/esm/rules/scalar/index.mjs +1 -1
  167. package/esm/rules/string/alpha.d.mts +4 -5
  168. package/esm/rules/string/alpha.d.mts.map +1 -1
  169. package/esm/rules/string/credit-card.d.mts +2 -3
  170. package/esm/rules/string/credit-card.d.mts.map +1 -1
  171. package/esm/rules/string/email.d.mts +2 -3
  172. package/esm/rules/string/email.d.mts.map +1 -1
  173. package/esm/rules/string/id-formats.d.mts +6 -7
  174. package/esm/rules/string/id-formats.d.mts.map +1 -1
  175. package/esm/rules/string/index.d.mts +12 -0
  176. package/esm/rules/string/index.mjs +1 -1
  177. package/esm/rules/string/ip.d.mts +7 -8
  178. package/esm/rules/string/ip.d.mts.map +1 -1
  179. package/esm/rules/string/matches.d.mts +2 -3
  180. package/esm/rules/string/matches.d.mts.map +1 -1
  181. package/esm/rules/string/pattern.d.mts +2 -3
  182. package/esm/rules/string/pattern.d.mts.map +1 -1
  183. package/esm/rules/string/string-comparison.d.mts +5 -6
  184. package/esm/rules/string/string-comparison.d.mts.map +1 -1
  185. package/esm/rules/string/strong-password-rule.d.mts +2 -3
  186. package/esm/rules/string/strong-password-rule.d.mts.map +1 -1
  187. package/esm/rules/string/url.d.mts +2 -3
  188. package/esm/rules/string/url.d.mts.map +1 -1
  189. package/esm/rules/string/without-whitespace.d.mts +2 -3
  190. package/esm/rules/string/without-whitespace.d.mts.map +1 -1
  191. package/esm/standard-schema/index.d.mts +4 -0
  192. package/esm/standard-schema/json-schema.d.mts +5 -7
  193. package/esm/standard-schema/json-schema.d.mts.map +1 -1
  194. package/esm/standard-schema/json-schema.mjs.map +1 -1
  195. package/esm/standard-schema/map-result.d.mts +2 -3
  196. package/esm/standard-schema/map-result.d.mts.map +1 -1
  197. package/esm/standard-schema/map-result.mjs.map +1 -1
  198. package/esm/standard-schema/types.d.mts +4 -5
  199. package/esm/standard-schema/types.d.mts.map +1 -1
  200. package/esm/string.d.mts +2 -3
  201. package/esm/string.d.mts.map +1 -1
  202. package/esm/types/conditional-types.d.mts +8 -6
  203. package/esm/types/conditional-types.d.mts.map +1 -1
  204. package/esm/types/context-types.d.mts +24 -15
  205. package/esm/types/context-types.d.mts.map +1 -1
  206. package/esm/types/data-transformer-types.d.mts +3 -5
  207. package/esm/types/data-transformer-types.d.mts.map +1 -1
  208. package/esm/types/date-types.d.mts +2 -3
  209. package/esm/types/date-types.d.mts.map +1 -1
  210. package/esm/types/file.types.d.mts +1 -2
  211. package/esm/types/file.types.d.mts.map +1 -1
  212. package/esm/types/index.d.mts +11 -0
  213. package/esm/types/inference-types.d.mts +15 -14
  214. package/esm/types/inference-types.d.mts.map +1 -1
  215. package/esm/types/mutator-types.d.mts +9 -7
  216. package/esm/types/mutator-types.d.mts.map +1 -1
  217. package/esm/types/result-types.d.mts +12 -7
  218. package/esm/types/result-types.d.mts.map +1 -1
  219. package/esm/types/rule-types.d.mts +33 -15
  220. package/esm/types/rule-types.d.mts.map +1 -1
  221. package/esm/types/schema-types.d.mts +1 -3
  222. package/esm/types/schema-types.d.mts.map +1 -1
  223. package/esm/validators/any-validator.d.mts +1 -3
  224. package/esm/validators/any-validator.d.mts.map +1 -1
  225. package/esm/validators/array-validator.d.mts +2 -3
  226. package/esm/validators/array-validator.d.mts.map +1 -1
  227. package/esm/validators/array-validator.mjs +3 -3
  228. package/esm/validators/array-validator.mjs.map +1 -1
  229. package/esm/validators/base-validator.d.mts +10 -11
  230. package/esm/validators/base-validator.d.mts.map +1 -1
  231. package/esm/validators/base-validator.mjs +52 -21
  232. package/esm/validators/base-validator.mjs.map +1 -1
  233. package/esm/validators/boolean-validator.d.mts +1 -3
  234. package/esm/validators/boolean-validator.d.mts.map +1 -1
  235. package/esm/validators/computed-validator.d.mts +3 -4
  236. package/esm/validators/computed-validator.d.mts.map +1 -1
  237. package/esm/validators/computed-validator.mjs +4 -4
  238. package/esm/validators/computed-validator.mjs.map +1 -1
  239. package/esm/validators/date-validator.d.mts +2 -3
  240. package/esm/validators/date-validator.d.mts.map +1 -1
  241. package/esm/validators/discriminated-union-validator.d.mts +3 -3
  242. package/esm/validators/discriminated-union-validator.d.mts.map +1 -1
  243. package/esm/validators/discriminated-union-validator.mjs +1 -1
  244. package/esm/validators/discriminated-union-validator.mjs.map +1 -1
  245. package/esm/validators/float-validator.d.mts +1 -3
  246. package/esm/validators/float-validator.d.mts.map +1 -1
  247. package/esm/validators/index.d.mts +2 -1
  248. package/esm/validators/index.mjs +1 -1
  249. package/esm/validators/instanceof-validator.d.mts +1 -3
  250. package/esm/validators/instanceof-validator.d.mts.map +1 -1
  251. package/esm/validators/int-validator.d.mts +1 -3
  252. package/esm/validators/int-validator.d.mts.map +1 -1
  253. package/esm/validators/lazy-validator.d.mts +2 -3
  254. package/esm/validators/lazy-validator.d.mts.map +1 -1
  255. package/esm/validators/lazy-validator.mjs +1 -1
  256. package/esm/validators/lazy-validator.mjs.map +1 -1
  257. package/esm/validators/literal-validator.d.mts +1 -3
  258. package/esm/validators/literal-validator.d.mts.map +1 -1
  259. package/esm/validators/managed-validator.d.mts +3 -4
  260. package/esm/validators/managed-validator.d.mts.map +1 -1
  261. package/esm/validators/methods/equality-conditional-methods.d.mts +3 -4
  262. package/esm/validators/methods/equality-conditional-methods.d.mts.map +1 -1
  263. package/esm/validators/methods/forbidden-methods.d.mts +2 -3
  264. package/esm/validators/methods/forbidden-methods.d.mts.map +1 -1
  265. package/esm/validators/methods/present-methods.d.mts +2 -3
  266. package/esm/validators/methods/present-methods.d.mts.map +1 -1
  267. package/esm/validators/methods/required-methods.d.mts +3 -4
  268. package/esm/validators/methods/required-methods.d.mts.map +1 -1
  269. package/esm/validators/number-validator.d.mts +1 -3
  270. package/esm/validators/number-validator.d.mts.map +1 -1
  271. package/esm/validators/number-validator.mjs +12 -8
  272. package/esm/validators/number-validator.mjs.map +1 -1
  273. package/esm/validators/numeric-validator.d.mts +1 -3
  274. package/esm/validators/numeric-validator.d.mts.map +1 -1
  275. package/esm/validators/object-validator.d.mts +2 -3
  276. package/esm/validators/object-validator.d.mts.map +1 -1
  277. package/esm/validators/object-validator.mjs +9 -7
  278. package/esm/validators/object-validator.mjs.map +1 -1
  279. package/esm/validators/primitive-validator.d.mts +1 -3
  280. package/esm/validators/primitive-validator.d.mts.map +1 -1
  281. package/esm/validators/record-validator.d.mts +2 -3
  282. package/esm/validators/record-validator.d.mts.map +1 -1
  283. package/esm/validators/record-validator.mjs +3 -3
  284. package/esm/validators/record-validator.mjs.map +1 -1
  285. package/esm/validators/scalar-validator.d.mts +1 -3
  286. package/esm/validators/scalar-validator.d.mts.map +1 -1
  287. package/esm/validators/scalar-validator.mjs.map +1 -1
  288. package/esm/validators/string-validator.d.mts +1 -3
  289. package/esm/validators/string-validator.d.mts.map +1 -1
  290. package/esm/validators/tuple-validator.d.mts +2 -3
  291. package/esm/validators/tuple-validator.d.mts.map +1 -1
  292. package/esm/validators/tuple-validator.mjs +3 -3
  293. package/esm/validators/tuple-validator.mjs.map +1 -1
  294. package/esm/validators/union-validator.d.mts +4 -4
  295. package/esm/validators/union-validator.d.mts.map +1 -1
  296. package/esm/validators/union-validator.mjs +3 -1
  297. package/esm/validators/union-validator.mjs.map +1 -1
  298. package/llms-full.txt +656 -527
  299. package/llms.txt +1 -1
  300. package/package.json +1 -1
  301. package/skills/bridge-standard-schema/SKILL.md +60 -36
  302. package/skills/compose-seal-modifiers/SKILL.md +89 -53
  303. package/skills/define-structural-shape/SKILL.md +41 -27
  304. package/skills/define-structural-shape/array-methods.md +27 -27
  305. package/skills/define-structural-shape/object-methods.md +38 -30
  306. package/skills/extend-seal-with-plugins/SKILL.md +39 -5
  307. package/skills/generate-json-schema/SKILL.md +13 -13
  308. package/skills/handle-seal-errors/SKILL.md +23 -23
  309. package/skills/index.md +4 -1
  310. package/skills/overview/SKILL.md +10 -2
  311. package/skills/pick-seal-primitive/SKILL.md +45 -45
  312. package/skills/pick-seal-primitive/date-methods.md +96 -96
  313. package/skills/pick-seal-primitive/number-methods.md +55 -55
  314. package/skills/pick-seal-primitive/string-methods.md +107 -102
  315. package/skills/seal-basics/SKILL.md +14 -14
  316. package/cjs/object--LXRt5RF.cjs.map +0 -1
  317. package/cjs/required-methods-DYsRO9aZ.cjs.map +0 -1
  318. package/cjs/string-DsqnKoSB.cjs.map +0 -1
@@ -2,8 +2,37 @@ import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
2
2
  import "../../helpers/index.mjs";
3
3
 
4
4
  //#region ../../packages/seal/src/rules/core/union.ts
5
+ const describeFailure = (index, errors) => ({
6
+ index,
7
+ errors,
8
+ literalMismatches: errors.filter((error) => error.type === "literal").length,
9
+ depth: Math.max(0, ...errors.map((error) => error.input ? error.input.split(".").length : 0))
10
+ });
5
11
  /**
6
- * Union rule - value must match at least one of the provided validators
12
+ * Whether `candidate` is closer to the value than `best`:
13
+ *
14
+ * 1. Fewest mismatched literals. A literal that does not match (`kind: "owner"`
15
+ * given `"member"`) says the value is a different member, while any other
16
+ * error says it is this member with a bad field.
17
+ * 2. Fewest errors.
18
+ * 3. Deepest error: the member matched more of the value's structure.
19
+ * 4. Declaration order (an earlier member wins a tie).
20
+ */
21
+ const isCloser = (candidate, best) => {
22
+ if (candidate.literalMismatches !== best.literalMismatches) return candidate.literalMismatches < best.literalMismatches;
23
+ if (candidate.errors.length !== best.errors.length) return candidate.errors.length < best.errors.length;
24
+ if (candidate.depth !== best.depth) return candidate.depth > best.depth;
25
+ return candidate.index < best.index;
26
+ };
27
+ /**
28
+ * Union rule - value must match at least one of the provided validators.
29
+ *
30
+ * Every member whose type matches the value is tried, in order, until one
31
+ * passes. When none passes, the errors of the closest failed member (see
32
+ * `isCloser`) are reported at their own paths with the `union` type: its
33
+ * first error under `firstErrorOnly` (the default), all of them otherwise.
34
+ * A custom union error message replaces them with a single error, as does the
35
+ * default message when no member matches the value's type.
7
36
  */
8
37
  const unionRule = {
9
38
  name: "union",
@@ -13,17 +42,34 @@ const unionRule = {
13
42
  if (value === void 0) return VALID_RULE;
14
43
  const validators = this.context.options.validators;
15
44
  const firstErrorOnly = context.configurations?.firstErrorOnly ?? true;
16
- const allErrors = [];
17
- for (const validator of validators) {
45
+ let closest;
46
+ for (const [index, validator] of validators.entries()) {
18
47
  if (!validator.matchesType(value)) continue;
19
- const result = await validator.validate(value, context);
20
- if (result.isValid) return VALID_RULE;
21
- const errorMsg = result.errors?.[0]?.error || "Validation failed";
22
- allErrors.push(errorMsg);
23
- if (firstErrorOnly) break;
48
+ const result = await validator.validate(value, { ...context });
49
+ if (result.isValid) return {
50
+ isValid: true,
51
+ data: result.data
52
+ };
53
+ const failure = describeFailure(index, result.errors?.length ? result.errors : [{
54
+ type: "union",
55
+ error: "Validation failed",
56
+ input: context.path
57
+ }]);
58
+ if (!closest || isCloser(failure, closest)) closest = failure;
24
59
  }
25
- if (allErrors.length > 0) this.context.errorMessage = firstErrorOnly ? allErrors[0] : allErrors.join("; ");
26
- return invalidRule(this, context);
60
+ const failed = invalidRule(this, context);
61
+ if (!closest || this.context.errorMessage) return failed;
62
+ const errors = (firstErrorOnly ? closest.errors.slice(0, 1) : closest.errors).map((error) => ({
63
+ error: error.error,
64
+ path: error.input
65
+ }));
66
+ const first = errors[0];
67
+ return first ? {
68
+ ...failed,
69
+ error: first.error,
70
+ path: first.path,
71
+ errors
72
+ } : failed;
27
73
  }
28
74
  };
29
75
 
@@ -1 +1 @@
1
- {"version":3,"file":"union.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/core/union.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\nimport type { BaseValidator } from \"../../validators/base-validator\";\n\n/**\n * Union rule - value must match at least one of the provided validators\n */\nexport const unionRule: SchemaRule<{ validators: BaseValidator[] }> = {\n name: \"union\",\n // Runs on \"empty\" values too: `v.union([v.literal(\"\"), v.int()]).present()`\n // must still ask its members about `\"\"` instead of accepting it unchecked.\n requiresValue: false,\n defaultErrorMessage: \"Value must match one of the allowed types\",\n async validate(value: any, context) {\n // Absence is the required/present rule's question, as for `literalRule`;\n // answering it here would defeat `.optional()`.\n if (value === undefined) {\n return VALID_RULE;\n }\n\n const validators = this.context.options.validators;\n const firstErrorOnly = context.configurations?.firstErrorOnly ?? true;\n const allErrors: string[] = [];\n\n // Try each validator\n for (const validator of validators) {\n // Skip if type doesn't match (optimization)\n if (!validator.matchesType(value)) {\n continue;\n }\n\n // Type matches - validate\n const result = await validator.validate(value, context);\n\n if (result.isValid) {\n // Success! Validator matched and validated\n return VALID_RULE;\n }\n\n // Failed - collect error message\n const errorMsg = result.errors?.[0]?.error || \"Validation failed\";\n allErrors.push(errorMsg);\n\n // If firstErrorOnly, stop after first failed validator\n if (firstErrorOnly) {\n break;\n }\n }\n\n // All failed or no validator matched the type\n if (allErrors.length > 0) {\n // At least one validator matched type but failed validation\n this.context.errorMessage = firstErrorOnly\n ? allErrors[0]\n : allErrors.join(\"; \");\n }\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAOA,MAAa,YAAyD;CACpE,MAAM;CAGN,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,IAAI,UAAU,QACZ,OAAO;EAGT,MAAM,aAAa,KAAK,QAAQ,QAAQ;EACxC,MAAM,iBAAiB,QAAQ,gBAAgB,kBAAkB;EACjE,MAAM,YAAsB,CAAC;EAG7B,KAAK,MAAM,aAAa,YAAY;GAElC,IAAI,CAAC,UAAU,YAAY,KAAK,GAC9B;GAIF,MAAM,SAAS,MAAM,UAAU,SAAS,OAAO,OAAO;GAEtD,IAAI,OAAO,SAET,OAAO;GAIT,MAAM,WAAW,OAAO,SAAS,EAAE,EAAE,SAAS;GAC9C,UAAU,KAAK,QAAQ;GAGvB,IAAI,gBACF;EAEJ;EAGA,IAAI,UAAU,SAAS,GAErB,KAAK,QAAQ,eAAe,iBACxB,UAAU,KACV,UAAU,KAAK,IAAI;EAGzB,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
1
+ {"version":3,"file":"union.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/core/union.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule, ValidationResult } from \"../../types\";\nimport type { BaseValidator } from \"../../validators/base-validator\";\n\ntype MemberFailure = {\n /** Declaration order of the member, the last tie-breaker. */\n index: number;\n errors: ValidationResult[\"errors\"];\n /** Mismatched literals: each says the value is a different member. */\n literalMismatches: number;\n /** Segments in the deepest error path (`a.b.c` → 3). */\n depth: number;\n};\n\nconst describeFailure = (index: number, errors: ValidationResult[\"errors\"]): MemberFailure => ({\n index,\n errors,\n literalMismatches: errors.filter((error) => error.type === \"literal\").length,\n depth: Math.max(0, ...errors.map((error) => (error.input ? error.input.split(\".\").length : 0))),\n});\n\n/**\n * Whether `candidate` is closer to the value than `best`:\n *\n * 1. Fewest mismatched literals. A literal that does not match (`kind: \"owner\"`\n * given `\"member\"`) says the value is a different member, while any other\n * error says it is this member with a bad field.\n * 2. Fewest errors.\n * 3. Deepest error: the member matched more of the value's structure.\n * 4. Declaration order (an earlier member wins a tie).\n */\nconst isCloser = (candidate: MemberFailure, best: MemberFailure): boolean => {\n if (candidate.literalMismatches !== best.literalMismatches) {\n return candidate.literalMismatches < best.literalMismatches;\n }\n\n if (candidate.errors.length !== best.errors.length) {\n return candidate.errors.length < best.errors.length;\n }\n\n if (candidate.depth !== best.depth) {\n return candidate.depth > best.depth;\n }\n\n return candidate.index < best.index;\n};\n\n/**\n * Union rule - value must match at least one of the provided validators.\n *\n * Every member whose type matches the value is tried, in order, until one\n * passes. When none passes, the errors of the closest failed member (see\n * `isCloser`) are reported at their own paths with the `union` type: its\n * first error under `firstErrorOnly` (the default), all of them otherwise.\n * A custom union error message replaces them with a single error, as does the\n * default message when no member matches the value's type.\n */\nexport const unionRule: SchemaRule<{ validators: BaseValidator[] }> = {\n name: \"union\",\n // Runs on \"empty\" values too: `v.union([v.literal(\"\"), v.int()]).present()`\n // must still ask its members about `\"\"` instead of accepting it unchecked.\n requiresValue: false,\n defaultErrorMessage: \"Value must match one of the allowed types\",\n async validate(value: any, context) {\n // Absence is the required/present rule's question, as for `literalRule`;\n // answering it here would defeat `.optional()`.\n if (value === undefined) {\n return VALID_RULE;\n }\n\n const validators = this.context.options.validators;\n const firstErrorOnly = context.configurations?.firstErrorOnly ?? true;\n let closest: MemberFailure | undefined;\n\n // `firstErrorOnly` limits the errors reported, never the members tried:\n // several object members all match a plain object, and a later one may\n // be the member the value belongs to.\n for (const [index, validator] of validators.entries()) {\n // A member that cannot hold this type of value cannot pass.\n if (!validator.matchesType(value)) {\n continue;\n }\n\n // Each member gets its own context: a member must not see what an\n // earlier member wrote into it (an object member sets `schema`).\n const result = await validator.validate(value, { ...context });\n\n if (result.isValid) {\n // Preserve defaults, computed fields and transformations from the branch.\n return { isValid: true, data: result.data };\n }\n\n const failure = describeFailure(\n index,\n result.errors?.length\n ? result.errors\n : [{ type: \"union\", error: \"Validation failed\", input: context.path }],\n );\n\n if (!closest || isCloser(failure, closest)) {\n closest = failure;\n }\n }\n\n const failed = invalidRule(this, context);\n\n // No member matched the type, or the union has its own message.\n if (!closest || this.context.errorMessage) {\n return failed;\n }\n\n const reported = firstErrorOnly ? closest.errors.slice(0, 1) : closest.errors;\n const errors = reported.map((error) => ({ error: error.error, path: error.input }));\n const first = errors[0];\n\n return first ? { ...failed, error: first.error, path: first.path, errors } : failed;\n },\n};\n"],"mappings":";;;;AAcA,MAAM,mBAAmB,OAAe,YAAuD;CAC7F;CACA;CACA,mBAAmB,OAAO,QAAQ,UAAU,MAAM,SAAS,SAAS,CAAC,CAAC;CACtE,OAAO,KAAK,IAAI,GAAG,GAAG,OAAO,KAAK,UAAW,MAAM,QAAQ,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,CAAE,CAAC;AAChG;;;;;;;;;;;AAYA,MAAM,YAAY,WAA0B,SAAiC;CAC3E,IAAI,UAAU,sBAAsB,KAAK,mBACvC,OAAO,UAAU,oBAAoB,KAAK;CAG5C,IAAI,UAAU,OAAO,WAAW,KAAK,OAAO,QAC1C,OAAO,UAAU,OAAO,SAAS,KAAK,OAAO;CAG/C,IAAI,UAAU,UAAU,KAAK,OAC3B,OAAO,UAAU,QAAQ,KAAK;CAGhC,OAAO,UAAU,QAAQ,KAAK;AAChC;;;;;;;;;;;AAYA,MAAa,YAAyD;CACpE,MAAM;CAGN,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,IAAI,UAAU,QACZ,OAAO;EAGT,MAAM,aAAa,KAAK,QAAQ,QAAQ;EACxC,MAAM,iBAAiB,QAAQ,gBAAgB,kBAAkB;EACjE,IAAI;EAKJ,KAAK,MAAM,CAAC,OAAO,cAAc,WAAW,QAAQ,GAAG;GAErD,IAAI,CAAC,UAAU,YAAY,KAAK,GAC9B;GAKF,MAAM,SAAS,MAAM,UAAU,SAAS,OAAO,EAAE,GAAG,QAAQ,CAAC;GAE7D,IAAI,OAAO,SAET,OAAO;IAAE,SAAS;IAAM,MAAM,OAAO;GAAK;GAG5C,MAAM,UAAU,gBACd,OACA,OAAO,QAAQ,SACX,OAAO,SACP,CAAC;IAAE,MAAM;IAAS,OAAO;IAAqB,OAAO,QAAQ;GAAK,CAAC,CACzE;GAEA,IAAI,CAAC,WAAW,SAAS,SAAS,OAAO,GACvC,UAAU;EAEd;EAEA,MAAM,SAAS,YAAY,MAAM,OAAO;EAGxC,IAAI,CAAC,WAAW,KAAK,QAAQ,cAC3B,OAAO;EAIT,MAAM,UADW,iBAAiB,QAAQ,OAAO,MAAM,GAAG,CAAC,IAAI,QAAQ,OAChD,CAAC,KAAK,WAAW;GAAE,OAAO,MAAM;GAAO,MAAM,MAAM;EAAM,EAAE;EAClF,MAAM,QAAQ,OAAO;EAErB,OAAO,QAAQ;GAAE,GAAG;GAAQ,OAAO,MAAM;GAAO,MAAM,MAAM;GAAM;EAAO,IAAI;CAC/E;AACF"}
@@ -1,11 +1,10 @@
1
1
  import { SchemaRule } from "../../types/rule-types.mjs";
2
2
  import { WhenRuleOptions } from "../../types/conditional-types.mjs";
3
-
3
+ import "../../types/index.mjs";
4
4
  //#region ../../packages/seal/src/rules/core/when.d.ts
5
5
  /**
6
6
  * When rule - conditional validation based on another field value
7
7
  */
8
- declare const whenRule: SchemaRule<WhenRuleOptions>;
8
+ export declare const whenRule: SchemaRule<WhenRuleOptions>;
9
9
  //#endregion
10
- export { whenRule };
11
10
  //# sourceMappingURL=when.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"when.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/core/when.ts"],"mappings":";;;;;;;cAOa,QAAA,EAAU,UAAU,CAAC,eAAA"}
1
+ {"version":3,"file":"when.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/core/when.ts"],"mappings":";;;;;;;qBAOa,UAAU,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"when.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/core/when.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule, WhenRuleOptions } from \"../../types\";\n\n/**\n * When rule - conditional validation based on another field value\n */\nexport const whenRule: SchemaRule<WhenRuleOptions> = {\n name: \"when\",\n description: \"Apply conditional validation based on another field value\",\n async validate(value: any, context) {\n const fieldToCheck = this.context.options.field;\n const conditions = this.context.options.is;\n const otherwise = this.context.options.otherwise;\n const scope = this.context.options.scope || \"global\";\n\n const fieldValue =\n scope === \"global\"\n ? get(context.allValues, fieldToCheck)\n : get(context.parent, fieldToCheck);\n\n // Convert field value to string for key lookup\n // This handles boolean, number, and string field values\n const fieldValueKey = String(fieldValue);\n\n if (conditions[fieldValueKey]) {\n const result = await conditions[fieldValueKey].validate(value, context);\n if (result.isValid) {\n return VALID_RULE;\n }\n\n // Safe error access\n this.context.errorMessage =\n result.errors?.[0]?.error || \"Validation failed\";\n return invalidRule(this, context);\n }\n\n if (otherwise) {\n const result = await otherwise.validate(value, context);\n\n if (result.isValid) {\n return VALID_RULE;\n }\n\n // Safe error access\n this.context.errorMessage =\n result.errors?.[0]?.error || \"Validation failed\";\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,WAAwC;CACnD,MAAM;CACN,aAAa;CACb,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,eAAe,KAAK,QAAQ,QAAQ;EAC1C,MAAM,aAAa,KAAK,QAAQ,QAAQ;EACxC,MAAM,YAAY,KAAK,QAAQ,QAAQ;EAGvC,MAAM,cAFQ,KAAK,QAAQ,QAAQ,SAAS,cAGhC,WACN,IAAI,QAAQ,WAAW,YAAY,IACnC,IAAI,QAAQ,QAAQ,YAAY;EAItC,MAAM,gBAAgB,OAAO,UAAU;EAEvC,IAAI,WAAW,gBAAgB;GAC7B,MAAM,SAAS,MAAM,WAAW,cAAc,CAAC,SAAS,OAAO,OAAO;GACtE,IAAI,OAAO,SACT,OAAO;GAIT,KAAK,QAAQ,eACX,OAAO,SAAS,EAAE,EAAE,SAAS;GAC/B,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,IAAI,WAAW;GACb,MAAM,SAAS,MAAM,UAAU,SAAS,OAAO,OAAO;GAEtD,IAAI,OAAO,SACT,OAAO;GAIT,KAAK,QAAQ,eACX,OAAO,SAAS,EAAE,EAAE,SAAS;GAC/B,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"when.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/core/when.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule, WhenRuleOptions } from \"../../types\";\n\n/**\n * When rule - conditional validation based on another field value\n */\nexport const whenRule: SchemaRule<WhenRuleOptions> = {\n name: \"when\",\n description: \"Apply conditional validation based on another field value\",\n async validate(value: any, context) {\n const fieldToCheck = this.context.options.field;\n const conditions = this.context.options.is;\n const otherwise = this.context.options.otherwise;\n const scope = this.context.options.scope || \"global\";\n\n const fieldValue =\n scope === \"global\" ? get(context.allValues, fieldToCheck) : get(context.parent, fieldToCheck);\n\n // Convert field value to string for key lookup\n // This handles boolean, number, and string field values\n const fieldValueKey = String(fieldValue);\n\n if (conditions[fieldValueKey]) {\n const result = await conditions[fieldValueKey].validate(value, context);\n if (result.isValid) {\n return VALID_RULE;\n }\n\n // Safe error access\n this.context.errorMessage = result.errors?.[0]?.error || \"Validation failed\";\n return invalidRule(this, context);\n }\n\n if (otherwise) {\n const result = await otherwise.validate(value, context);\n\n if (result.isValid) {\n return VALID_RULE;\n }\n\n // Safe error access\n this.context.errorMessage = result.errors?.[0]?.error || \"Validation failed\";\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,WAAwC;CACnD,MAAM;CACN,aAAa;CACb,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,eAAe,KAAK,QAAQ,QAAQ;EAC1C,MAAM,aAAa,KAAK,QAAQ,QAAQ;EACxC,MAAM,YAAY,KAAK,QAAQ,QAAQ;EAGvC,MAAM,cAFQ,KAAK,QAAQ,QAAQ,SAAS,cAGhC,WAAW,IAAI,QAAQ,WAAW,YAAY,IAAI,IAAI,QAAQ,QAAQ,YAAY;EAI9F,MAAM,gBAAgB,OAAO,UAAU;EAEvC,IAAI,WAAW,gBAAgB;GAC7B,MAAM,SAAS,MAAM,WAAW,cAAc,CAAC,SAAS,OAAO,OAAO;GACtE,IAAI,OAAO,SACT,OAAO;GAIT,KAAK,QAAQ,eAAe,OAAO,SAAS,EAAE,EAAE,SAAS;GACzD,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,IAAI,WAAW;GACb,MAAM,SAAS,MAAM,UAAU,SAAS,OAAO,OAAO;GAEtD,IAAI,OAAO,SACT,OAAO;GAIT,KAAK,QAAQ,eAAe,OAAO,SAAS,EAAE,EAAE,SAAS;GACzD,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF"}
@@ -1,29 +1,28 @@
1
1
  import { SchemaRule } from "../../types/rule-types.mjs";
2
-
2
+ import "../../types/index.mjs";
3
3
  //#region ../../packages/seal/src/rules/date/date-comparison-rules.d.ts
4
4
  /**
5
5
  * Between dates rule - date must be between start and end dates
6
6
  */
7
- declare const betweenDatesRule: SchemaRule<{
7
+ export declare const betweenDatesRule: SchemaRule<{
8
8
  startDate: Date;
9
9
  endDate: Date;
10
10
  }>;
11
11
  /**
12
12
  * Today rule - date must be exactly today
13
13
  */
14
- declare const todayRule: SchemaRule;
14
+ export declare const todayRule: SchemaRule;
15
15
  /**
16
16
  * Past rule - date must be in the past
17
17
  */
18
- declare const pastRule: SchemaRule;
18
+ export declare const pastRule: SchemaRule;
19
19
  /**
20
20
  * Future rule - date must be in the future
21
21
  */
22
- declare const futureRule: SchemaRule;
22
+ export declare const futureRule: SchemaRule;
23
23
  /**
24
24
  * After today rule - date must be after today (not including today)
25
25
  */
26
- declare const afterTodayRule: SchemaRule;
26
+ export declare const afterTodayRule: SchemaRule;
27
27
  //#endregion
28
- export { afterTodayRule, betweenDatesRule, futureRule, pastRule, todayRule };
29
28
  //# sourceMappingURL=date-comparison-rules.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"date-comparison-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-comparison-rules.ts"],"mappings":";;;;;AAMA;cAAa,gBAAA,EAAkB,UAAA;EAC7B,SAAA,EAAW,IAAA;EACX,OAAA,EAAS,IAAA;AAAA;;;;cAqBE,SAAA,EAAW,UAcvB;;;;cAKY,QAAA,EAAU,UAYtB;;AApDc;AAqBf;cAoCa,UAAA,EAAY,UAYxB;;;AAlCA;cAuCY,cAAA,EAAgB,UAc5B"}
1
+ {"version":3,"file":"date-comparison-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-comparison-rules.ts"],"mappings":";;;;;;qBAMa,kBAAkB;EAC7B,WAAW;EACX,SAAS;;;;;qBAqBE,WAAW;;;;qBAmBX,UAAU;;;;qBAiBV,YAAY;;;;qBAiBZ,gBAAgB"}
@@ -1,25 +1,24 @@
1
1
  import { SchemaRule } from "../../types/rule-types.mjs";
2
2
  import { WeekDay } from "../../types/date-types.mjs";
3
-
3
+ import "../../types/index.mjs";
4
4
  //#region ../../packages/seal/src/rules/date/date-day-rules.d.ts
5
5
  /**
6
6
  * Weekend rule - date must be Saturday or Sunday
7
7
  */
8
- declare const weekendRule: SchemaRule;
8
+ export declare const weekendRule: SchemaRule;
9
9
  /**
10
10
  * Weekday rule - date must be Monday through Friday
11
11
  */
12
- declare const weekdayRule: SchemaRule;
12
+ export declare const weekdayRule: SchemaRule;
13
13
  /**
14
14
  * Weekdays rule - date must be one of specified weekdays
15
15
  */
16
- declare const weekdaysRule: SchemaRule<{
16
+ export declare const weekdaysRule: SchemaRule<{
17
17
  days: WeekDay[];
18
18
  }>;
19
19
  /**
20
20
  * Business day rule - date must be Monday-Friday (no weekends)
21
21
  */
22
- declare const businessDayRule: SchemaRule;
22
+ export declare const businessDayRule: SchemaRule;
23
23
  //#endregion
24
- export { businessDayRule, weekdayRule, weekdaysRule, weekendRule };
25
24
  //# sourceMappingURL=date-day-rules.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"date-day-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-day-rules.ts"],"mappings":";;;;;;AAQA;cAAa,WAAA,EAAa,UAazB;;;AAAA;cAKY,WAAA,EAAa,UAczB;;;;cAKY,YAAA,EAAc,UAAU;EAAG,IAAA,EAAM,OAAA;AAAA;;;;cAyBjC,eAAA,EAAiB,UAc7B"}
1
+ {"version":3,"file":"date-day-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-day-rules.ts"],"mappings":";;;;;;;qBAQa,aAAa;;;;qBAkBb,aAAa;;;;qBAmBb,cAAc;EAAa,MAAM;;;;;qBAyBjC,iBAAiB"}
@@ -1,12 +1,12 @@
1
1
  import { SchemaRule } from "../../types/rule-types.mjs";
2
-
2
+ import "../../types/index.mjs";
3
3
  //#region ../../packages/seal/src/rules/date/date-field-comparison-rules.d.ts
4
4
  /**
5
5
  * Before field rule - date must be < given date or field
6
6
  * Smart detection: date value or field name
7
7
  * Supports both global and sibling scope
8
8
  */
9
- declare const beforeFieldRule: SchemaRule<{
9
+ export declare const beforeFieldRule: SchemaRule<{
10
10
  dateOrField: Date | string | number;
11
11
  scope?: "global" | "sibling";
12
12
  }>;
@@ -15,7 +15,7 @@ declare const beforeFieldRule: SchemaRule<{
15
15
  * Smart detection: date value or field name
16
16
  * Supports both global and sibling scope
17
17
  */
18
- declare const afterFieldRule: SchemaRule<{
18
+ export declare const afterFieldRule: SchemaRule<{
19
19
  dateOrField: Date | string | number;
20
20
  scope?: "global" | "sibling";
21
21
  }>;
@@ -23,10 +23,9 @@ declare const afterFieldRule: SchemaRule<{
23
23
  * Same as field rule - date must be the same as another field's date
24
24
  * Supports both global and sibling scope
25
25
  */
26
- declare const sameAsFieldDateRule: SchemaRule<{
26
+ export declare const sameAsFieldDateRule: SchemaRule<{
27
27
  field: string;
28
28
  scope?: "global" | "sibling";
29
29
  }>;
30
30
  //#endregion
31
- export { afterFieldRule, beforeFieldRule, sameAsFieldDateRule };
32
31
  //# sourceMappingURL=date-field-comparison-rules.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"date-field-comparison-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-field-comparison-rules.ts"],"mappings":";;;;;AAUA;;;cAAa,eAAA,EAAiB,UAAU;EACtC,WAAA,EAAa,IAAA;EACb,KAAA;AAAA;;;AAAK;AAsCP;;cAAa,cAAA,EAAgB,UAAU;EACrC,WAAA,EAAa,IAAA;EACb,KAAA;AAAA;;;;AAAK;cAwCM,mBAAA,EAAqB,UAAU;EAC1C,KAAA;EACA,KAAA;AAAA"}
1
+ {"version":3,"file":"date-field-comparison-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-field-comparison-rules.ts"],"mappings":";;;;;;;;qBAUa,iBAAiB;EAC5B,aAAa;EACb;;;;;;;qBAsCW,gBAAgB;EAC3B,aAAa;EACb;;;;;;qBAwCW,qBAAqB;EAChC;EACA"}
@@ -18,7 +18,8 @@ const beforeFieldRule = {
18
18
  let compareDate;
19
19
  if (isDateValue(dateOrField)) compareDate = new Date(dateOrField);
20
20
  else {
21
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, dateOrField);
21
+ const source = scope === "sibling" ? context.parent : context.allValues;
22
+ const fieldValue = get(source, dateOrField);
22
23
  if (fieldValue === void 0) return VALID_RULE;
23
24
  compareDate = new Date(fieldValue);
24
25
  }
@@ -42,7 +43,8 @@ const afterFieldRule = {
42
43
  compareDate = new Date(dateOrField);
43
44
  this.context.translationParams.dateOrField = compareDate.toISOString();
44
45
  } else {
45
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, dateOrField);
46
+ const source = scope === "sibling" ? context.parent : context.allValues;
47
+ const fieldValue = get(source, dateOrField);
46
48
  if (fieldValue === void 0) return VALID_RULE;
47
49
  compareDate = new Date(fieldValue);
48
50
  this.context.translatableParams.dateOrField = fieldValue;
@@ -61,7 +63,8 @@ const sameAsFieldDateRule = {
61
63
  defaultErrorMessage: "The :input must be the same as :field",
62
64
  async validate(value, context) {
63
65
  const { field, scope = "global" } = this.context.options;
64
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, field);
66
+ const source = scope === "sibling" ? context.parent : context.allValues;
67
+ const fieldValue = get(source, field);
65
68
  if (fieldValue === void 0 || value === void 0) {
66
69
  this.context.translatableParams.field = fieldValue;
67
70
  return invalidRule(this, context);
@@ -1 +1 @@
1
- {"version":3,"file":"date-field-comparison-rules.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-field-comparison-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isDateValue } from \"../../helpers/date-helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Before field rule - date must be < given date or field\n * Smart detection: date value or field name\n * Supports both global and sibling scope\n */\nexport const beforeFieldRule: SchemaRule<{\n dateOrField: Date | string | number;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"beforeField\",\n description: \"The date must be before the given date or field\",\n defaultErrorMessage: \"The :input must be before :dateOrField\",\n async validate(value: Date, context) {\n const { dateOrField, scope = \"global\" } = this.context.options;\n let compareDate: Date;\n\n if (isDateValue(dateOrField)) {\n // Value comparison\n compareDate = new Date(dateOrField);\n } else {\n // Field comparison\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dateOrField as string);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n compareDate = new Date(fieldValue);\n }\n\n const inputDate = new Date(value);\n\n if (inputDate < compareDate) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * After field rule - date must be > given date or field\n * Smart detection: date value or field name\n * Supports both global and sibling scope\n */\nexport const afterFieldRule: SchemaRule<{\n dateOrField: Date | string | number;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"afterField\",\n description: \"The date must be after the given date or field\",\n defaultErrorMessage: \"The :input must be after :dateOrField\",\n async validate(value: Date, context) {\n const { dateOrField, scope = \"global\" } = this.context.options;\n let compareDate: Date;\n\n if (isDateValue(dateOrField)) {\n // Value comparison\n compareDate = new Date(dateOrField);\n this.context.translationParams.dateOrField = compareDate.toISOString();\n } else {\n // Field comparison\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dateOrField as string);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n compareDate = new Date(fieldValue);\n this.context.translatableParams.dateOrField = fieldValue;\n }\n\n const inputDate = new Date(value);\n\n if (inputDate > compareDate) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Same as field rule - date must be the same as another field's date\n * Supports both global and sibling scope\n */\nexport const sameAsFieldDateRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"sameAsFieldDate\",\n description: \"The date must be the same as another field's date\",\n defaultErrorMessage: \"The :input must be the same as :field\",\n async validate(value: Date, context) {\n const { field, scope = \"global\" } = this.context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, field);\n\n // Both fields must exist to be considered \"the same\"\n if (fieldValue === undefined || value === undefined) {\n this.context.translatableParams.field = fieldValue;\n return invalidRule(this, context);\n }\n\n const inputDate = new Date(value);\n inputDate.setHours(0, 0, 0, 0);\n const compareDate = new Date(fieldValue);\n compareDate.setHours(0, 0, 0, 0);\n\n if (inputDate.getTime() === compareDate.getTime()) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.field = fieldValue;\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,kBAGR;CACH,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,aAAa,QAAQ,aAAa,KAAK,QAAQ;EACvD,IAAI;EAEJ,IAAI,YAAY,WAAW,GAEzB,cAAc,IAAI,KAAK,WAAW;OAC7B;GAGL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,WAAqB;GAEpD,IAAI,eAAe,QACjB,OAAO;GAGT,cAAc,IAAI,KAAK,UAAU;EACnC;EAIA,IAAI,IAFkB,KAAK,KAEf,IAAI,aACd,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;;AAOA,MAAa,iBAGR;CACH,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,aAAa,QAAQ,aAAa,KAAK,QAAQ;EACvD,IAAI;EAEJ,IAAI,YAAY,WAAW,GAAG;GAE5B,cAAc,IAAI,KAAK,WAAW;GAClC,KAAK,QAAQ,kBAAkB,cAAc,YAAY,YAAY;EACvE,OAAO;GAGL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,WAAqB;GAEpD,IAAI,eAAe,QACjB,OAAO;GAGT,cAAc,IAAI,KAAK,UAAU;GACjC,KAAK,QAAQ,mBAAmB,cAAc;EAChD;EAIA,IAAI,IAFkB,KAAK,KAEf,IAAI,aACd,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,sBAGR;CACH,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,OAAO,QAAQ,aAAa,KAAK,QAAQ;EAEjD,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,KAAK;EAGpC,IAAI,eAAe,UAAa,UAAU,QAAW;GACnD,KAAK,QAAQ,mBAAmB,QAAQ;GACxC,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,MAAM,YAAY,IAAI,KAAK,KAAK;EAChC,UAAU,SAAS,GAAG,GAAG,GAAG,CAAC;EAC7B,MAAM,cAAc,IAAI,KAAK,UAAU;EACvC,YAAY,SAAS,GAAG,GAAG,GAAG,CAAC;EAE/B,IAAI,UAAU,QAAQ,MAAM,YAAY,QAAQ,GAC9C,OAAO;EAGT,KAAK,QAAQ,mBAAmB,QAAQ;EACxC,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
1
+ {"version":3,"file":"date-field-comparison-rules.mjs","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-field-comparison-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isDateValue } from \"../../helpers/date-helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Before field rule - date must be < given date or field\n * Smart detection: date value or field name\n * Supports both global and sibling scope\n */\nexport const beforeFieldRule: SchemaRule<{\n dateOrField: Date | string | number;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"beforeField\",\n description: \"The date must be before the given date or field\",\n defaultErrorMessage: \"The :input must be before :dateOrField\",\n async validate(value: Date, context) {\n const { dateOrField, scope = \"global\" } = this.context.options;\n let compareDate: Date;\n\n if (isDateValue(dateOrField)) {\n // Value comparison\n compareDate = new Date(dateOrField);\n } else {\n // Field comparison\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dateOrField as string);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n compareDate = new Date(fieldValue);\n }\n\n const inputDate = new Date(value);\n\n if (inputDate < compareDate) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * After field rule - date must be > given date or field\n * Smart detection: date value or field name\n * Supports both global and sibling scope\n */\nexport const afterFieldRule: SchemaRule<{\n dateOrField: Date | string | number;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"afterField\",\n description: \"The date must be after the given date or field\",\n defaultErrorMessage: \"The :input must be after :dateOrField\",\n async validate(value: Date, context) {\n const { dateOrField, scope = \"global\" } = this.context.options;\n let compareDate: Date;\n\n if (isDateValue(dateOrField)) {\n // Value comparison\n compareDate = new Date(dateOrField);\n this.context.translationParams.dateOrField = compareDate.toISOString();\n } else {\n // Field comparison\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dateOrField as string);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n compareDate = new Date(fieldValue);\n this.context.translatableParams.dateOrField = fieldValue;\n }\n\n const inputDate = new Date(value);\n\n if (inputDate > compareDate) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Same as field rule - date must be the same as another field's date\n * Supports both global and sibling scope\n */\nexport const sameAsFieldDateRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"sameAsFieldDate\",\n description: \"The date must be the same as another field's date\",\n defaultErrorMessage: \"The :input must be the same as :field\",\n async validate(value: Date, context) {\n const { field, scope = \"global\" } = this.context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, field);\n\n // Both fields must exist to be considered \"the same\"\n if (fieldValue === undefined || value === undefined) {\n this.context.translatableParams.field = fieldValue;\n return invalidRule(this, context);\n }\n\n const inputDate = new Date(value);\n inputDate.setHours(0, 0, 0, 0);\n const compareDate = new Date(fieldValue);\n compareDate.setHours(0, 0, 0, 0);\n\n if (inputDate.getTime() === compareDate.getTime()) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.field = fieldValue;\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,kBAGR;CACH,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,aAAa,QAAQ,aAAa,KAAK,QAAQ;EACvD,IAAI;EAEJ,IAAI,YAAY,WAAW,GAEzB,cAAc,IAAI,KAAK,WAAW;OAC7B;GAEL,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;GAC9D,MAAM,aAAa,IAAI,QAAQ,WAAqB;GAEpD,IAAI,eAAe,QACjB,OAAO;GAGT,cAAc,IAAI,KAAK,UAAU;EACnC;EAIA,IAAI,IAFkB,KAAK,KAEf,IAAI,aACd,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;;AAOA,MAAa,iBAGR;CACH,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,aAAa,QAAQ,aAAa,KAAK,QAAQ;EACvD,IAAI;EAEJ,IAAI,YAAY,WAAW,GAAG;GAE5B,cAAc,IAAI,KAAK,WAAW;GAClC,KAAK,QAAQ,kBAAkB,cAAc,YAAY,YAAY;EACvE,OAAO;GAEL,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;GAC9D,MAAM,aAAa,IAAI,QAAQ,WAAqB;GAEpD,IAAI,eAAe,QACjB,OAAO;GAGT,cAAc,IAAI,KAAK,UAAU;GACjC,KAAK,QAAQ,mBAAmB,cAAc;EAChD;EAIA,IAAI,IAFkB,KAAK,KAEf,IAAI,aACd,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,sBAGR;CACH,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,OAAO,QAAQ,aAAa,KAAK,QAAQ;EACjD,MAAM,SAAS,UAAU,YAAY,QAAQ,SAAS,QAAQ;EAC9D,MAAM,aAAa,IAAI,QAAQ,KAAK;EAGpC,IAAI,eAAe,UAAa,UAAU,QAAW;GACnD,KAAK,QAAQ,mBAAmB,QAAQ;GACxC,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,MAAM,YAAY,IAAI,KAAK,KAAK;EAChC,UAAU,SAAS,GAAG,GAAG,GAAG,CAAC;EAC7B,MAAM,cAAc,IAAI,KAAK,UAAU;EACvC,YAAY,SAAS,GAAG,GAAG,GAAG,CAAC;EAE/B,IAAI,UAAU,QAAQ,MAAM,YAAY,QAAQ,GAC9C,OAAO;EAGT,KAAK,QAAQ,mBAAmB,QAAQ;EACxC,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { SchemaRule } from "../../types/rule-types.mjs";
2
-
2
+ import "../../types/index.mjs";
3
3
  //#region ../../packages/seal/src/rules/date/date-period-rules.d.ts
4
4
  declare const MONTHS: {
5
5
  1: string;
@@ -15,24 +15,24 @@ declare const MONTHS: {
15
15
  11: string;
16
16
  12: string;
17
17
  };
18
- type Month = keyof typeof MONTHS;
18
+ export type Month = keyof typeof MONTHS;
19
19
  /**
20
20
  * Month rule - date must be in specific month (1-12)
21
21
  */
22
- declare const monthRule: SchemaRule<{
22
+ export declare const monthRule: SchemaRule<{
23
23
  month: Month;
24
24
  }>;
25
25
  /**
26
26
  * Year rule - date must be in specific year
27
27
  */
28
- declare const yearRule: SchemaRule<{
28
+ export declare const yearRule: SchemaRule<{
29
29
  year: number;
30
30
  }>;
31
31
  /**
32
32
  * Between years rule - date must be between start and end years
33
33
  * Supports field names with sibling scope
34
34
  */
35
- declare const betweenYearsRule: SchemaRule<{
35
+ export declare const betweenYearsRule: SchemaRule<{
36
36
  startYear: number | string;
37
37
  endYear: number | string;
38
38
  scope?: "global" | "sibling";
@@ -41,7 +41,7 @@ declare const betweenYearsRule: SchemaRule<{
41
41
  * Between months rule - date must be between start and end months (1-12)
42
42
  * Supports field names with sibling scope
43
43
  */
44
- declare const betweenMonthsRule: SchemaRule<{
44
+ export declare const betweenMonthsRule: SchemaRule<{
45
45
  startMonth: Month | string;
46
46
  endMonth: Month | string;
47
47
  scope?: "global" | "sibling";
@@ -50,7 +50,7 @@ declare const betweenMonthsRule: SchemaRule<{
50
50
  * Between days rule - date must be between start and end days (1-31)
51
51
  * Supports field names with sibling scope
52
52
  */
53
- declare const betweenDaysRule: SchemaRule<{
53
+ export declare const betweenDaysRule: SchemaRule<{
54
54
  startDay: number | string;
55
55
  endDay: number | string;
56
56
  scope?: "global" | "sibling";
@@ -58,13 +58,13 @@ declare const betweenDaysRule: SchemaRule<{
58
58
  /**
59
59
  * Quarter rule - date must be in specific quarter (1-4)
60
60
  */
61
- declare const quarterRule: SchemaRule<{
61
+ export declare const quarterRule: SchemaRule<{
62
62
  quarter: 1 | 2 | 3 | 4;
63
63
  }>;
64
64
  /**
65
65
  * Between times rule - time must be between start and end times (HH:MM format)
66
66
  */
67
- declare const betweenTimesRule: SchemaRule<{
67
+ export declare const betweenTimesRule: SchemaRule<{
68
68
  startTime: string;
69
69
  endTime: string;
70
70
  }>;
@@ -73,7 +73,7 @@ declare const betweenTimesRule: SchemaRule<{
73
73
  * Smart detection: number or field name
74
74
  * Supports both global and sibling scope
75
75
  */
76
- declare const minYearRule: SchemaRule<{
76
+ export declare const minYearRule: SchemaRule<{
77
77
  yearOrField: number | string;
78
78
  scope?: "global" | "sibling";
79
79
  }>;
@@ -82,7 +82,7 @@ declare const minYearRule: SchemaRule<{
82
82
  * Smart detection: number or field name
83
83
  * Supports both global and sibling scope
84
84
  */
85
- declare const maxYearRule: SchemaRule<{
85
+ export declare const maxYearRule: SchemaRule<{
86
86
  yearOrField: number | string;
87
87
  scope?: "global" | "sibling";
88
88
  }>;
@@ -91,7 +91,7 @@ declare const maxYearRule: SchemaRule<{
91
91
  * Smart detection: number or field name
92
92
  * Supports both global and sibling scope
93
93
  */
94
- declare const minMonthRule: SchemaRule<{
94
+ export declare const minMonthRule: SchemaRule<{
95
95
  monthOrField: number | string;
96
96
  scope?: "global" | "sibling";
97
97
  }>;
@@ -100,7 +100,7 @@ declare const minMonthRule: SchemaRule<{
100
100
  * Smart detection: number or field name
101
101
  * Supports both global and sibling scope
102
102
  */
103
- declare const maxMonthRule: SchemaRule<{
103
+ export declare const maxMonthRule: SchemaRule<{
104
104
  monthOrField: Month | string;
105
105
  scope?: "global" | "sibling";
106
106
  }>;
@@ -109,7 +109,7 @@ declare const maxMonthRule: SchemaRule<{
109
109
  * Smart detection: number or field name
110
110
  * Supports both global and sibling scope
111
111
  */
112
- declare const minDayRule: SchemaRule<{
112
+ export declare const minDayRule: SchemaRule<{
113
113
  dayOrField: number | string;
114
114
  scope?: "global" | "sibling";
115
115
  }>;
@@ -118,10 +118,10 @@ declare const minDayRule: SchemaRule<{
118
118
  * Smart detection: number or field name
119
119
  * Supports both global and sibling scope
120
120
  */
121
- declare const maxDayRule: SchemaRule<{
121
+ export declare const maxDayRule: SchemaRule<{
122
122
  dayOrField: number | string;
123
123
  scope?: "global" | "sibling";
124
124
  }>;
125
125
  //#endregion
126
- export { Month, betweenDaysRule, betweenMonthsRule, betweenTimesRule, betweenYearsRule, maxDayRule, maxMonthRule, maxYearRule, minDayRule, minMonthRule, minYearRule, monthRule, quarterRule, yearRule };
126
+ export {};
127
127
  //# sourceMappingURL=date-period-rules.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"date-period-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-period-rules.ts"],"mappings":";;;cAIM,MAAA;;;;;;;;;;;;;;KAeM,KAAA,gBAAqB,MAAM;;;;cAK1B,SAAA,EAAW,UAAU;EAAG,KAAA,EAAO,KAAA;AAAA;;;;cAoB/B,QAAA,EAAU,UAAU;EAAG,IAAI;AAAA;;;;;cAoB3B,gBAAA,EAAkB,UAAU;EACvC,SAAA;EACA,OAAA;EACA,KAAA;AAAA;;;AAvBsC;AAoBxC;cA8Ea,iBAAA,EAAmB,UAAA;EAC9B,UAAA,EAAY,KAAA;EACZ,QAAA,EAAU,KAAA;EACV,KAAA;AAAA;;;;AA9EK;cA6JM,eAAA,EAAiB,UAAU;EACtC,QAAA;EACA,MAAA;EACA,KAAA;AAAA;;;;cA0EW,WAAA,EAAa,UAAU;EAAG,OAAO;AAAA;;;;cAoBjC,gBAAA,EAAkB,UAAU;EACvC,SAAA;EACA,OAAA;AAAA;;;;;;cAyCW,WAAA,EAAa,UAAU;EAClC,WAAA;EACA,KAAA;AAAA;;;;AAjE4C;AAoB9C;cAmGa,WAAA,EAAa,UAAU;EAClC,WAAA;EACA,KAAA;AAAA;;;;AAnGO;AAyCT;cAgHa,YAAA,EAAc,UAAU;EACnC,YAAA;EACA,KAAA;AAAA;;;;AAhHK;AAsDP;cA+Ga,YAAA,EAAc,UAAU;EACnC,YAAA,EAAc,KAAA;EACd,KAAA;AAAA;;;;AA/GK;AAsDP;cA+Ga,UAAA,EAAY,UAAU;EACjC,UAAA;EACA,KAAA;AAAA;;;;AA/GK;AAqDP;cA+Ga,UAAA,EAAY,UAAU;EACjC,UAAA;EACA,KAAA;AAAA"}
1
+ {"version":3,"file":"date-period-rules.d.mts","names":[],"sources":["../../../../../../../../../packages/seal/src/rules/date/date-period-rules.ts"],"mappings":";;;cAIM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU,qBAAqB;;;;qBAKpB,WAAW;EAAa,OAAO;;;;;qBAoB/B,UAAU;EAAa;;;;;;qBAoBvB,kBAAkB;EAC7B;EACA;EACA;;;;;;qBA2EW,mBAAmB;EAC9B,YAAY;EACZ,UAAU;EACV;;;;;;qBA+EW,iBAAiB;EAC5B;EACA;EACA;;;;;qBA0EW,aAAa;EAAa;;;;;qBAoB1B,kBAAkB;EAC7B;EACA;;;;;;;qBAyCW,aAAa;EACxB;EACA;;;;;;;qBAsDW,aAAa;EACxB;EACA;;;;;;;qBAsDW,cAAc;EACzB;EACA;;;;;;;qBAqDW,cAAc;EACzB,cAAc;EACd;;;;;;;qBAsDW,YAAY;EACvB;EACA;;;;;;;qBAqDW,YAAY;EACvB;EACA"}
@@ -54,7 +54,8 @@ const betweenYearsRule = {
54
54
  let compareStartYear;
55
55
  if (typeof startYear === "number") compareStartYear = startYear;
56
56
  else {
57
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, startYear);
57
+ const source = scope === "sibling" ? context.parent : context.allValues;
58
+ const fieldValue = get(source, startYear);
58
59
  if (fieldValue === void 0) return VALID_RULE;
59
60
  if (fieldValue instanceof Date) compareStartYear = fieldValue.getFullYear();
60
61
  else if (typeof fieldValue === "number") compareStartYear = fieldValue;
@@ -67,7 +68,8 @@ const betweenYearsRule = {
67
68
  let compareEndYear;
68
69
  if (typeof endYear === "number") compareEndYear = endYear;
69
70
  else {
70
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, endYear);
71
+ const source = scope === "sibling" ? context.parent : context.allValues;
72
+ const fieldValue = get(source, endYear);
71
73
  if (fieldValue === void 0) return VALID_RULE;
72
74
  if (fieldValue instanceof Date) compareEndYear = fieldValue.getFullYear();
73
75
  else if (typeof fieldValue === "number") compareEndYear = fieldValue;
@@ -98,7 +100,8 @@ const betweenMonthsRule = {
98
100
  compareStartMonth = startMonth;
99
101
  this.context.translatableParams.startMonth = MONTHS[compareStartMonth];
100
102
  } else {
101
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, startMonth);
103
+ const source = scope === "sibling" ? context.parent : context.allValues;
104
+ const fieldValue = get(source, startMonth);
102
105
  if (fieldValue === void 0) return VALID_RULE;
103
106
  this.context.translatableParams.startMonth = startMonth;
104
107
  if (fieldValue instanceof Date) compareStartMonth = fieldValue.getMonth() + 1;
@@ -114,7 +117,8 @@ const betweenMonthsRule = {
114
117
  compareEndMonth = endMonth;
115
118
  this.context.translatableParams.endMonth = MONTHS[compareEndMonth];
116
119
  } else {
117
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, endMonth);
120
+ const source = scope === "sibling" ? context.parent : context.allValues;
121
+ const fieldValue = get(source, endMonth);
118
122
  if (fieldValue === void 0) return VALID_RULE;
119
123
  this.context.translatableParams.endMonth = endMonth;
120
124
  if (fieldValue instanceof Date) compareEndMonth = fieldValue.getMonth() + 1;
@@ -142,7 +146,8 @@ const betweenDaysRule = {
142
146
  let compareStartDay;
143
147
  if (typeof startDay === "number") compareStartDay = startDay;
144
148
  else {
145
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, startDay);
149
+ const source = scope === "sibling" ? context.parent : context.allValues;
150
+ const fieldValue = get(source, startDay);
146
151
  if (fieldValue === void 0) return VALID_RULE;
147
152
  if (fieldValue instanceof Date) compareStartDay = fieldValue.getDate();
148
153
  else if (typeof fieldValue === "number") compareStartDay = fieldValue;
@@ -155,7 +160,8 @@ const betweenDaysRule = {
155
160
  let compareEndDay;
156
161
  if (typeof endDay === "number") compareEndDay = endDay;
157
162
  else {
158
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, endDay);
163
+ const source = scope === "sibling" ? context.parent : context.allValues;
164
+ const fieldValue = get(source, endDay);
159
165
  if (fieldValue === void 0) return VALID_RULE;
160
166
  if (fieldValue instanceof Date) compareEndDay = fieldValue.getDate();
161
167
  else if (typeof fieldValue === "number") compareEndDay = fieldValue;
@@ -224,7 +230,8 @@ const minYearRule = {
224
230
  compareYear = yearOrField;
225
231
  this.context.translationParams.yearOrField = yearOrField;
226
232
  } else {
227
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, yearOrField);
233
+ const source = scope === "sibling" ? context.parent : context.allValues;
234
+ const fieldValue = get(source, yearOrField);
228
235
  if (fieldValue === void 0) return VALID_RULE;
229
236
  this.context.translatableParams.yearOrField = yearOrField;
230
237
  if (fieldValue instanceof Date) compareYear = fieldValue.getFullYear();
@@ -255,7 +262,8 @@ const maxYearRule = {
255
262
  compareYear = yearOrField;
256
263
  this.context.translationParams.yearOrField = compareYear;
257
264
  } else {
258
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, yearOrField);
265
+ const source = scope === "sibling" ? context.parent : context.allValues;
266
+ const fieldValue = get(source, yearOrField);
259
267
  if (fieldValue === void 0) return VALID_RULE;
260
268
  this.context.translatableParams.yearOrField = yearOrField;
261
269
  if (fieldValue instanceof Date) compareYear = fieldValue.getFullYear();
@@ -286,7 +294,8 @@ const minMonthRule = {
286
294
  compareMonth = monthOrField;
287
295
  this.context.translationParams.monthOrField = compareMonth;
288
296
  } else {
289
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, monthOrField);
297
+ const source = scope === "sibling" ? context.parent : context.allValues;
298
+ const fieldValue = get(source, monthOrField);
290
299
  if (fieldValue === void 0) return VALID_RULE;
291
300
  this.context.translatableParams.monthOrField = monthOrField;
292
301
  if (fieldValue instanceof Date) compareMonth = fieldValue.getMonth() + 1;
@@ -317,7 +326,8 @@ const maxMonthRule = {
317
326
  compareMonth = monthOrField;
318
327
  this.context.translatableParams.monthOrField = MONTHS[monthOrField];
319
328
  } else {
320
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, monthOrField);
329
+ const source = scope === "sibling" ? context.parent : context.allValues;
330
+ const fieldValue = get(source, monthOrField);
321
331
  if (fieldValue === void 0) return VALID_RULE;
322
332
  this.context.translatableParams.monthOrField = monthOrField;
323
333
  if (fieldValue instanceof Date) compareMonth = fieldValue.getMonth() + 1;
@@ -348,7 +358,8 @@ const minDayRule = {
348
358
  compareDay = dayOrField;
349
359
  this.context.translationParams.dayOrField = dayOrField;
350
360
  } else {
351
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, dayOrField);
361
+ const source = scope === "sibling" ? context.parent : context.allValues;
362
+ const fieldValue = get(source, dayOrField);
352
363
  if (fieldValue === void 0) return VALID_RULE;
353
364
  this.context.translatableParams.dayOrField = dayOrField;
354
365
  if (fieldValue instanceof Date) compareDay = fieldValue.getDate();
@@ -379,7 +390,8 @@ const maxDayRule = {
379
390
  compareDay = dayOrField;
380
391
  this.context.translationParams.dayOrField = dayOrField;
381
392
  } else {
382
- const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, dayOrField);
393
+ const source = scope === "sibling" ? context.parent : context.allValues;
394
+ const fieldValue = get(source, dayOrField);
383
395
  if (fieldValue === void 0) return VALID_RULE;
384
396
  this.context.translatableParams.dayOrField = dayOrField;
385
397
  if (fieldValue instanceof Date) compareDay = fieldValue.getDate();