@clementine-solutions/jane-io 1.0.0 → 1.0.2

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 (408) hide show
  1. package/README.md +132 -1
  2. package/dist/core/analysis/diff.d.ts +35 -0
  3. package/dist/core/analysis/diff.js +88 -0
  4. package/dist/core/analysis/explain.d.ts +35 -0
  5. package/dist/core/analysis/explain.js +117 -0
  6. package/dist/core/analysis/index.d.ts +14 -0
  7. package/dist/core/analysis/index.js +26 -0
  8. package/dist/core/analysis/replay.d.ts +34 -0
  9. package/dist/core/analysis/replay.js +68 -0
  10. package/dist/core/analysis/telemetry.d.ts +28 -0
  11. package/dist/core/analysis/telemetry.js +123 -0
  12. package/dist/core/boundary-rules/at-most-one.d.ts +17 -0
  13. package/dist/core/boundary-rules/at-most-one.js +38 -0
  14. package/dist/core/boundary-rules/conditionally-required.d.ts +18 -0
  15. package/dist/core/boundary-rules/conditionally-required.js +44 -0
  16. package/dist/core/boundary-rules/date-range.d.ts +17 -0
  17. package/dist/core/boundary-rules/date-range.js +39 -0
  18. package/dist/core/boundary-rules/index.d.ts +18 -0
  19. package/dist/core/boundary-rules/index.js +21 -0
  20. package/dist/core/boundary-rules/mutually-exclusive.d.ts +16 -0
  21. package/dist/core/boundary-rules/mutually-exclusive.js +38 -0
  22. package/dist/core/boundary-rules/no-unknown-fields.d.ts +17 -0
  23. package/dist/core/boundary-rules/no-unknown-fields.js +39 -0
  24. package/dist/core/boundary-rules/require-all.d.ts +16 -0
  25. package/dist/core/boundary-rules/require-all.js +39 -0
  26. package/dist/core/boundary-rules/require-one.d.ts +17 -0
  27. package/dist/core/boundary-rules/require-one.js +41 -0
  28. package/dist/core/common/events.d.ts +37 -0
  29. package/dist/core/common/events.js +82 -0
  30. package/dist/core/common/fluent.d.ts +151 -0
  31. package/dist/core/common/fluent.js +429 -0
  32. package/dist/core/common/index.d.ts +16 -0
  33. package/dist/core/common/index.js +31 -0
  34. package/dist/core/common/policy.d.ts +170 -0
  35. package/dist/core/common/policy.js +550 -0
  36. package/dist/core/common/utilities.d.ts +59 -0
  37. package/dist/core/common/utilities.js +177 -0
  38. package/dist/core/common/wildcard.d.ts +27 -0
  39. package/dist/core/common/wildcard.js +63 -0
  40. package/dist/core/field-path/construct.d.ts +77 -0
  41. package/dist/core/field-path/construct.js +189 -0
  42. package/dist/core/field-path/format.d.ts +41 -0
  43. package/dist/core/field-path/format.js +154 -0
  44. package/dist/core/field-path/index.d.ts +14 -0
  45. package/dist/core/field-path/index.js +26 -0
  46. package/dist/core/field-path/utilities.d.ts +85 -0
  47. package/dist/core/field-path/utilities.js +138 -0
  48. package/dist/core/field-path/walk.d.ts +36 -0
  49. package/dist/core/field-path/walk.js +80 -0
  50. package/dist/core/fluent-registry.d.ts +138 -0
  51. package/dist/core/fluent-registry.js +151 -0
  52. package/dist/core/normalizers/array/compact-sparse-array.d.ts +22 -0
  53. package/dist/core/normalizers/array/compact-sparse-array.js +40 -0
  54. package/dist/core/normalizers/array/flatten-one-level.d.ts +17 -0
  55. package/dist/core/normalizers/array/flatten-one-level.js +45 -0
  56. package/dist/core/normalizers/array/remove-empty-string-items.d.ts +6 -0
  57. package/dist/core/normalizers/array/remove-empty-string-items.js +34 -0
  58. package/dist/core/normalizers/array/remove-null-items.d.ts +16 -0
  59. package/dist/core/normalizers/array/remove-null-items.js +34 -0
  60. package/dist/core/normalizers/array/remove-undefined-items.d.ts +16 -0
  61. package/dist/core/normalizers/array/remove-undefined-items.js +34 -0
  62. package/dist/core/normalizers/date/invalid-date-to-undefined.d.ts +17 -0
  63. package/dist/core/normalizers/date/invalid-date-to-undefined.js +35 -0
  64. package/dist/core/normalizers/index.d.ts +28 -0
  65. package/dist/core/normalizers/index.js +46 -0
  66. package/dist/core/normalizers/normalizer-register.d.ts +17 -0
  67. package/dist/core/normalizers/normalizer-register.js +41 -0
  68. package/dist/core/normalizers/number/infinity-to-undefined.d.ts +18 -0
  69. package/dist/core/normalizers/number/infinity-to-undefined.js +35 -0
  70. package/dist/core/normalizers/number/nan-to-undefined.d.ts +17 -0
  71. package/dist/core/normalizers/number/nan-to-undefined.js +34 -0
  72. package/dist/core/normalizers/number/normalize-negative-zero.d.ts +16 -0
  73. package/dist/core/normalizers/number/normalize-negative-zero.js +33 -0
  74. package/dist/core/normalizers/object/remove-empty-array-keys.d.ts +17 -0
  75. package/dist/core/normalizers/object/remove-empty-array-keys.js +38 -0
  76. package/dist/core/normalizers/object/remove-empty-object-keys.d.ts +16 -0
  77. package/dist/core/normalizers/object/remove-empty-object-keys.js +42 -0
  78. package/dist/core/normalizers/object/remove-empty-string-keys.d.ts +16 -0
  79. package/dist/core/normalizers/object/remove-empty-string-keys.js +37 -0
  80. package/dist/core/normalizers/object/remove-null-keys.d.ts +16 -0
  81. package/dist/core/normalizers/object/remove-null-keys.js +37 -0
  82. package/dist/core/normalizers/object/remove-undefined-keys.d.ts +16 -0
  83. package/dist/core/normalizers/object/remove-undefined-keys.js +37 -0
  84. package/dist/core/normalizers/string/collapse-whitespace.d.ts +17 -0
  85. package/dist/core/normalizers/string/collapse-whitespace.js +35 -0
  86. package/dist/core/normalizers/string/empty-to-undefined.d.ts +16 -0
  87. package/dist/core/normalizers/string/empty-to-undefined.js +33 -0
  88. package/dist/core/normalizers/string/trim.d.ts +16 -0
  89. package/dist/core/normalizers/string/trim.js +34 -0
  90. package/dist/core/parsers/index.d.ts +22 -0
  91. package/dist/core/parsers/index.js +43 -0
  92. package/dist/core/parsers/parse-array-string.d.ts +16 -0
  93. package/dist/core/parsers/parse-array-string.js +36 -0
  94. package/dist/core/parsers/parse-bigint-string.d.ts +16 -0
  95. package/dist/core/parsers/parse-bigint-string.js +33 -0
  96. package/dist/core/parsers/parse-binary-string.d.ts +16 -0
  97. package/dist/core/parsers/parse-binary-string.js +33 -0
  98. package/dist/core/parsers/parse-boolean-string.d.ts +16 -0
  99. package/dist/core/parsers/parse-boolean-string.js +27 -0
  100. package/dist/core/parsers/parse-date-string.d.ts +16 -0
  101. package/dist/core/parsers/parse-date-string.js +30 -0
  102. package/dist/core/parsers/parse-duration-string.d.ts +16 -0
  103. package/dist/core/parsers/parse-duration-string.js +37 -0
  104. package/dist/core/parsers/parse-hex-string.d.ts +16 -0
  105. package/dist/core/parsers/parse-hex-string.js +29 -0
  106. package/dist/core/parsers/parse-integer-string.d.ts +16 -0
  107. package/dist/core/parsers/parse-integer-string.js +30 -0
  108. package/dist/core/parsers/parse-json-string.d.ts +17 -0
  109. package/dist/core/parsers/parse-json-string.js +35 -0
  110. package/dist/core/parsers/parse-numeric-string.d.ts +16 -0
  111. package/dist/core/parsers/parse-numeric-string.js +29 -0
  112. package/dist/core/parsers/parse-object-string.d.ts +16 -0
  113. package/dist/core/parsers/parse-object-string.js +36 -0
  114. package/dist/core/parsers/parse-octal-string.d.ts +16 -0
  115. package/dist/core/parsers/parse-octal-string.js +33 -0
  116. package/dist/core/parsers/parse-scientific-notation-string.d.ts +16 -0
  117. package/dist/core/parsers/parse-scientific-notation-string.js +30 -0
  118. package/dist/core/parsers/parse-url-string.d.ts +16 -0
  119. package/dist/core/parsers/parse-url-string.js +36 -0
  120. package/dist/core/pipeline/boundary.d.ts +36 -0
  121. package/dist/core/pipeline/boundary.js +256 -0
  122. package/dist/core/pipeline/contain.d.ts +122 -0
  123. package/dist/core/pipeline/contain.js +339 -0
  124. package/dist/core/pipeline/index.d.ts +16 -0
  125. package/dist/core/pipeline/index.js +37 -0
  126. package/dist/core/pipeline/normalize.d.ts +34 -0
  127. package/dist/core/pipeline/normalize.js +76 -0
  128. package/dist/core/pipeline/parse.d.ts +40 -0
  129. package/dist/core/pipeline/parse.js +91 -0
  130. package/dist/core/pipeline/pipeline.d.ts +23 -0
  131. package/dist/core/pipeline/pipeline.js +418 -0
  132. package/dist/core/pipeline/scan.d.ts +46 -0
  133. package/dist/core/pipeline/scan.js +115 -0
  134. package/dist/core/pipeline/validate.d.ts +40 -0
  135. package/dist/core/pipeline/validate.js +74 -0
  136. package/dist/core/scanners/any/scan-for-sentinels.d.ts +19 -0
  137. package/dist/core/scanners/any/scan-for-sentinels.js +35 -0
  138. package/dist/core/scanners/array/array-is-deep.d.ts +19 -0
  139. package/dist/core/scanners/array/array-is-deep.js +38 -0
  140. package/dist/core/scanners/array/array-is-heterogenous.d.ts +18 -0
  141. package/dist/core/scanners/array/array-is-heterogenous.js +39 -0
  142. package/dist/core/scanners/array/array-is-large.d.ts +19 -0
  143. package/dist/core/scanners/array/array-is-large.js +32 -0
  144. package/dist/core/scanners/bigint/bigint-is-large.d.ts +20 -0
  145. package/dist/core/scanners/bigint/bigint-is-large.js +34 -0
  146. package/dist/core/scanners/bigint/bigint-not-safe.d.ts +20 -0
  147. package/dist/core/scanners/bigint/bigint-not-safe.js +34 -0
  148. package/dist/core/scanners/date/date-is-before-epoch.d.ts +19 -0
  149. package/dist/core/scanners/date/date-is-before-epoch.js +32 -0
  150. package/dist/core/scanners/date/date-is-far-future.d.ts +19 -0
  151. package/dist/core/scanners/date/date-is-far-future.js +32 -0
  152. package/dist/core/scanners/date/date-is-invalid.d.ts +19 -0
  153. package/dist/core/scanners/date/date-is-invalid.js +31 -0
  154. package/dist/core/scanners/index.d.ts +31 -0
  155. package/dist/core/scanners/index.js +58 -0
  156. package/dist/core/scanners/number/number-is-infinite.d.ts +19 -0
  157. package/dist/core/scanners/number/number-is-infinite.js +31 -0
  158. package/dist/core/scanners/number/number-is-nan.d.ts +19 -0
  159. package/dist/core/scanners/number/number-is-nan.js +31 -0
  160. package/dist/core/scanners/number/number-is-too-large.d.ts +20 -0
  161. package/dist/core/scanners/number/number-is-too-large.js +33 -0
  162. package/dist/core/scanners/number/number-is-unsafe-integer.d.ts +19 -0
  163. package/dist/core/scanners/number/number-is-unsafe-integer.js +31 -0
  164. package/dist/core/scanners/object/object-has-circular-references.d.ts +20 -0
  165. package/dist/core/scanners/object/object-has-circular-references.js +43 -0
  166. package/dist/core/scanners/object/object-has-many-keys.d.ts +19 -0
  167. package/dist/core/scanners/object/object-has-many-keys.js +33 -0
  168. package/dist/core/scanners/object/object-is-deep.d.ts +20 -0
  169. package/dist/core/scanners/object/object-is-deep.js +38 -0
  170. package/dist/core/scanners/scanner-registry.d.ts +19 -0
  171. package/dist/core/scanners/scanner-registry.js +36 -0
  172. package/dist/core/scanners/string/string-has-unsafe-unicode.d.ts +19 -0
  173. package/dist/core/scanners/string/string-has-unsafe-unicode.js +32 -0
  174. package/dist/core/scanners/string/string-has-whitespace-edges.d.ts +19 -0
  175. package/dist/core/scanners/string/string-has-whitespace-edges.js +31 -0
  176. package/dist/core/scanners/string/string-is-long.d.ts +19 -0
  177. package/dist/core/scanners/string/string-is-long.js +32 -0
  178. package/dist/core/scanners/unknown/unknown-not-scannable.d.ts +21 -0
  179. package/dist/core/scanners/unknown/unknown-not-scannable.js +34 -0
  180. package/dist/core/shapes/analysis.d.ts +239 -0
  181. package/dist/core/shapes/analysis.js +11 -0
  182. package/dist/core/shapes/boundary.d.ts +126 -0
  183. package/dist/core/shapes/boundary.js +11 -0
  184. package/dist/core/shapes/events.d.ts +83 -0
  185. package/dist/core/shapes/events.js +10 -0
  186. package/dist/core/shapes/field-path.d.ts +51 -0
  187. package/dist/core/shapes/field-path.js +10 -0
  188. package/dist/core/shapes/index.d.ts +21 -0
  189. package/dist/core/shapes/index.js +11 -0
  190. package/dist/core/shapes/normalize.d.ts +59 -0
  191. package/dist/core/shapes/normalize.js +11 -0
  192. package/dist/core/shapes/parse.d.ts +75 -0
  193. package/dist/core/shapes/parse.js +11 -0
  194. package/dist/core/shapes/pipeline.d.ts +149 -0
  195. package/dist/core/shapes/pipeline.js +11 -0
  196. package/dist/core/shapes/policy.d.ts +158 -0
  197. package/dist/core/shapes/policy.js +11 -0
  198. package/dist/core/shapes/public.d.ts +92 -0
  199. package/dist/core/shapes/public.js +10 -0
  200. package/dist/core/shapes/scan.d.ts +126 -0
  201. package/dist/core/shapes/scan.js +11 -0
  202. package/dist/core/shapes/validate.d.ts +65 -0
  203. package/dist/core/shapes/validate.js +11 -0
  204. package/dist/core/validators/array/array-max-items.d.ts +25 -0
  205. package/dist/core/validators/array/array-max-items.js +42 -0
  206. package/dist/core/validators/array/array-min-items.d.ts +25 -0
  207. package/dist/core/validators/array/array-min-items.js +42 -0
  208. package/dist/core/validators/array/array.d.ts +22 -0
  209. package/dist/core/validators/array/array.js +34 -0
  210. package/dist/core/validators/array/excludes.d.ts +25 -0
  211. package/dist/core/validators/array/excludes.js +47 -0
  212. package/dist/core/validators/array/has-unique-items.d.ts +24 -0
  213. package/dist/core/validators/array/has-unique-items.js +46 -0
  214. package/dist/core/validators/array/includes.d.ts +24 -0
  215. package/dist/core/validators/array/includes.js +46 -0
  216. package/dist/core/validators/array/items-equal.d.ts +25 -0
  217. package/dist/core/validators/array/items-equal.js +42 -0
  218. package/dist/core/validators/array/no-empty-string-items.d.ts +24 -0
  219. package/dist/core/validators/array/no-empty-string-items.js +46 -0
  220. package/dist/core/validators/array/no-null-items.d.ts +24 -0
  221. package/dist/core/validators/array/no-null-items.js +46 -0
  222. package/dist/core/validators/array/no-undefined-items.d.ts +24 -0
  223. package/dist/core/validators/array/no-undefined-items.js +45 -0
  224. package/dist/core/validators/array/non-empty-array.d.ts +24 -0
  225. package/dist/core/validators/array/non-empty-array.js +45 -0
  226. package/dist/core/validators/array/not-sparse.d.ts +25 -0
  227. package/dist/core/validators/array/not-sparse.js +44 -0
  228. package/dist/core/validators/bigint/bigint-equals.d.ts +24 -0
  229. package/dist/core/validators/bigint/bigint-equals.js +57 -0
  230. package/dist/core/validators/bigint/bigint-max.d.ts +25 -0
  231. package/dist/core/validators/bigint/bigint-max.js +63 -0
  232. package/dist/core/validators/bigint/bigint-min.d.ts +25 -0
  233. package/dist/core/validators/bigint/bigint-min.js +87 -0
  234. package/dist/core/validators/bigint/bigint-negative.d.ts +23 -0
  235. package/dist/core/validators/bigint/bigint-negative.js +73 -0
  236. package/dist/core/validators/bigint/bigint-non-negative.d.ts +24 -0
  237. package/dist/core/validators/bigint/bigint-non-negative.js +72 -0
  238. package/dist/core/validators/bigint/bigint-non-positive.d.ts +24 -0
  239. package/dist/core/validators/bigint/bigint-non-positive.js +72 -0
  240. package/dist/core/validators/bigint/bigint-positive.d.ts +24 -0
  241. package/dist/core/validators/bigint/bigint-positive.js +72 -0
  242. package/dist/core/validators/bigint/bigint-safe.d.ts +25 -0
  243. package/dist/core/validators/bigint/bigint-safe.js +75 -0
  244. package/dist/core/validators/bigint/bigint.d.ts +20 -0
  245. package/dist/core/validators/bigint/bigint.js +38 -0
  246. package/dist/core/validators/boolean/boolean.d.ts +21 -0
  247. package/dist/core/validators/boolean/boolean.js +39 -0
  248. package/dist/core/validators/boolean/is-false.d.ts +22 -0
  249. package/dist/core/validators/boolean/is-false.js +48 -0
  250. package/dist/core/validators/boolean/is-true.d.ts +22 -0
  251. package/dist/core/validators/boolean/is-true.js +48 -0
  252. package/dist/core/validators/common/is-country-code.d.ts +17 -0
  253. package/dist/core/validators/common/is-country-code.js +36 -0
  254. package/dist/core/validators/common/is-currency-code.d.ts +17 -0
  255. package/dist/core/validators/common/is-currency-code.js +36 -0
  256. package/dist/core/validators/common/is-email-strict.d.ts +17 -0
  257. package/dist/core/validators/common/is-email-strict.js +36 -0
  258. package/dist/core/validators/common/is-email.d.ts +17 -0
  259. package/dist/core/validators/common/is-email.js +36 -0
  260. package/dist/core/validators/common/is-ip.d.ts +17 -0
  261. package/dist/core/validators/common/is-ip.js +37 -0
  262. package/dist/core/validators/common/is-phone-strict.d.ts +17 -0
  263. package/dist/core/validators/common/is-phone-strict.js +36 -0
  264. package/dist/core/validators/common/is-phone.d.ts +17 -0
  265. package/dist/core/validators/common/is-phone.js +36 -0
  266. package/dist/core/validators/common/is-port.d.ts +17 -0
  267. package/dist/core/validators/common/is-port.js +35 -0
  268. package/dist/core/validators/common/is-postal-code.d.ts +17 -0
  269. package/dist/core/validators/common/is-postal-code.js +36 -0
  270. package/dist/core/validators/common/is-url.d.ts +17 -0
  271. package/dist/core/validators/common/is-url.js +38 -0
  272. package/dist/core/validators/common/is-uuid.d.ts +17 -0
  273. package/dist/core/validators/common/is-uuid.js +36 -0
  274. package/dist/core/validators/date/before-epoch.d.ts +28 -0
  275. package/dist/core/validators/date/before-epoch.js +56 -0
  276. package/dist/core/validators/date/date-now-required.d.ts +22 -0
  277. package/dist/core/validators/date/date-now-required.js +48 -0
  278. package/dist/core/validators/date/is-date.d.ts +21 -0
  279. package/dist/core/validators/date/is-date.js +47 -0
  280. package/dist/core/validators/date/is-far-future.d.ts +23 -0
  281. package/dist/core/validators/date/is-far-future.js +46 -0
  282. package/dist/core/validators/date/is-future.d.ts +24 -0
  283. package/dist/core/validators/date/is-future.js +59 -0
  284. package/dist/core/validators/date/is-past.d.ts +24 -0
  285. package/dist/core/validators/date/is-past.js +59 -0
  286. package/dist/core/validators/date/not-after.d.ts +25 -0
  287. package/dist/core/validators/date/not-after.js +66 -0
  288. package/dist/core/validators/date/not-before.d.ts +25 -0
  289. package/dist/core/validators/date/not-before.js +66 -0
  290. package/dist/core/validators/date/same-day.d.ts +25 -0
  291. package/dist/core/validators/date/same-day.js +60 -0
  292. package/dist/core/validators/date/same-month.d.ts +25 -0
  293. package/dist/core/validators/date/same-month.js +59 -0
  294. package/dist/core/validators/date/same-year.d.ts +24 -0
  295. package/dist/core/validators/date/same-year.js +56 -0
  296. package/dist/core/validators/date/too-early.d.ts +25 -0
  297. package/dist/core/validators/date/too-early.js +57 -0
  298. package/dist/core/validators/date/too-late.d.ts +25 -0
  299. package/dist/core/validators/date/too-late.js +57 -0
  300. package/dist/core/validators/date/weekday.d.ts +32 -0
  301. package/dist/core/validators/date/weekday.js +65 -0
  302. package/dist/core/validators/date/weekend.d.ts +27 -0
  303. package/dist/core/validators/date/weekend.js +56 -0
  304. package/dist/core/validators/index.d.ts +112 -0
  305. package/dist/core/validators/index.js +139 -0
  306. package/dist/core/validators/nullish/is-null-or-undefined.d.ts +22 -0
  307. package/dist/core/validators/nullish/is-null-or-undefined.js +40 -0
  308. package/dist/core/validators/nullish/is-null.d.ts +21 -0
  309. package/dist/core/validators/nullish/is-null.js +39 -0
  310. package/dist/core/validators/nullish/is-undefined.d.ts +21 -0
  311. package/dist/core/validators/nullish/is-undefined.js +39 -0
  312. package/dist/core/validators/number/finite.d.ts +22 -0
  313. package/dist/core/validators/number/finite.js +40 -0
  314. package/dist/core/validators/number/integer.d.ts +22 -0
  315. package/dist/core/validators/number/integer.js +40 -0
  316. package/dist/core/validators/number/less-than.d.ts +21 -0
  317. package/dist/core/validators/number/less-than.js +39 -0
  318. package/dist/core/validators/number/max.d.ts +21 -0
  319. package/dist/core/validators/number/max.js +39 -0
  320. package/dist/core/validators/number/min.d.ts +21 -0
  321. package/dist/core/validators/number/min.js +39 -0
  322. package/dist/core/validators/number/more-than.d.ts +21 -0
  323. package/dist/core/validators/number/more-than.js +39 -0
  324. package/dist/core/validators/number/negative.d.ts +20 -0
  325. package/dist/core/validators/number/negative.js +38 -0
  326. package/dist/core/validators/number/non-negative.d.ts +19 -0
  327. package/dist/core/validators/number/non-negative.js +37 -0
  328. package/dist/core/validators/number/non-positive.d.ts +19 -0
  329. package/dist/core/validators/number/non-positive.js +37 -0
  330. package/dist/core/validators/number/number.d.ts +19 -0
  331. package/dist/core/validators/number/number.js +31 -0
  332. package/dist/core/validators/number/positive.d.ts +20 -0
  333. package/dist/core/validators/number/positive.js +38 -0
  334. package/dist/core/validators/number/safe-integer.d.ts +19 -0
  335. package/dist/core/validators/number/safe-integer.js +42 -0
  336. package/dist/core/validators/object/deep-equals.d.ts +24 -0
  337. package/dist/core/validators/object/deep-equals.js +47 -0
  338. package/dist/core/validators/object/has-key.d.ts +23 -0
  339. package/dist/core/validators/object/has-key.js +42 -0
  340. package/dist/core/validators/object/has-value.d.ts +27 -0
  341. package/dist/core/validators/object/has-value.js +59 -0
  342. package/dist/core/validators/object/keys-equal.d.ts +26 -0
  343. package/dist/core/validators/object/keys-equal.js +47 -0
  344. package/dist/core/validators/object/max-keys.d.ts +24 -0
  345. package/dist/core/validators/object/max-keys.js +43 -0
  346. package/dist/core/validators/object/min-keys.d.ts +24 -0
  347. package/dist/core/validators/object/min-keys.js +43 -0
  348. package/dist/core/validators/object/missing-key.d.ts +23 -0
  349. package/dist/core/validators/object/missing-key.js +42 -0
  350. package/dist/core/validators/object/no-empty-array-values.d.ts +23 -0
  351. package/dist/core/validators/object/no-empty-array-values.js +44 -0
  352. package/dist/core/validators/object/no-empty-object-values.d.ts +23 -0
  353. package/dist/core/validators/object/no-empty-object-values.js +44 -0
  354. package/dist/core/validators/object/no-null-values.d.ts +23 -0
  355. package/dist/core/validators/object/no-null-values.js +44 -0
  356. package/dist/core/validators/object/no-undefined-values.d.ts +23 -0
  357. package/dist/core/validators/object/no-undefined-values.js +44 -0
  358. package/dist/core/validators/object/non-empty-object.d.ts +21 -0
  359. package/dist/core/validators/object/non-empty-object.js +40 -0
  360. package/dist/core/validators/object/only-keys.d.ts +23 -0
  361. package/dist/core/validators/object/only-keys.js +43 -0
  362. package/dist/core/validators/object/plain-object.d.ts +22 -0
  363. package/dist/core/validators/object/plain-object.js +35 -0
  364. package/dist/core/validators/string/alpha-num.d.ts +23 -0
  365. package/dist/core/validators/string/alpha-num.js +50 -0
  366. package/dist/core/validators/string/alpha.d.ts +24 -0
  367. package/dist/core/validators/string/alpha.js +51 -0
  368. package/dist/core/validators/string/chars-equal.d.ts +23 -0
  369. package/dist/core/validators/string/chars-equal.js +49 -0
  370. package/dist/core/validators/string/ends-with.d.ts +23 -0
  371. package/dist/core/validators/string/ends-with.js +50 -0
  372. package/dist/core/validators/string/is-ascii.d.ts +24 -0
  373. package/dist/core/validators/string/is-ascii.js +53 -0
  374. package/dist/core/validators/string/is-printable.d.ts +25 -0
  375. package/dist/core/validators/string/is-printable.js +53 -0
  376. package/dist/core/validators/string/matches.d.ts +23 -0
  377. package/dist/core/validators/string/matches.js +50 -0
  378. package/dist/core/validators/string/max-length.d.ts +24 -0
  379. package/dist/core/validators/string/max-length.js +50 -0
  380. package/dist/core/validators/string/min-length.d.ts +24 -0
  381. package/dist/core/validators/string/min-length.js +50 -0
  382. package/dist/core/validators/string/no-lead-space.d.ts +23 -0
  383. package/dist/core/validators/string/no-lead-space.js +50 -0
  384. package/dist/core/validators/string/no-repeat-space.d.ts +25 -0
  385. package/dist/core/validators/string/no-repeat-space.js +52 -0
  386. package/dist/core/validators/string/no-space.d.ts +24 -0
  387. package/dist/core/validators/string/no-space.js +51 -0
  388. package/dist/core/validators/string/no-trail-space.d.ts +23 -0
  389. package/dist/core/validators/string/no-trail-space.js +50 -0
  390. package/dist/core/validators/string/non-empty.d.ts +22 -0
  391. package/dist/core/validators/string/non-empty.js +48 -0
  392. package/dist/core/validators/string/not-one-of.d.ts +24 -0
  393. package/dist/core/validators/string/not-one-of.js +51 -0
  394. package/dist/core/validators/string/num-string.d.ts +23 -0
  395. package/dist/core/validators/string/num-string.js +50 -0
  396. package/dist/core/validators/string/one-of.d.ts +23 -0
  397. package/dist/core/validators/string/one-of.js +50 -0
  398. package/dist/core/validators/string/starts-with.d.ts +23 -0
  399. package/dist/core/validators/string/starts-with.js +50 -0
  400. package/dist/core/validators/string/string.d.ts +21 -0
  401. package/dist/core/validators/string/string.js +39 -0
  402. package/dist/core/validators/string/trimmed.d.ts +24 -0
  403. package/dist/core/validators/string/trimmed.js +51 -0
  404. package/dist/index.d.ts +83 -0
  405. package/dist/index.js +26 -0
  406. package/dist/test.d.ts +1 -0
  407. package/dist/test.js +12 -0
  408. package/package.json +2 -2
