@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.
- package/README.md +132 -1
- package/dist/core/analysis/diff.d.ts +35 -0
- package/dist/core/analysis/diff.js +88 -0
- package/dist/core/analysis/explain.d.ts +35 -0
- package/dist/core/analysis/explain.js +117 -0
- package/dist/core/analysis/index.d.ts +14 -0
- package/dist/core/analysis/index.js +26 -0
- package/dist/core/analysis/replay.d.ts +34 -0
- package/dist/core/analysis/replay.js +68 -0
- package/dist/core/analysis/telemetry.d.ts +28 -0
- package/dist/core/analysis/telemetry.js +123 -0
- package/dist/core/boundary-rules/at-most-one.d.ts +17 -0
- package/dist/core/boundary-rules/at-most-one.js +38 -0
- package/dist/core/boundary-rules/conditionally-required.d.ts +18 -0
- package/dist/core/boundary-rules/conditionally-required.js +44 -0
- package/dist/core/boundary-rules/date-range.d.ts +17 -0
- package/dist/core/boundary-rules/date-range.js +39 -0
- package/dist/core/boundary-rules/index.d.ts +18 -0
- package/dist/core/boundary-rules/index.js +21 -0
- package/dist/core/boundary-rules/mutually-exclusive.d.ts +16 -0
- package/dist/core/boundary-rules/mutually-exclusive.js +38 -0
- package/dist/core/boundary-rules/no-unknown-fields.d.ts +17 -0
- package/dist/core/boundary-rules/no-unknown-fields.js +39 -0
- package/dist/core/boundary-rules/require-all.d.ts +16 -0
- package/dist/core/boundary-rules/require-all.js +39 -0
- package/dist/core/boundary-rules/require-one.d.ts +17 -0
- package/dist/core/boundary-rules/require-one.js +41 -0
- package/dist/core/common/events.d.ts +37 -0
- package/dist/core/common/events.js +82 -0
- package/dist/core/common/fluent.d.ts +151 -0
- package/dist/core/common/fluent.js +429 -0
- package/dist/core/common/index.d.ts +16 -0
- package/dist/core/common/index.js +31 -0
- package/dist/core/common/policy.d.ts +170 -0
- package/dist/core/common/policy.js +550 -0
- package/dist/core/common/utilities.d.ts +59 -0
- package/dist/core/common/utilities.js +177 -0
- package/dist/core/common/wildcard.d.ts +27 -0
- package/dist/core/common/wildcard.js +63 -0
- package/dist/core/field-path/construct.d.ts +77 -0
- package/dist/core/field-path/construct.js +189 -0
- package/dist/core/field-path/format.d.ts +41 -0
- package/dist/core/field-path/format.js +154 -0
- package/dist/core/field-path/index.d.ts +14 -0
- package/dist/core/field-path/index.js +26 -0
- package/dist/core/field-path/utilities.d.ts +85 -0
- package/dist/core/field-path/utilities.js +138 -0
- package/dist/core/field-path/walk.d.ts +36 -0
- package/dist/core/field-path/walk.js +80 -0
- package/dist/core/fluent-registry.d.ts +138 -0
- package/dist/core/fluent-registry.js +151 -0
- package/dist/core/normalizers/array/compact-sparse-array.d.ts +22 -0
- package/dist/core/normalizers/array/compact-sparse-array.js +40 -0
- package/dist/core/normalizers/array/flatten-one-level.d.ts +17 -0
- package/dist/core/normalizers/array/flatten-one-level.js +45 -0
- package/dist/core/normalizers/array/remove-empty-string-items.d.ts +6 -0
- package/dist/core/normalizers/array/remove-empty-string-items.js +34 -0
- package/dist/core/normalizers/array/remove-null-items.d.ts +16 -0
- package/dist/core/normalizers/array/remove-null-items.js +34 -0
- package/dist/core/normalizers/array/remove-undefined-items.d.ts +16 -0
- package/dist/core/normalizers/array/remove-undefined-items.js +34 -0
- package/dist/core/normalizers/date/invalid-date-to-undefined.d.ts +17 -0
- package/dist/core/normalizers/date/invalid-date-to-undefined.js +35 -0
- package/dist/core/normalizers/index.d.ts +28 -0
- package/dist/core/normalizers/index.js +46 -0
- package/dist/core/normalizers/normalizer-register.d.ts +17 -0
- package/dist/core/normalizers/normalizer-register.js +41 -0
- package/dist/core/normalizers/number/infinity-to-undefined.d.ts +18 -0
- package/dist/core/normalizers/number/infinity-to-undefined.js +35 -0
- package/dist/core/normalizers/number/nan-to-undefined.d.ts +17 -0
- package/dist/core/normalizers/number/nan-to-undefined.js +34 -0
- package/dist/core/normalizers/number/normalize-negative-zero.d.ts +16 -0
- package/dist/core/normalizers/number/normalize-negative-zero.js +33 -0
- package/dist/core/normalizers/object/remove-empty-array-keys.d.ts +17 -0
- package/dist/core/normalizers/object/remove-empty-array-keys.js +38 -0
- package/dist/core/normalizers/object/remove-empty-object-keys.d.ts +16 -0
- package/dist/core/normalizers/object/remove-empty-object-keys.js +42 -0
- package/dist/core/normalizers/object/remove-empty-string-keys.d.ts +16 -0
- package/dist/core/normalizers/object/remove-empty-string-keys.js +37 -0
- package/dist/core/normalizers/object/remove-null-keys.d.ts +16 -0
- package/dist/core/normalizers/object/remove-null-keys.js +37 -0
- package/dist/core/normalizers/object/remove-undefined-keys.d.ts +16 -0
- package/dist/core/normalizers/object/remove-undefined-keys.js +37 -0
- package/dist/core/normalizers/string/collapse-whitespace.d.ts +17 -0
- package/dist/core/normalizers/string/collapse-whitespace.js +35 -0
- package/dist/core/normalizers/string/empty-to-undefined.d.ts +16 -0
- package/dist/core/normalizers/string/empty-to-undefined.js +33 -0
- package/dist/core/normalizers/string/trim.d.ts +16 -0
- package/dist/core/normalizers/string/trim.js +34 -0
- package/dist/core/parsers/index.d.ts +22 -0
- package/dist/core/parsers/index.js +43 -0
- package/dist/core/parsers/parse-array-string.d.ts +16 -0
- package/dist/core/parsers/parse-array-string.js +36 -0
- package/dist/core/parsers/parse-bigint-string.d.ts +16 -0
- package/dist/core/parsers/parse-bigint-string.js +33 -0
- package/dist/core/parsers/parse-binary-string.d.ts +16 -0
- package/dist/core/parsers/parse-binary-string.js +33 -0
- package/dist/core/parsers/parse-boolean-string.d.ts +16 -0
- package/dist/core/parsers/parse-boolean-string.js +27 -0
- package/dist/core/parsers/parse-date-string.d.ts +16 -0
- package/dist/core/parsers/parse-date-string.js +30 -0
- package/dist/core/parsers/parse-duration-string.d.ts +16 -0
- package/dist/core/parsers/parse-duration-string.js +37 -0
- package/dist/core/parsers/parse-hex-string.d.ts +16 -0
- package/dist/core/parsers/parse-hex-string.js +29 -0
- package/dist/core/parsers/parse-integer-string.d.ts +16 -0
- package/dist/core/parsers/parse-integer-string.js +30 -0
- package/dist/core/parsers/parse-json-string.d.ts +17 -0
- package/dist/core/parsers/parse-json-string.js +35 -0
- package/dist/core/parsers/parse-numeric-string.d.ts +16 -0
- package/dist/core/parsers/parse-numeric-string.js +29 -0
- package/dist/core/parsers/parse-object-string.d.ts +16 -0
- package/dist/core/parsers/parse-object-string.js +36 -0
- package/dist/core/parsers/parse-octal-string.d.ts +16 -0
- package/dist/core/parsers/parse-octal-string.js +33 -0
- package/dist/core/parsers/parse-scientific-notation-string.d.ts +16 -0
- package/dist/core/parsers/parse-scientific-notation-string.js +30 -0
- package/dist/core/parsers/parse-url-string.d.ts +16 -0
- package/dist/core/parsers/parse-url-string.js +36 -0
- package/dist/core/pipeline/boundary.d.ts +36 -0
- package/dist/core/pipeline/boundary.js +256 -0
- package/dist/core/pipeline/contain.d.ts +122 -0
- package/dist/core/pipeline/contain.js +339 -0
- package/dist/core/pipeline/index.d.ts +16 -0
- package/dist/core/pipeline/index.js +37 -0
- package/dist/core/pipeline/normalize.d.ts +34 -0
- package/dist/core/pipeline/normalize.js +76 -0
- package/dist/core/pipeline/parse.d.ts +40 -0
- package/dist/core/pipeline/parse.js +91 -0
- package/dist/core/pipeline/pipeline.d.ts +23 -0
- package/dist/core/pipeline/pipeline.js +418 -0
- package/dist/core/pipeline/scan.d.ts +46 -0
- package/dist/core/pipeline/scan.js +115 -0
- package/dist/core/pipeline/validate.d.ts +40 -0
- package/dist/core/pipeline/validate.js +74 -0
- package/dist/core/scanners/any/scan-for-sentinels.d.ts +19 -0
- package/dist/core/scanners/any/scan-for-sentinels.js +35 -0
- package/dist/core/scanners/array/array-is-deep.d.ts +19 -0
- package/dist/core/scanners/array/array-is-deep.js +38 -0
- package/dist/core/scanners/array/array-is-heterogenous.d.ts +18 -0
- package/dist/core/scanners/array/array-is-heterogenous.js +39 -0
- package/dist/core/scanners/array/array-is-large.d.ts +19 -0
- package/dist/core/scanners/array/array-is-large.js +32 -0
- package/dist/core/scanners/bigint/bigint-is-large.d.ts +20 -0
- package/dist/core/scanners/bigint/bigint-is-large.js +34 -0
- package/dist/core/scanners/bigint/bigint-not-safe.d.ts +20 -0
- package/dist/core/scanners/bigint/bigint-not-safe.js +34 -0
- package/dist/core/scanners/date/date-is-before-epoch.d.ts +19 -0
- package/dist/core/scanners/date/date-is-before-epoch.js +32 -0
- package/dist/core/scanners/date/date-is-far-future.d.ts +19 -0
- package/dist/core/scanners/date/date-is-far-future.js +32 -0
- package/dist/core/scanners/date/date-is-invalid.d.ts +19 -0
- package/dist/core/scanners/date/date-is-invalid.js +31 -0
- package/dist/core/scanners/index.d.ts +31 -0
- package/dist/core/scanners/index.js +58 -0
- package/dist/core/scanners/number/number-is-infinite.d.ts +19 -0
- package/dist/core/scanners/number/number-is-infinite.js +31 -0
- package/dist/core/scanners/number/number-is-nan.d.ts +19 -0
- package/dist/core/scanners/number/number-is-nan.js +31 -0
- package/dist/core/scanners/number/number-is-too-large.d.ts +20 -0
- package/dist/core/scanners/number/number-is-too-large.js +33 -0
- package/dist/core/scanners/number/number-is-unsafe-integer.d.ts +19 -0
- package/dist/core/scanners/number/number-is-unsafe-integer.js +31 -0
- package/dist/core/scanners/object/object-has-circular-references.d.ts +20 -0
- package/dist/core/scanners/object/object-has-circular-references.js +43 -0
- package/dist/core/scanners/object/object-has-many-keys.d.ts +19 -0
- package/dist/core/scanners/object/object-has-many-keys.js +33 -0
- package/dist/core/scanners/object/object-is-deep.d.ts +20 -0
- package/dist/core/scanners/object/object-is-deep.js +38 -0
- package/dist/core/scanners/scanner-registry.d.ts +19 -0
- package/dist/core/scanners/scanner-registry.js +36 -0
- package/dist/core/scanners/string/string-has-unsafe-unicode.d.ts +19 -0
- package/dist/core/scanners/string/string-has-unsafe-unicode.js +32 -0
- package/dist/core/scanners/string/string-has-whitespace-edges.d.ts +19 -0
- package/dist/core/scanners/string/string-has-whitespace-edges.js +31 -0
- package/dist/core/scanners/string/string-is-long.d.ts +19 -0
- package/dist/core/scanners/string/string-is-long.js +32 -0
- package/dist/core/scanners/unknown/unknown-not-scannable.d.ts +21 -0
- package/dist/core/scanners/unknown/unknown-not-scannable.js +34 -0
- package/dist/core/shapes/analysis.d.ts +239 -0
- package/dist/core/shapes/analysis.js +11 -0
- package/dist/core/shapes/boundary.d.ts +126 -0
- package/dist/core/shapes/boundary.js +11 -0
- package/dist/core/shapes/events.d.ts +83 -0
- package/dist/core/shapes/events.js +10 -0
- package/dist/core/shapes/field-path.d.ts +51 -0
- package/dist/core/shapes/field-path.js +10 -0
- package/dist/core/shapes/index.d.ts +21 -0
- package/dist/core/shapes/index.js +11 -0
- package/dist/core/shapes/normalize.d.ts +59 -0
- package/dist/core/shapes/normalize.js +11 -0
- package/dist/core/shapes/parse.d.ts +75 -0
- package/dist/core/shapes/parse.js +11 -0
- package/dist/core/shapes/pipeline.d.ts +149 -0
- package/dist/core/shapes/pipeline.js +11 -0
- package/dist/core/shapes/policy.d.ts +158 -0
- package/dist/core/shapes/policy.js +11 -0
- package/dist/core/shapes/public.d.ts +92 -0
- package/dist/core/shapes/public.js +10 -0
- package/dist/core/shapes/scan.d.ts +126 -0
- package/dist/core/shapes/scan.js +11 -0
- package/dist/core/shapes/validate.d.ts +65 -0
- package/dist/core/shapes/validate.js +11 -0
- package/dist/core/validators/array/array-max-items.d.ts +25 -0
- package/dist/core/validators/array/array-max-items.js +42 -0
- package/dist/core/validators/array/array-min-items.d.ts +25 -0
- package/dist/core/validators/array/array-min-items.js +42 -0
- package/dist/core/validators/array/array.d.ts +22 -0
- package/dist/core/validators/array/array.js +34 -0
- package/dist/core/validators/array/excludes.d.ts +25 -0
- package/dist/core/validators/array/excludes.js +47 -0
- package/dist/core/validators/array/has-unique-items.d.ts +24 -0
- package/dist/core/validators/array/has-unique-items.js +46 -0
- package/dist/core/validators/array/includes.d.ts +24 -0
- package/dist/core/validators/array/includes.js +46 -0
- package/dist/core/validators/array/items-equal.d.ts +25 -0
- package/dist/core/validators/array/items-equal.js +42 -0
- package/dist/core/validators/array/no-empty-string-items.d.ts +24 -0
- package/dist/core/validators/array/no-empty-string-items.js +46 -0
- package/dist/core/validators/array/no-null-items.d.ts +24 -0
- package/dist/core/validators/array/no-null-items.js +46 -0
- package/dist/core/validators/array/no-undefined-items.d.ts +24 -0
- package/dist/core/validators/array/no-undefined-items.js +45 -0
- package/dist/core/validators/array/non-empty-array.d.ts +24 -0
- package/dist/core/validators/array/non-empty-array.js +45 -0
- package/dist/core/validators/array/not-sparse.d.ts +25 -0
- package/dist/core/validators/array/not-sparse.js +44 -0
- package/dist/core/validators/bigint/bigint-equals.d.ts +24 -0
- package/dist/core/validators/bigint/bigint-equals.js +57 -0
- package/dist/core/validators/bigint/bigint-max.d.ts +25 -0
- package/dist/core/validators/bigint/bigint-max.js +63 -0
- package/dist/core/validators/bigint/bigint-min.d.ts +25 -0
- package/dist/core/validators/bigint/bigint-min.js +87 -0
- package/dist/core/validators/bigint/bigint-negative.d.ts +23 -0
- package/dist/core/validators/bigint/bigint-negative.js +73 -0
- package/dist/core/validators/bigint/bigint-non-negative.d.ts +24 -0
- package/dist/core/validators/bigint/bigint-non-negative.js +72 -0
- package/dist/core/validators/bigint/bigint-non-positive.d.ts +24 -0
- package/dist/core/validators/bigint/bigint-non-positive.js +72 -0
- package/dist/core/validators/bigint/bigint-positive.d.ts +24 -0
- package/dist/core/validators/bigint/bigint-positive.js +72 -0
- package/dist/core/validators/bigint/bigint-safe.d.ts +25 -0
- package/dist/core/validators/bigint/bigint-safe.js +75 -0
- package/dist/core/validators/bigint/bigint.d.ts +20 -0
- package/dist/core/validators/bigint/bigint.js +38 -0
- package/dist/core/validators/boolean/boolean.d.ts +21 -0
- package/dist/core/validators/boolean/boolean.js +39 -0
- package/dist/core/validators/boolean/is-false.d.ts +22 -0
- package/dist/core/validators/boolean/is-false.js +48 -0
- package/dist/core/validators/boolean/is-true.d.ts +22 -0
- package/dist/core/validators/boolean/is-true.js +48 -0
- package/dist/core/validators/common/is-country-code.d.ts +17 -0
- package/dist/core/validators/common/is-country-code.js +36 -0
- package/dist/core/validators/common/is-currency-code.d.ts +17 -0
- package/dist/core/validators/common/is-currency-code.js +36 -0
- package/dist/core/validators/common/is-email-strict.d.ts +17 -0
- package/dist/core/validators/common/is-email-strict.js +36 -0
- package/dist/core/validators/common/is-email.d.ts +17 -0
- package/dist/core/validators/common/is-email.js +36 -0
- package/dist/core/validators/common/is-ip.d.ts +17 -0
- package/dist/core/validators/common/is-ip.js +37 -0
- package/dist/core/validators/common/is-phone-strict.d.ts +17 -0
- package/dist/core/validators/common/is-phone-strict.js +36 -0
- package/dist/core/validators/common/is-phone.d.ts +17 -0
- package/dist/core/validators/common/is-phone.js +36 -0
- package/dist/core/validators/common/is-port.d.ts +17 -0
- package/dist/core/validators/common/is-port.js +35 -0
- package/dist/core/validators/common/is-postal-code.d.ts +17 -0
- package/dist/core/validators/common/is-postal-code.js +36 -0
- package/dist/core/validators/common/is-url.d.ts +17 -0
- package/dist/core/validators/common/is-url.js +38 -0
- package/dist/core/validators/common/is-uuid.d.ts +17 -0
- package/dist/core/validators/common/is-uuid.js +36 -0
- package/dist/core/validators/date/before-epoch.d.ts +28 -0
- package/dist/core/validators/date/before-epoch.js +56 -0
- package/dist/core/validators/date/date-now-required.d.ts +22 -0
- package/dist/core/validators/date/date-now-required.js +48 -0
- package/dist/core/validators/date/is-date.d.ts +21 -0
- package/dist/core/validators/date/is-date.js +47 -0
- package/dist/core/validators/date/is-far-future.d.ts +23 -0
- package/dist/core/validators/date/is-far-future.js +46 -0
- package/dist/core/validators/date/is-future.d.ts +24 -0
- package/dist/core/validators/date/is-future.js +59 -0
- package/dist/core/validators/date/is-past.d.ts +24 -0
- package/dist/core/validators/date/is-past.js +59 -0
- package/dist/core/validators/date/not-after.d.ts +25 -0
- package/dist/core/validators/date/not-after.js +66 -0
- package/dist/core/validators/date/not-before.d.ts +25 -0
- package/dist/core/validators/date/not-before.js +66 -0
- package/dist/core/validators/date/same-day.d.ts +25 -0
- package/dist/core/validators/date/same-day.js +60 -0
- package/dist/core/validators/date/same-month.d.ts +25 -0
- package/dist/core/validators/date/same-month.js +59 -0
- package/dist/core/validators/date/same-year.d.ts +24 -0
- package/dist/core/validators/date/same-year.js +56 -0
- package/dist/core/validators/date/too-early.d.ts +25 -0
- package/dist/core/validators/date/too-early.js +57 -0
- package/dist/core/validators/date/too-late.d.ts +25 -0
- package/dist/core/validators/date/too-late.js +57 -0
- package/dist/core/validators/date/weekday.d.ts +32 -0
- package/dist/core/validators/date/weekday.js +65 -0
- package/dist/core/validators/date/weekend.d.ts +27 -0
- package/dist/core/validators/date/weekend.js +56 -0
- package/dist/core/validators/index.d.ts +112 -0
- package/dist/core/validators/index.js +139 -0
- package/dist/core/validators/nullish/is-null-or-undefined.d.ts +22 -0
- package/dist/core/validators/nullish/is-null-or-undefined.js +40 -0
- package/dist/core/validators/nullish/is-null.d.ts +21 -0
- package/dist/core/validators/nullish/is-null.js +39 -0
- package/dist/core/validators/nullish/is-undefined.d.ts +21 -0
- package/dist/core/validators/nullish/is-undefined.js +39 -0
- package/dist/core/validators/number/finite.d.ts +22 -0
- package/dist/core/validators/number/finite.js +40 -0
- package/dist/core/validators/number/integer.d.ts +22 -0
- package/dist/core/validators/number/integer.js +40 -0
- package/dist/core/validators/number/less-than.d.ts +21 -0
- package/dist/core/validators/number/less-than.js +39 -0
- package/dist/core/validators/number/max.d.ts +21 -0
- package/dist/core/validators/number/max.js +39 -0
- package/dist/core/validators/number/min.d.ts +21 -0
- package/dist/core/validators/number/min.js +39 -0
- package/dist/core/validators/number/more-than.d.ts +21 -0
- package/dist/core/validators/number/more-than.js +39 -0
- package/dist/core/validators/number/negative.d.ts +20 -0
- package/dist/core/validators/number/negative.js +38 -0
- package/dist/core/validators/number/non-negative.d.ts +19 -0
- package/dist/core/validators/number/non-negative.js +37 -0
- package/dist/core/validators/number/non-positive.d.ts +19 -0
- package/dist/core/validators/number/non-positive.js +37 -0
- package/dist/core/validators/number/number.d.ts +19 -0
- package/dist/core/validators/number/number.js +31 -0
- package/dist/core/validators/number/positive.d.ts +20 -0
- package/dist/core/validators/number/positive.js +38 -0
- package/dist/core/validators/number/safe-integer.d.ts +19 -0
- package/dist/core/validators/number/safe-integer.js +42 -0
- package/dist/core/validators/object/deep-equals.d.ts +24 -0
- package/dist/core/validators/object/deep-equals.js +47 -0
- package/dist/core/validators/object/has-key.d.ts +23 -0
- package/dist/core/validators/object/has-key.js +42 -0
- package/dist/core/validators/object/has-value.d.ts +27 -0
- package/dist/core/validators/object/has-value.js +59 -0
- package/dist/core/validators/object/keys-equal.d.ts +26 -0
- package/dist/core/validators/object/keys-equal.js +47 -0
- package/dist/core/validators/object/max-keys.d.ts +24 -0
- package/dist/core/validators/object/max-keys.js +43 -0
- package/dist/core/validators/object/min-keys.d.ts +24 -0
- package/dist/core/validators/object/min-keys.js +43 -0
- package/dist/core/validators/object/missing-key.d.ts +23 -0
- package/dist/core/validators/object/missing-key.js +42 -0
- package/dist/core/validators/object/no-empty-array-values.d.ts +23 -0
- package/dist/core/validators/object/no-empty-array-values.js +44 -0
- package/dist/core/validators/object/no-empty-object-values.d.ts +23 -0
- package/dist/core/validators/object/no-empty-object-values.js +44 -0
- package/dist/core/validators/object/no-null-values.d.ts +23 -0
- package/dist/core/validators/object/no-null-values.js +44 -0
- package/dist/core/validators/object/no-undefined-values.d.ts +23 -0
- package/dist/core/validators/object/no-undefined-values.js +44 -0
- package/dist/core/validators/object/non-empty-object.d.ts +21 -0
- package/dist/core/validators/object/non-empty-object.js +40 -0
- package/dist/core/validators/object/only-keys.d.ts +23 -0
- package/dist/core/validators/object/only-keys.js +43 -0
- package/dist/core/validators/object/plain-object.d.ts +22 -0
- package/dist/core/validators/object/plain-object.js +35 -0
- package/dist/core/validators/string/alpha-num.d.ts +23 -0
- package/dist/core/validators/string/alpha-num.js +50 -0
- package/dist/core/validators/string/alpha.d.ts +24 -0
- package/dist/core/validators/string/alpha.js +51 -0
- package/dist/core/validators/string/chars-equal.d.ts +23 -0
- package/dist/core/validators/string/chars-equal.js +49 -0
- package/dist/core/validators/string/ends-with.d.ts +23 -0
- package/dist/core/validators/string/ends-with.js +50 -0
- package/dist/core/validators/string/is-ascii.d.ts +24 -0
- package/dist/core/validators/string/is-ascii.js +53 -0
- package/dist/core/validators/string/is-printable.d.ts +25 -0
- package/dist/core/validators/string/is-printable.js +53 -0
- package/dist/core/validators/string/matches.d.ts +23 -0
- package/dist/core/validators/string/matches.js +50 -0
- package/dist/core/validators/string/max-length.d.ts +24 -0
- package/dist/core/validators/string/max-length.js +50 -0
- package/dist/core/validators/string/min-length.d.ts +24 -0
- package/dist/core/validators/string/min-length.js +50 -0
- package/dist/core/validators/string/no-lead-space.d.ts +23 -0
- package/dist/core/validators/string/no-lead-space.js +50 -0
- package/dist/core/validators/string/no-repeat-space.d.ts +25 -0
- package/dist/core/validators/string/no-repeat-space.js +52 -0
- package/dist/core/validators/string/no-space.d.ts +24 -0
- package/dist/core/validators/string/no-space.js +51 -0
- package/dist/core/validators/string/no-trail-space.d.ts +23 -0
- package/dist/core/validators/string/no-trail-space.js +50 -0
- package/dist/core/validators/string/non-empty.d.ts +22 -0
- package/dist/core/validators/string/non-empty.js +48 -0
- package/dist/core/validators/string/not-one-of.d.ts +24 -0
- package/dist/core/validators/string/not-one-of.js +51 -0
- package/dist/core/validators/string/num-string.d.ts +23 -0
- package/dist/core/validators/string/num-string.js +50 -0
- package/dist/core/validators/string/one-of.d.ts +23 -0
- package/dist/core/validators/string/one-of.js +50 -0
- package/dist/core/validators/string/starts-with.d.ts +23 -0
- package/dist/core/validators/string/starts-with.js +50 -0
- package/dist/core/validators/string/string.d.ts +21 -0
- package/dist/core/validators/string/string.js +39 -0
- package/dist/core/validators/string/trimmed.d.ts +24 -0
- package/dist/core/validators/string/trimmed.js +51 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +26 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +12 -0
- package/package.json +2 -2
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Is Past
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance representing a moment
|
|
7
|
+
* strictly before the current system time.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
import { validationEvent } from '../../pipeline';
|
|
12
|
+
import { detectStructuralType } from '../../pipeline/scan';
|
|
13
|
+
import { safeStringify } from '../../common';
|
|
14
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
15
|
+
|* Implementation *|
|
|
16
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
17
|
+
/**
|
|
18
|
+
* Ensures the input is a Date instance representing a moment strictly
|
|
19
|
+
* before the current system time.
|
|
20
|
+
*
|
|
21
|
+
* - Non-Date values emit `date.not.date`.
|
|
22
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
23
|
+
* - Dates ≥ now emit `date.in.future`.
|
|
24
|
+
*
|
|
25
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
26
|
+
* provided path. It supports userMessage overrides applied at the
|
|
27
|
+
* pipeline level.
|
|
28
|
+
*/
|
|
29
|
+
export const isPast = async (value, path) => {
|
|
30
|
+
const structuralType = detectStructuralType(value);
|
|
31
|
+
// ------------------------------------------------------------
|
|
32
|
+
// Type check — the input must be a Date instance.
|
|
33
|
+
// ------------------------------------------------------------
|
|
34
|
+
if (!(value instanceof Date)) {
|
|
35
|
+
return [
|
|
36
|
+
validationEvent('error', 'date.not.date', path, `Expected 'Date' but received '${structuralType}'.`, `Please provide a valid date.`, { value, expected: 'Date', actual: structuralType }),
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
// ------------------------------------------------------------
|
|
40
|
+
// Validity check — reject invalid Date instances.
|
|
41
|
+
// ------------------------------------------------------------
|
|
42
|
+
if (isNaN(value.getTime())) {
|
|
43
|
+
return [
|
|
44
|
+
validationEvent('error', 'date.is.invalid', path, `Date value is invalid.`, `Please provide a valid date.`, { value, expected: 'valid Date', actual: value }),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
// ------------------------------------------------------------
|
|
48
|
+
// Past check — must be strictly less than now.
|
|
49
|
+
// ------------------------------------------------------------
|
|
50
|
+
if (value.getTime() >= Date.now()) {
|
|
51
|
+
return [
|
|
52
|
+
validationEvent('error', 'date.in.future', path, `${safeStringify(value)} must be in the past.`, `Please provide a past date.`, { value, expected: 'past date', actual: value }),
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
// ------------------------------------------------------------
|
|
56
|
+
// Valid — return an empty array to indicate success.
|
|
57
|
+
// ------------------------------------------------------------
|
|
58
|
+
return [];
|
|
59
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Not After
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance that is not after the
|
|
7
|
+
* provided `max` boundary.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
import type { ValidationRule } from '../../shapes';
|
|
12
|
+
/**
|
|
13
|
+
* Ensures the input is a Date instance that is not after the
|
|
14
|
+
* provided `max` boundary. The comparison is strict: value must be
|
|
15
|
+
* ≤ max.
|
|
16
|
+
*
|
|
17
|
+
* - Non-Date values emit `date.not.date`.
|
|
18
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
19
|
+
* - Dates > max emit `date.too.late`.
|
|
20
|
+
*
|
|
21
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
22
|
+
* provided path. It supports userMessage overrides applied at the
|
|
23
|
+
* pipeline level.
|
|
24
|
+
*/
|
|
25
|
+
export declare const notAfter: (max: Date) => ValidationRule;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Not After
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance that is not after the
|
|
7
|
+
* provided `max` boundary.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
import { validationEvent } from '../../pipeline';
|
|
12
|
+
import { detectStructuralType } from '../../pipeline/scan';
|
|
13
|
+
import { safeStringify } from '../../common';
|
|
14
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
15
|
+
|* Implementation *|
|
|
16
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
17
|
+
/**
|
|
18
|
+
* Ensures the input is a Date instance that is not after the
|
|
19
|
+
* provided `max` boundary. The comparison is strict: value must be
|
|
20
|
+
* ≤ max.
|
|
21
|
+
*
|
|
22
|
+
* - Non-Date values emit `date.not.date`.
|
|
23
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
24
|
+
* - Dates > max emit `date.too.late`.
|
|
25
|
+
*
|
|
26
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
27
|
+
* provided path. It supports userMessage overrides applied at the
|
|
28
|
+
* pipeline level.
|
|
29
|
+
*/
|
|
30
|
+
export const notAfter = (max) => {
|
|
31
|
+
const rule = async (value, path) => {
|
|
32
|
+
const structuralType = detectStructuralType(value);
|
|
33
|
+
// ------------------------------------------------------------
|
|
34
|
+
// Type check — the input must be a Date instance.
|
|
35
|
+
// ------------------------------------------------------------
|
|
36
|
+
if (!(value instanceof Date)) {
|
|
37
|
+
return [
|
|
38
|
+
validationEvent('error', 'date.not.date', path, `Expected 'Date' but received '${structuralType}'.`, `Please provide a valid date.`, { value, expected: 'Date', actual: structuralType }),
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
// ------------------------------------------------------------
|
|
42
|
+
// Validity check — reject invalid Date instances.
|
|
43
|
+
// ------------------------------------------------------------
|
|
44
|
+
if (isNaN(value.getTime())) {
|
|
45
|
+
return [
|
|
46
|
+
validationEvent('error', 'date.is.invalid', path, `Date value is invalid.`, `Please provide a valid date.`, { value, expected: 'valid Date', actual: value }),
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
// ------------------------------------------------------------
|
|
50
|
+
// Boundary check — must be ≤ max.
|
|
51
|
+
// ------------------------------------------------------------
|
|
52
|
+
if (value.getTime() > max.getTime()) {
|
|
53
|
+
return [
|
|
54
|
+
validationEvent('error', 'date.too.late', path, `${safeStringify(value)} must not be after ${max.toISOString()}.`, `Please provide an earlier date.`, { value, expected: `<= ${max.toISOString()}`, actual: value.toISOString() }),
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
// ------------------------------------------------------------
|
|
58
|
+
// Valid — return an empty array to indicate success.
|
|
59
|
+
// ------------------------------------------------------------
|
|
60
|
+
return [];
|
|
61
|
+
};
|
|
62
|
+
// Mark as factory to preserve captured `max` value
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
rule.__janeFactory = true;
|
|
65
|
+
return rule;
|
|
66
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Not Before
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance that is not before the
|
|
7
|
+
* provided `min` boundary.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
import type { ValidationRule } from '../../shapes';
|
|
12
|
+
/**
|
|
13
|
+
* Ensures the input is a Date instance that is not before the
|
|
14
|
+
* provided `min` boundary. The comparison is inclusive: value must be
|
|
15
|
+
* ≥ min.
|
|
16
|
+
*
|
|
17
|
+
* - Non-Date values emit `date.not.date`.
|
|
18
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
19
|
+
* - Dates < min emit `date.too.early`.
|
|
20
|
+
*
|
|
21
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
22
|
+
* provided path. It supports userMessage overrides applied at the
|
|
23
|
+
* pipeline level.
|
|
24
|
+
*/
|
|
25
|
+
export declare const notBefore: (min: Date) => ValidationRule;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Not Before
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance that is not before the
|
|
7
|
+
* provided `min` boundary.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
import { validationEvent } from '../../pipeline';
|
|
12
|
+
import { detectStructuralType } from '../../pipeline/scan';
|
|
13
|
+
import { safeStringify } from '../../common';
|
|
14
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
15
|
+
|* Implementation *|
|
|
16
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
17
|
+
/**
|
|
18
|
+
* Ensures the input is a Date instance that is not before the
|
|
19
|
+
* provided `min` boundary. The comparison is inclusive: value must be
|
|
20
|
+
* ≥ min.
|
|
21
|
+
*
|
|
22
|
+
* - Non-Date values emit `date.not.date`.
|
|
23
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
24
|
+
* - Dates < min emit `date.too.early`.
|
|
25
|
+
*
|
|
26
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
27
|
+
* provided path. It supports userMessage overrides applied at the
|
|
28
|
+
* pipeline level.
|
|
29
|
+
*/
|
|
30
|
+
export const notBefore = (min) => {
|
|
31
|
+
const rule = async (value, path) => {
|
|
32
|
+
const structuralType = detectStructuralType(value);
|
|
33
|
+
// ------------------------------------------------------------
|
|
34
|
+
// Type check — the input must be a Date instance.
|
|
35
|
+
// ------------------------------------------------------------
|
|
36
|
+
if (!(value instanceof Date)) {
|
|
37
|
+
return [
|
|
38
|
+
validationEvent('error', 'date.not.date', path, `Expected 'Date' but received '${structuralType}'.`, `Please provide a valid date.`, { value, expected: 'Date', actual: structuralType }),
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
// ------------------------------------------------------------
|
|
42
|
+
// Validity check — reject invalid Date instances.
|
|
43
|
+
// ------------------------------------------------------------
|
|
44
|
+
if (isNaN(value.getTime())) {
|
|
45
|
+
return [
|
|
46
|
+
validationEvent('error', 'date.is.invalid', path, `Date value is invalid.`, `Please provide a valid date.`, { value, expected: 'valid Date', actual: value }),
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
// ------------------------------------------------------------
|
|
50
|
+
// Boundary check — must be ≥ min.
|
|
51
|
+
// ------------------------------------------------------------
|
|
52
|
+
if (value.getTime() < min.getTime()) {
|
|
53
|
+
return [
|
|
54
|
+
validationEvent('error', 'date.too.early', path, `${safeStringify(value)} must not be before ${min.toISOString()}.`, `Please provide a later date.`, { value, expected: `>= ${min.toISOString()}`, actual: value.toISOString() }),
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
// ------------------------------------------------------------
|
|
58
|
+
// Valid — return an empty array to indicate success.
|
|
59
|
+
// ------------------------------------------------------------
|
|
60
|
+
return [];
|
|
61
|
+
};
|
|
62
|
+
// Mark as factory to preserve captured `min` value
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
rule.__janeFactory = true;
|
|
65
|
+
return rule;
|
|
66
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Same Day
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance representing the same
|
|
7
|
+
* calendar day (year, month, day) as the provided `other`
|
|
8
|
+
* date.
|
|
9
|
+
* @see https://jane-io.com
|
|
10
|
+
* ----------------------------------------------------------------------------
|
|
11
|
+
*/
|
|
12
|
+
import type { ValidationRule } from '../../shapes';
|
|
13
|
+
/**
|
|
14
|
+
* Ensures the input is a Date instance representing the same
|
|
15
|
+
* calendar day (year, month, day) as the provided `other` date.
|
|
16
|
+
*
|
|
17
|
+
* - Non-Date values emit `date.not.date`.
|
|
18
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
19
|
+
* - Dates not matching the same Y/M/D emit `date.not.same-day`.
|
|
20
|
+
*
|
|
21
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
22
|
+
* provided path. It supports userMessage overrides applied at the
|
|
23
|
+
* pipeline level.
|
|
24
|
+
*/
|
|
25
|
+
export declare const sameDay: (other: Date) => ValidationRule;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Same Day
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance representing the same
|
|
7
|
+
* calendar day (year, month, day) as the provided `other`
|
|
8
|
+
* date.
|
|
9
|
+
* @see https://jane-io.com
|
|
10
|
+
* ----------------------------------------------------------------------------
|
|
11
|
+
*/
|
|
12
|
+
import { validationEvent } from '../../pipeline';
|
|
13
|
+
import { safeStringify } from '../../common';
|
|
14
|
+
import { detectStructuralType } from '../../pipeline/scan';
|
|
15
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
16
|
+
|* Implementation *|
|
|
17
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
18
|
+
/**
|
|
19
|
+
* Ensures the input is a Date instance representing the same
|
|
20
|
+
* calendar day (year, month, day) as the provided `other` date.
|
|
21
|
+
*
|
|
22
|
+
* - Non-Date values emit `date.not.date`.
|
|
23
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
24
|
+
* - Dates not matching the same Y/M/D emit `date.not.same-day`.
|
|
25
|
+
*
|
|
26
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
27
|
+
* provided path. It supports userMessage overrides applied at the
|
|
28
|
+
* pipeline level.
|
|
29
|
+
*/
|
|
30
|
+
export const sameDay = (other) => {
|
|
31
|
+
const rule = async (value, path) => {
|
|
32
|
+
const structuralType = detectStructuralType(value);
|
|
33
|
+
if (!(value instanceof Date)) {
|
|
34
|
+
return [
|
|
35
|
+
validationEvent('error', 'date.not.date', path, `Expected 'Date' but received '${structuralType}'.`, `Please provide a valid date.`, { value, expected: 'Date', actual: structuralType }),
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
if (isNaN(value.getTime())) {
|
|
39
|
+
return [
|
|
40
|
+
validationEvent('error', 'date.is.invalid', path, `Date value is invalid.`, `Please provide a valid date.`, { value, expected: 'valid Date', actual: value }),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
const isSame = value.getUTCFullYear() === other.getUTCFullYear() &&
|
|
44
|
+
value.getUTCMonth() === other.getUTCMonth() &&
|
|
45
|
+
value.getUTCDate() === other.getUTCDate();
|
|
46
|
+
if (!isSame) {
|
|
47
|
+
return [
|
|
48
|
+
validationEvent('error', 'date.not.same-day', path, `${safeStringify(value)} must be the same day as ${other.toISOString()}.`, `Please provide the correct date.`, {
|
|
49
|
+
value,
|
|
50
|
+
expected: other.toISOString().slice(0, 10),
|
|
51
|
+
actual: value.toISOString().slice(0, 10),
|
|
52
|
+
}),
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
return [];
|
|
56
|
+
};
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
rule.__janeFactory = true;
|
|
59
|
+
return rule;
|
|
60
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Same Month
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance representing a date in
|
|
7
|
+
* the same calendar month (year + month) as the provided
|
|
8
|
+
* `other` date.
|
|
9
|
+
* @see https://jane-io.com
|
|
10
|
+
* ----------------------------------------------------------------------------
|
|
11
|
+
*/
|
|
12
|
+
import type { ValidationRule } from '../../shapes';
|
|
13
|
+
/**
|
|
14
|
+
* Ensures the input is a Date instance representing a date in the
|
|
15
|
+
* same calendar month (year + month) as the provided `other` date.
|
|
16
|
+
*
|
|
17
|
+
* - Non-Date values emit `date.not.date`.
|
|
18
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
19
|
+
* - Dates not matching the same Y/M emit `date.not.same-month`.
|
|
20
|
+
*
|
|
21
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
22
|
+
* provided path. It supports userMessage overrides applied at the
|
|
23
|
+
* pipeline level.
|
|
24
|
+
*/
|
|
25
|
+
export declare const sameMonth: (other: Date) => ValidationRule;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Same Month
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance representing a date in
|
|
7
|
+
* the same calendar month (year + month) as the provided
|
|
8
|
+
* `other` date.
|
|
9
|
+
* @see https://jane-io.com
|
|
10
|
+
* ----------------------------------------------------------------------------
|
|
11
|
+
*/
|
|
12
|
+
import { validationEvent } from '../../pipeline';
|
|
13
|
+
import { safeStringify } from '../../common';
|
|
14
|
+
import { detectStructuralType } from '../../pipeline/scan';
|
|
15
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
16
|
+
|* Implementation *|
|
|
17
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
18
|
+
/**
|
|
19
|
+
* Ensures the input is a Date instance representing a date in the
|
|
20
|
+
* same calendar month (year + month) as the provided `other` date.
|
|
21
|
+
*
|
|
22
|
+
* - Non-Date values emit `date.not.date`.
|
|
23
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
24
|
+
* - Dates not matching the same Y/M emit `date.not.same-month`.
|
|
25
|
+
*
|
|
26
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
27
|
+
* provided path. It supports userMessage overrides applied at the
|
|
28
|
+
* pipeline level.
|
|
29
|
+
*/
|
|
30
|
+
export const sameMonth = (other) => {
|
|
31
|
+
const rule = async (value, path) => {
|
|
32
|
+
const structuralType = detectStructuralType(value);
|
|
33
|
+
if (!(value instanceof Date)) {
|
|
34
|
+
return [
|
|
35
|
+
validationEvent('error', 'date.not.date', path, `Expected 'Date' but received '${structuralType}'.`, `Please provide a valid date.`, { value, expected: 'Date', actual: structuralType }),
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
if (isNaN(value.getTime())) {
|
|
39
|
+
return [
|
|
40
|
+
validationEvent('error', 'date.is.invalid', path, `Date value is invalid.`, `Please provide a valid date.`, { value, expected: 'valid Date', actual: value }),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
const isSame = value.getUTCFullYear() === other.getUTCFullYear() &&
|
|
44
|
+
value.getUTCMonth() === other.getUTCMonth();
|
|
45
|
+
if (!isSame) {
|
|
46
|
+
return [
|
|
47
|
+
validationEvent('error', 'date.not.same-month', path, `${safeStringify(value)} must be in the same month as ${other.toISOString()}.`, `Please provide a date in the correct month.`, {
|
|
48
|
+
value,
|
|
49
|
+
expected: other.toISOString().slice(0, 7), // YYYY-MM
|
|
50
|
+
actual: value.toISOString().slice(0, 7),
|
|
51
|
+
}),
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
return [];
|
|
55
|
+
};
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
rule.__janeFactory = true;
|
|
58
|
+
return rule;
|
|
59
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Same Year
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance representing a date in
|
|
7
|
+
* the same calendar year as the provided `other` date.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
import type { ValidationRule } from '../../shapes';
|
|
12
|
+
/**
|
|
13
|
+
* Ensures the input is a Date instance representing a date in the
|
|
14
|
+
* same calendar year as the provided `other` date.
|
|
15
|
+
*
|
|
16
|
+
* - Non-Date values emit `date.not.date`.
|
|
17
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
18
|
+
* - Dates not matching the same year emit `date.not.same-year`.
|
|
19
|
+
*
|
|
20
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
21
|
+
* provided path. It supports userMessage overrides applied at the
|
|
22
|
+
* pipeline level.
|
|
23
|
+
*/
|
|
24
|
+
export declare const sameYear: (other: Date) => ValidationRule;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Same Year
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance representing a date in
|
|
7
|
+
* the same calendar year as the provided `other` date.
|
|
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
|
+
* Ensures the input is a Date instance representing a date in the
|
|
19
|
+
* same calendar year as the provided `other` date.
|
|
20
|
+
*
|
|
21
|
+
* - Non-Date values emit `date.not.date`.
|
|
22
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
23
|
+
* - Dates not matching the same year emit `date.not.same-year`.
|
|
24
|
+
*
|
|
25
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
26
|
+
* provided path. It supports userMessage overrides applied at the
|
|
27
|
+
* pipeline level.
|
|
28
|
+
*/
|
|
29
|
+
export const sameYear = (other) => {
|
|
30
|
+
const rule = async (value, path) => {
|
|
31
|
+
const structuralType = detectStructuralType(value);
|
|
32
|
+
if (!(value instanceof Date)) {
|
|
33
|
+
return [
|
|
34
|
+
validationEvent('error', 'date.not.date', path, `Expected 'Date' but received '${structuralType}'.`, `Please provide a valid date.`, { value, expected: 'Date', actual: structuralType }),
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
if (isNaN(value.getTime())) {
|
|
38
|
+
return [
|
|
39
|
+
validationEvent('error', 'date.is.invalid', path, `Date value is invalid.`, `Please provide a valid date.`, { value, expected: 'valid Date', actual: value }),
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
if (value.getUTCFullYear() !== other.getUTCFullYear()) {
|
|
43
|
+
return [
|
|
44
|
+
validationEvent('error', 'date.not.same-year', path, `${safeStringify(value)} must be in the same year as ${other.toISOString()}.`, `Please provide a date in the correct year.`, {
|
|
45
|
+
value,
|
|
46
|
+
expected: other.toISOString().slice(0, 4),
|
|
47
|
+
actual: value.toISOString().slice(0, 4),
|
|
48
|
+
}),
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
return [];
|
|
52
|
+
};
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
rule.__janeFactory = true;
|
|
55
|
+
return rule;
|
|
56
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Too Early
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance that is not earlier
|
|
7
|
+
* than the provided `min` boundary.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
import type { ValidationRule } from '../../shapes';
|
|
12
|
+
/**
|
|
13
|
+
* Ensures the input is a Date instance that is not earlier than the
|
|
14
|
+
* provided `min` boundary. The comparison is inclusive: value must be
|
|
15
|
+
* ≥ min.
|
|
16
|
+
*
|
|
17
|
+
* - Non-Date values emit `date.not.date`.
|
|
18
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
19
|
+
* - Dates < min emit `date.too.early`.
|
|
20
|
+
*
|
|
21
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
22
|
+
* provided path. It supports userMessage overrides applied at the
|
|
23
|
+
* pipeline level.
|
|
24
|
+
*/
|
|
25
|
+
export declare const tooEarly: (min: Date) => ValidationRule;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Too Early
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance that is not earlier
|
|
7
|
+
* than the provided `min` boundary.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
import { validationEvent } from '../../pipeline';
|
|
12
|
+
import { detectStructuralType } from '../../pipeline/scan';
|
|
13
|
+
import { safeStringify } from '../../common';
|
|
14
|
+
/* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— *\
|
|
15
|
+
|* Implementation *|
|
|
16
|
+
\* ——— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ————— * ——— */
|
|
17
|
+
/**
|
|
18
|
+
* Ensures the input is a Date instance that is not earlier than the
|
|
19
|
+
* provided `min` boundary. The comparison is inclusive: value must be
|
|
20
|
+
* ≥ min.
|
|
21
|
+
*
|
|
22
|
+
* - Non-Date values emit `date.not.date`.
|
|
23
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
24
|
+
* - Dates < min emit `date.too.early`.
|
|
25
|
+
*
|
|
26
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
27
|
+
* provided path. It supports userMessage overrides applied at the
|
|
28
|
+
* pipeline level.
|
|
29
|
+
*/
|
|
30
|
+
export const tooEarly = (min) => {
|
|
31
|
+
const rule = async (value, path) => {
|
|
32
|
+
const structuralType = detectStructuralType(value);
|
|
33
|
+
if (!(value instanceof Date)) {
|
|
34
|
+
return [
|
|
35
|
+
validationEvent('error', 'date.not.date', path, `Expected 'Date' but received '${structuralType}'.`, `Please provide a valid date.`, { value, expected: 'Date', actual: structuralType }),
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
if (isNaN(value.getTime())) {
|
|
39
|
+
return [
|
|
40
|
+
validationEvent('error', 'date.is.invalid', path, `Date value is invalid.`, `Please provide a valid date.`, { value, expected: 'valid Date', actual: value }),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
if (value.getTime() < min.getTime()) {
|
|
44
|
+
return [
|
|
45
|
+
validationEvent('error', 'date.too.early', path, `${safeStringify(value)} must not be earlier than ${min.toISOString()}.`, `Please provide a later date.`, {
|
|
46
|
+
value: value.toISOString(),
|
|
47
|
+
expected: `>= ${min.toISOString()}`,
|
|
48
|
+
actual: value.toISOString(),
|
|
49
|
+
}),
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
return [];
|
|
53
|
+
};
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
rule.__janeFactory = true;
|
|
56
|
+
return rule;
|
|
57
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Validators | Too Early
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
* @package @clementine-solutions/jane
|
|
6
|
+
* @description Ensures the input is a Date instance that is not later than
|
|
7
|
+
* the provided `max` boundary.
|
|
8
|
+
* @see https://jane-io.com
|
|
9
|
+
* ----------------------------------------------------------------------------
|
|
10
|
+
*/
|
|
11
|
+
import type { ValidationRule } from '../../shapes';
|
|
12
|
+
/**
|
|
13
|
+
* Ensures the input is a Date instance that is not later than the
|
|
14
|
+
* provided `max` boundary. The comparison is inclusive: value must be
|
|
15
|
+
* ≤ max.
|
|
16
|
+
*
|
|
17
|
+
* - Non-Date values emit `date.not.date`.
|
|
18
|
+
* - Invalid Date instances emit `date.is.invalid`.
|
|
19
|
+
* - Dates > max emit `date.too.late`.
|
|
20
|
+
*
|
|
21
|
+
* This rule is pure, total, async-compatible, and preserves the
|
|
22
|
+
* provided path. It supports userMessage overrides applied at the
|
|
23
|
+
* pipeline level.
|
|
24
|
+
*/
|
|
25
|
+
export declare const tooLate: (max: Date) => ValidationRule;
|