@@ -0,0 +1,126 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Shapes | Scan
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Shapes that define how raw input is inspected and converted
7
+ * into safe JSON‑like form.
8
+ * @see https://jane-io.com
9
+ * ----------------------------------------------------------------------------
10
+ */
11
+ import type { FieldPath, JaneEvent, Policy } from '.';
12
+ /**
13
+ * Execution context for containment.
14
+ *
15
+ * Holds structural limits, a cycle‑detection map, and the active policy.
16
+ * Used by containment routines to enforce depth and size limits while
17
+ * producing safe, JSON‑like representations of arbitrary input.
18
+ */
19
+ export interface ContainmentContext {
20
+ readonly options: ContainmentOptions;
21
+ readonly seen: WeakMap<object, unknown>;
22
+ readonly policy: Policy;
23
+ }
24
+ /**
25
+ * Structural limits applied during containment.
26
+ *
27
+ * These bounds prevent unbounded recursion and excessive traversal by
28
+ * capping depth, array length, and object key count.
29
+ */
30
+ export interface ContainmentOptions {
31
+ readonly maxDepth: number;
32
+ readonly maxArrayLength: number;
33
+ readonly maxObjectKeys: number;
34
+ }
35
+ /**
36
+ * A JSON‑like object used internally during containment.
37
+ *
38
+ * Keys are plain strings and values are restricted to InternalJsonValue,
39
+ * ensuring the structure is safe, serializable, and cycle‑free.
40
+ */
41
+ export type InternalJsonObject = {
42
+ [key: string]: InternalJsonValue;
43
+ };
44
+ /**
45
+ * A JSON‑like array used internally during containment.
46
+ *
47
+ * Elements are restricted to InternalJsonValue to guarantee safe,
48
+ * serializable structure throughout the pipeline.
49
+ */
50
+ export type InternalJsonArray = InternalJsonValue[];
51
+ /**
52
+ * The full set of values allowed inside internal JSON structures.
53
+ *
54
+ * Extends standard JSON with `undefined` to support partial containment
55
+ * and sentinel values during scanning and normalization.
56
+ */
57
+ export type InternalJsonValue = string | number | boolean | null | InternalJsonArray | InternalJsonObject | undefined;
58
+ /**
59
+ * A strict JSON‑serializable value.
60
+ *
61
+ * Used for public surfaces and output shapes where only standard JSON
62
+ * types are permitted.
63
+ */
64
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
65
+ [key: string]: JsonValue;
66
+ };
67
+ /**
68
+ * A function that executes the scan stage.
69
+ *
70
+ * Receives a ScanStageContext and returns a ScanStageOutput, allowing
71
+ * pipelines to plug in custom scanning behavior.
72
+ */
73
+ export type ScanRule = (raw: unknown, path: FieldPath) => readonly JaneEvent[];
74
+ /**
75
+ * Groups scan rules by structural type.
76
+ *
77
+ * The scanner selects rules from these buckets based on the detected
78
+ * StructuralType, while `all` contains rules applied universally.
79
+ */
80
+ export interface ScanRuleSet {
81
+ readonly all: readonly ScanRule[];
82
+ readonly string: readonly ScanRule[];
83
+ readonly number: readonly ScanRule[];
84
+ readonly boolean: readonly ScanRule[];
85
+ readonly array: readonly ScanRule[];
86
+ readonly object: readonly ScanRule[];
87
+ readonly date: readonly ScanRule[];
88
+ readonly unknown: readonly ScanRule[];
89
+ readonly bigint: readonly ScanRule[];
90
+ }
91
+ /**
92
+ * Executes the scan stage.
93
+ *
94
+ * Accepts a ScanStageContext and returns a ScanStageOutput, allowing
95
+ * pipelines to plug in custom scanning behavior.
96
+ */
97
+ export type ScanRunner = (input: ScanStageContext) => Promise<ScanStageOutput>;
98
+ /**
99
+ * Input to a scan stage execution.
100
+ *
101
+ * Provides the raw value, its current path, the active scan rules,
102
+ * and the policy controlling how events are interpreted.
103
+ */
104
+ export interface ScanStageContext {
105
+ readonly raw: unknown;
106
+ readonly path?: FieldPath;
107
+ readonly rules: readonly ScanRule[];
108
+ readonly policy: Policy;
109
+ }
110
+ /**
111
+ * Output produced by the scan stage.
112
+ *
113
+ * Contains all emitted scan events and the safe, JSON‑like value
114
+ * derived from the raw input.
115
+ */
116
+ export interface ScanStageOutput {
117
+ readonly events: readonly JaneEvent[];
118
+ readonly safe: InternalJsonValue;
119
+ }
120
+ /**
121
+ * The structural categories recognized by the scanner.
122
+ *
123
+ * Used to select scan rules and classify raw input without relying
124
+ * on user‑defined types or schema information.
125
+ */
126
+ export type StructuralType = 'string' | 'number' | 'boolean' | 'array' | 'object' | 'date' | 'bigint' | 'unknown';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Shapes | Scan
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Shapes that define how raw input is inspected and converted
7
+ * into safe JSON‑like form.
8
+ * @see https://jane-io.com
9
+ * ----------------------------------------------------------------------------
10
+ */
11
+ export {};
@@ -0,0 +1,65 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Shapes | Validate
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Shapes that define rule‑driven correctness checks during
7
+ * validation.
8
+ * @see https://jane-io.com
9
+ * ----------------------------------------------------------------------------
10
+ */
11
+ import type { FieldPath, JaneEvent, PipelineBuilder } from '.';
12
+ import type { janeRegistry } from '../fluent-registry';
13
+ /**
14
+ * A factory that produces a validation rule.
15
+ *
16
+ * Used by registry‑backed fluent APIs to create parameterized validators
17
+ * from user‑supplied arguments.
18
+ */
19
+ export type ValidatorFactory = (...args: unknown[]) => ValidationRule;
20
+ /**
21
+ * A fluent validator entry for a named validator in the registry.
22
+ *
23
+ * If the registry entry is a factory, exposes its parameters and returns
24
+ * a PipelineBuilder. Otherwise, returns a PipelineBuilder directly.
25
+ */
26
+ export type ValidatorFactoryRule<Name extends ValidatorName> = (typeof janeRegistry.validators)[Name] extends ValidatorFactory ? (...args: Parameters<(typeof janeRegistry.validators)[Name]>) => PipelineBuilder : PipelineBuilder;
27
+ /**
28
+ * The fluent rule type for any validator registered in Jane.
29
+ *
30
+ * Represents either a zero‑argument validator or a parameterized factory,
31
+ * depending on the registry entry.
32
+ */
33
+ export type ValidatorFluentRule = (typeof janeRegistry.validators)[ValidatorName];
34
+ /**
35
+ * The set of validator names registered in Jane.
36
+ *
37
+ * Used to index validator factories and fluent rules in the registry.
38
+ */
39
+ export type ValidatorName = keyof typeof janeRegistry.validators;
40
+ /**
41
+ * A validation rule that inspects a value and emits correctness events.
42
+ *
43
+ * Rules return zero or more JaneEvent entries describing issues found at
44
+ * the given path.
45
+ */
46
+ export type ValidationRule = (value: unknown, path: FieldPath) => readonly JaneEvent[] | Promise<readonly JaneEvent[]>;
47
+ /**
48
+ * Input to a validation stage execution.
49
+ *
50
+ * Provides the normalized value, its current path, and the active
51
+ * validation rules.
52
+ */
53
+ export interface ValidationStageContext {
54
+ readonly value: unknown;
55
+ readonly path?: FieldPath;
56
+ readonly rules: readonly ValidationRule[];
57
+ }
58
+ /**
59
+ * Output produced by the validation stage.
60
+ *
61
+ * Contains all correctness‑related events emitted by the active rules.
62
+ */
63
+ export interface ValidationStageOutput {
64
+ readonly events: readonly JaneEvent[];
65
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Shapes | Validate
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Shapes that define rule‑driven correctness checks during
7
+ * validation.
8
+ * @see https://jane-io.com
9
+ * ----------------------------------------------------------------------------
10
+ */
11
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Array Maximum Items (Array Max Items)
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that an array does not exceed a maximum number of
7
+ * items.
8
+ * @see https://jane-io.com
9
+ * ----------------------------------------------------------------------------
10
+ */
11
+ import type { ValidationRule } from '../../shapes';
12
+ /**
13
+ * Validate that an array does not exceed a maximum number of items.
14
+ *
15
+ * This rule checks:
16
+ * - The value is structurally an array
17
+ * - The array length is less than or equal to the provided maximum
18
+ *
19
+ * Emits:
20
+ * - array.not.array
21
+ * - array.too.long
22
+ *
23
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
24
+ */
25
+ export declare const arrayMaxItems: (max: number) => ValidationRule;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Array Maximum Items (Array Max Items)
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that an array does not exceed a maximum number of
7
+ * items.
8
+ * @see https://jane-io.com
9
+ * ----------------------------------------------------------------------------
10
+ */
11
+ import { validationEvent } from '../../pipeline';
12
+ import { detectStructuralType } from '../../pipeline/scan';
13
+ /* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
14
+ |* Implementation *|
15
+ \* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
16
+ /**
17
+ * Validate that an array does not exceed a maximum number of items.
18
+ *
19
+ * This rule checks:
20
+ * - The value is structurally an array
21
+ * - The array length is less than or equal to the provided maximum
22
+ *
23
+ * Emits:
24
+ * - array.not.array
25
+ * - array.too.long
26
+ *
27
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
28
+ */
29
+ export const arrayMaxItems = (max) => async (value, path) => {
30
+ const structuralType = detectStructuralType(value);
31
+ if (!Array.isArray(value)) {
32
+ return [
33
+ validationEvent('error', 'array.not.array', path, `Expected 'array' but received '${structuralType}'.`, `Please provide a valid array.`, { value, expected: 'array', actual: structuralType }),
34
+ ];
35
+ }
36
+ if (value.length > max) {
37
+ return [
38
+ validationEvent('error', 'array.too.long', path, `Array length ${value.length} must be ≤ ${max}.`, `Please provide no more than ${max} items.`, { value, expected: `≤ ${max}`, actual: value.length }),
39
+ ];
40
+ }
41
+ return [];
42
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Array Minimum Items (Array Min Items)
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that an array contains at least a minimum number of
7
+ * items.
8
+ * @see https://jane-io.com
9
+ * ----------------------------------------------------------------------------
10
+ */
11
+ import type { ValidationRule } from '../../shapes';
12
+ /**
13
+ * Validate that an array contains at least a minimum number of items.
14
+ *
15
+ * This rule checks:
16
+ * - The value is structurally an array
17
+ * - The array length is greater than or equal to the provided minimum
18
+ *
19
+ * Emits:
20
+ * - array.not.array
21
+ * - array.too.short
22
+ *
23
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
24
+ */
25
+ export declare const arrayMinItems: (min: number) => ValidationRule;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Array Minimum Items (Array Min Items)
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that an array contains at least a minimum number of
7
+ * items.
8
+ * @see https://jane-io.com
9
+ * ----------------------------------------------------------------------------
10
+ */
11
+ import { validationEvent } from '../../pipeline';
12
+ import { detectStructuralType } from '../../pipeline/scan';
13
+ /* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
14
+ |* Implementation *|
15
+ \* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
16
+ /**
17
+ * Validate that an array contains at least a minimum number of items.
18
+ *
19
+ * This rule checks:
20
+ * - The value is structurally an array
21
+ * - The array length is greater than or equal to the provided minimum
22
+ *
23
+ * Emits:
24
+ * - array.not.array
25
+ * - array.too.short
26
+ *
27
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
28
+ */
29
+ export const arrayMinItems = (min) => async (value, path) => {
30
+ const structuralType = detectStructuralType(value);
31
+ if (!Array.isArray(value)) {
32
+ return [
33
+ validationEvent('error', 'array.not.array', path, `Expected 'array' but received '${structuralType}'.`, `Please provide a valid array.`, { value, expected: 'array', actual: structuralType }),
34
+ ];
35
+ }
36
+ if (value.length < min) {
37
+ return [
38
+ validationEvent('error', 'array.too.short', path, `Array length ${value.length} must be ≥ ${min}.`, `Please provide at least ${min} items.`, { value, expected: `≥ ${min}`, actual: value.length }),
39
+ ];
40
+ }
41
+ return [];
42
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Array
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that a value is structurally an array.
7
+ * @see https://jane-io.com
8
+ * ----------------------------------------------------------------------------
9
+ */
10
+ import type { ValidationRule } from '../../shapes';
11
+ /**
12
+ * Validate that a value is structurally an array.
13
+ *
14
+ * This rule checks:
15
+ * - The value is an array according to JavaScript semantics
16
+ *
17
+ * Emits:
18
+ * - array.not.array
19
+ *
20
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
21
+ */
22
+ export declare const array: ValidationRule;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Array
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that a value is structurally an array.
7
+ * @see https://jane-io.com
8
+ * ----------------------------------------------------------------------------
9
+ */
10
+ import { validationEvent } from '../../pipeline';
11
+ import { detectStructuralType } from '../../pipeline/scan';
12
+ /* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
13
+ |* Implementation *|
14
+ \* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
15
+ /**
16
+ * Validate that a value is structurally an array.
17
+ *
18
+ * This rule checks:
19
+ * - The value is an array according to JavaScript semantics
20
+ *
21
+ * Emits:
22
+ * - array.not.array
23
+ *
24
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
25
+ */
26
+ export const array = async (value, path) => {
27
+ const structuralType = detectStructuralType(value);
28
+ if (!Array.isArray(value)) {
29
+ return [
30
+ validationEvent('error', 'array.not.array', path, `Expected 'array' but received '${structuralType}'.`, `Please provide a valid array.`, { value, expected: 'array', actual: structuralType }),
31
+ ];
32
+ }
33
+ return [];
34
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Excludes
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that an array does not include a specific
7
+ * disallowed item.
8
+ * @see https://jane-io.com
9
+ * ----------------------------------------------------------------------------
10
+ */
11
+ import type { ValidationRule } from '../../shapes';
12
+ /**
13
+ * Validate that an array does not include a specific disallowed item.
14
+ *
15
+ * This rule checks:
16
+ * - The value is structurally an array
17
+ * - The array does not contain the provided item (using Array.prototype.includes)
18
+ *
19
+ * Emits:
20
+ * - array.not.array
21
+ * - array.has.invalid-value
22
+ *
23
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
24
+ */
25
+ export declare const excludes: (item: unknown) => ValidationRule;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Excludes
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that an array does not include a specific
7
+ * disallowed item.
8
+ * @see https://jane-io.com
9
+ * ----------------------------------------------------------------------------
10
+ */
11
+ import { validationEvent } from '../../pipeline';
12
+ import { safeStringify } from '../../common';
13
+ import { detectStructuralType } from '../../pipeline/scan';
14
+ /* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
15
+ |* Implementation *|
16
+ \* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
17
+ /**
18
+ * Validate that an array does not include a specific disallowed item.
19
+ *
20
+ * This rule checks:
21
+ * - The value is structurally an array
22
+ * - The array does not contain the provided item (using Array.prototype.includes)
23
+ *
24
+ * Emits:
25
+ * - array.not.array
26
+ * - array.has.invalid-value
27
+ *
28
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
29
+ */
30
+ export const excludes = (item) => async (value, path) => {
31
+ const structuralType = detectStructuralType(value);
32
+ if (!Array.isArray(value)) {
33
+ return [
34
+ validationEvent('error', 'array.not.array', path, `Expected 'array' but received '${structuralType}'.`, `Please provide a valid array.`, { value, expected: 'array', actual: structuralType }),
35
+ ];
36
+ }
37
+ if (value.includes(item)) {
38
+ return [
39
+ validationEvent('error', 'array.has.invalid-value', path, `Array must not include ${safeStringify(item)}.`, `Please remove the disallowed item.`, {
40
+ value,
41
+ expected: `exclude ${safeStringify(item)}`,
42
+ actual: value,
43
+ }),
44
+ ];
45
+ }
46
+ return [];
47
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Has Unique Items
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that an array contains only unique items.
7
+ * @see https://jane-io.com
8
+ * ----------------------------------------------------------------------------
9
+ */
10
+ import type { ValidationRule } from '../../shapes';
11
+ /**
12
+ * Validate that an array contains only unique items.
13
+ *
14
+ * This rule checks:
15
+ * - The value is structurally an array
16
+ * - The array does not contain duplicate items (using reference and value equality via Set)
17
+ *
18
+ * Emits:
19
+ * - array.not.array
20
+ * - array.not.unique
21
+ *
22
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
23
+ */
24
+ export declare const hasUniqueItems: ValidationRule;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Has Unique Items
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that an array contains only unique items.
7
+ * @see https://jane-io.com
8
+ * ----------------------------------------------------------------------------
9
+ */
10
+ import { validationEvent } from '../../pipeline';
11
+ import { detectStructuralType } from '../../pipeline/scan';
12
+ /* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
13
+ |* Implementation *|
14
+ \* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
15
+ /**
16
+ * Validate that an array contains only unique items.
17
+ *
18
+ * This rule checks:
19
+ * - The value is structurally an array
20
+ * - The array does not contain duplicate items (using reference and value equality via Set)
21
+ *
22
+ * Emits:
23
+ * - array.not.array
24
+ * - array.not.unique
25
+ *
26
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
27
+ */
28
+ export const hasUniqueItems = async (value, path) => {
29
+ const structuralType = detectStructuralType(value);
30
+ if (!Array.isArray(value)) {
31
+ return [
32
+ validationEvent('error', 'array.not.array', path, `Expected 'array' but received '${structuralType}'.`, `Please provide a valid array.`, { value, expected: 'array', actual: structuralType }),
33
+ ];
34
+ }
35
+ const uniqueSet = new Set(value);
36
+ if (uniqueSet.size !== value.length) {
37
+ return [
38
+ validationEvent('error', 'array.not.unique', path, `Array must contain only unique items.`, `Please remove duplicate items.`, {
39
+ value,
40
+ expected: 'unique items',
41
+ actual: 'duplicates found',
42
+ }),
43
+ ];
44
+ }
45
+ return [];
46
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Includes
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that an array includes a specific required item.
7
+ * @see https://jane-io.com
8
+ * ----------------------------------------------------------------------------
9
+ */
10
+ import type { ValidationRule } from '../../shapes';
11
+ /**
12
+ * Validate that an array includes a specific required item.
13
+ *
14
+ * This rule checks:
15
+ * - The value is structurally an array
16
+ * - The array contains the provided item (using Array.prototype.includes)
17
+ *
18
+ * Emits:
19
+ * - array.not.array
20
+ * - array.is.missing-value
21
+ *
22
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
23
+ */
24
+ export declare const includes: (item: unknown) => ValidationRule;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Includes
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that an array includes a specific required item.
7
+ * @see https://jane-io.com
8
+ * ----------------------------------------------------------------------------
9
+ */
10
+ import { validationEvent } from '../../pipeline';
11
+ import { safeStringify } from '../../common';
12
+ import { detectStructuralType } from '../../pipeline/scan';
13
+ /* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
14
+ |* Implementation *|
15
+ \* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
16
+ /**
17
+ * Validate that an array includes a specific required item.
18
+ *
19
+ * This rule checks:
20
+ * - The value is structurally an array
21
+ * - The array contains the provided item (using Array.prototype.includes)
22
+ *
23
+ * Emits:
24
+ * - array.not.array
25
+ * - array.is.missing-value
26
+ *
27
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
28
+ */
29
+ export const includes = (item) => async (value, path) => {
30
+ const structuralType = detectStructuralType(value);
31
+ if (!Array.isArray(value)) {
32
+ return [
33
+ validationEvent('error', 'array.not.array', path, `Expected 'array' but received '${structuralType}'.`, `Please provide a valid array.`, { value, expected: 'array', actual: structuralType }),
34
+ ];
35
+ }
36
+ if (!value.includes(item)) {
37
+ return [
38
+ validationEvent('error', 'array.is.missing-value', path, `Array must include ${safeStringify(item)}.`, `Please include the required item.`, {
39
+ value,
40
+ expected: `includes ${safeStringify(item)}`,
41
+ actual: value,
42
+ }),
43
+ ];
44
+ }
45
+ return [];
46
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Validators | Items Equal
4
+ * ----------------------------------------------------------------------------
5
+ * @package @clementine-solutions/jane
6
+ * @description Validate that an array contains exactly the specified
7
+ * number of items.
8
+ * @see https://jane-io.com
9
+ * ----------------------------------------------------------------------------
10
+ */
11
+ import type { ValidationRule } from '../../shapes';
12
+ /**
13
+ * Validate that an array contains exactly the specified number of items.
14
+ *
15
+ * This rule checks:
16
+ * - The value is structurally an array
17
+ * - The array length matches the exact required count
18
+ *
19
+ * Emits:
20
+ * - array.not.array
21
+ * - array.has.invalid-length
22
+ *
23
+ * This rule is async-compatible and returns a readonly array of JaneEvent objects.
24
+ */
25
+ export declare const itemsEqual: (exact: number) => ValidationRule;