@bgord/tools 1.3.24 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/age-years.vo.d.ts +11 -0
- package/dist/src/age-years.vo.js +6 -0
- package/dist/{age.vo.js → src/age.vo.js} +2 -1
- package/dist/src/api-key.vo.d.ts +7 -0
- package/dist/src/api-key.vo.js +7 -0
- package/dist/src/basename.vo.d.ts +12 -0
- package/dist/src/basename.vo.js +22 -0
- package/dist/src/day-iso-id.vo.d.ts +9 -0
- package/dist/{day-iso-id.vo.js → src/day-iso-id.vo.js} +4 -8
- package/dist/{day.vo.js → src/day.vo.js} +7 -6
- package/dist/src/directory-path-absolute.vo.d.ts +12 -0
- package/dist/{directory-path-absolute.vo.js → src/directory-path-absolute.vo.js} +5 -12
- package/dist/src/directory-path-relative.vo.d.ts +12 -0
- package/dist/{directory-path-relative.vo.js → src/directory-path-relative.vo.js} +5 -12
- package/dist/src/distance-value.vo.d.ts +7 -0
- package/dist/src/distance-value.vo.js +5 -0
- package/dist/{distance.vo.js → src/distance.vo.js} +7 -6
- package/dist/src/division-factor.vo.d.ts +7 -0
- package/dist/src/division-factor.vo.js +5 -0
- package/dist/src/duration-ms.vo.d.ts +6 -0
- package/dist/src/duration-ms.vo.js +5 -0
- package/dist/{duration.service.js → src/duration.service.js} +2 -1
- package/dist/src/email.vo.d.ts +6 -0
- package/dist/src/email.vo.js +4 -0
- package/dist/{etags.vo.js → src/etags.vo.js} +3 -2
- package/dist/src/extension.vo.d.ts +9 -0
- package/dist/src/extension.vo.js +15 -0
- package/dist/src/feature-flag-value.vo.d.ts +10 -0
- package/dist/{feature-flag-value.vo.js → src/feature-flag-value.vo.js} +2 -2
- package/dist/src/file-path-absolute-schema.vo.d.ts +17 -0
- package/dist/{file-path-absolute-schema.vo.js → src/file-path-absolute-schema.vo.js} +6 -13
- package/dist/src/file-path-relative-schema.vo.d.ts +17 -0
- package/dist/{file-path-relative-schema.vo.js → src/file-path-relative-schema.vo.js} +6 -13
- package/dist/{file-path.vo.js → src/file-path.vo.js} +5 -4
- package/dist/src/filename-affix.vo.d.ts +13 -0
- package/dist/{filename-affix.vo.js → src/filename-affix.vo.js} +4 -9
- package/dist/src/filename-from-string.vo.d.ts +10 -0
- package/dist/{filename-from-string.vo.js → src/filename-from-string.vo.js} +5 -8
- package/dist/{filename.vo.js → src/filename.vo.js} +8 -7
- package/dist/src/height-milimiters.vo.d.ts +7 -0
- package/dist/src/height-milimiters.vo.js +8 -0
- package/dist/{height.vo.js → src/height.vo.js} +4 -3
- package/dist/src/hour-value.vo.d.ts +7 -0
- package/dist/src/hour-value.vo.js +5 -0
- package/dist/{hour.vo.js → src/hour.vo.js} +3 -2
- package/dist/src/iban-schema.vo.d.ts +7 -0
- package/dist/src/iban-schema.vo.js +7 -0
- package/dist/{iban.vo.js → src/iban.vo.js} +2 -1
- package/dist/src/image.vo.d.ts +13 -0
- package/dist/src/image.vo.js +10 -0
- package/dist/src/integer-non-negative.vo.d.ts +7 -0
- package/dist/src/integer-non-negative.vo.js +8 -0
- package/dist/src/integer-positive.vo.d.ts +7 -0
- package/dist/src/integer-positive.vo.js +5 -0
- package/dist/src/integer.vo.d.ts +6 -0
- package/dist/src/integer.vo.js +4 -0
- package/dist/src/language.vo.d.ts +7 -0
- package/dist/{language.vo.js → src/language.vo.js} +2 -2
- package/dist/src/mime-value.vo.d.ts +7 -0
- package/dist/{mime-value.vo.js → src/mime-value.vo.js} +4 -7
- package/dist/{mime.vo.js → src/mime.vo.js} +2 -1
- package/dist/src/mimes.js +19 -0
- package/dist/src/minute-value.vo.d.ts +7 -0
- package/dist/src/minute-value.vo.js +5 -0
- package/dist/{minute.vo.js → src/minute.vo.js} +3 -2
- package/dist/src/money-amount.vo.d.ts +7 -0
- package/dist/src/money-amount.vo.js +5 -0
- package/dist/{money.vo.js → src/money.vo.js} +7 -6
- package/dist/src/month-iso-id.vo.d.ts +8 -0
- package/dist/{month-iso-id.vo.js → src/month-iso-id.vo.js} +5 -9
- package/dist/{month.vo.js → src/month.vo.js} +5 -4
- package/dist/src/multiplication-factor.vo.d.ts +7 -0
- package/dist/src/multiplication-factor.vo.js +8 -0
- package/dist/src/object-key.vo.d.ts +11 -0
- package/dist/src/object-key.vo.js +19 -0
- package/dist/src/package-version-schema.vo.d.ts +8 -0
- package/dist/{package-version-schema.vo.js → src/package-version-schema.vo.js} +4 -7
- package/dist/{package-version.vo.js → src/package-version.vo.js} +3 -4
- package/dist/src/pagination-page.vo.d.ts +6 -0
- package/dist/src/pagination-page.vo.js +3 -0
- package/dist/src/pagination-skip.vo.d.ts +7 -0
- package/dist/src/pagination-skip.vo.js +3 -0
- package/dist/src/pagination-take.vo.d.ts +7 -0
- package/dist/src/pagination-take.vo.js +3 -0
- package/dist/{pagination.service.js → src/pagination.service.js} +8 -7
- package/dist/src/quarter-iso-id.vo.d.ts +8 -0
- package/dist/src/quarter-iso-id.vo.js +7 -0
- package/dist/{quarter.vo.js → src/quarter.vo.js} +3 -2
- package/dist/src/reordering-item-position-value.vo.d.ts +6 -0
- package/dist/src/reordering-item-position-value.vo.js +3 -0
- package/dist/{reordering.service.d.ts → src/reordering.service.d.ts} +9 -9
- package/dist/{reordering.service.js → src/reordering.service.js} +7 -7
- package/dist/src/revision-value.vo.d.ts +7 -0
- package/dist/src/revision-value.vo.js +3 -0
- package/dist/{revision.vo.js → src/revision.vo.js} +3 -2
- package/dist/{rounding-decimal.strategy.d.ts → src/rounding-decimal.strategy.d.ts} +2 -2
- package/dist/src/rounding-decimal.strategy.js +14 -0
- package/dist/src/size-bytes.vo.d.ts +6 -0
- package/dist/src/size-bytes.vo.js +5 -0
- package/dist/{size.vo.js → src/size.vo.js} +5 -4
- package/dist/src/time-zone-offset-value.vo.d.ts +8 -0
- package/dist/src/time-zone-offset-value.vo.js +13 -0
- package/dist/src/timestamp-value.vo.d.ts +6 -0
- package/dist/src/timestamp-value.vo.js +5 -0
- package/dist/{timestamp.vo.js → src/timestamp.vo.js} +2 -1
- package/dist/src/timezone.vo.d.ts +9 -0
- package/dist/{timezone.vo.js → src/timezone.vo.js} +7 -10
- package/dist/src/url-with-slash.vo.d.ts +6 -0
- package/dist/src/url-with-slash.vo.js +5 -0
- package/dist/src/url-without-slash.vo.d.ts +6 -0
- package/dist/src/url-without-slash.vo.js +5 -0
- package/dist/src/week-iso-id.vo.d.ts +8 -0
- package/dist/{week-iso-id.vo.js → src/week-iso-id.vo.js} +5 -9
- package/dist/{week.vo.js → src/week.vo.js} +5 -4
- package/dist/src/weekday-iso-id.vo.d.ts +7 -0
- package/dist/src/weekday-iso-id.vo.js +5 -0
- package/dist/{weekday.vo.js → src/weekday.vo.js} +9 -8
- package/dist/src/weight-grams.vo.d.ts +7 -0
- package/dist/src/weight-grams.vo.js +5 -0
- package/dist/{weight.vo.js → src/weight.vo.js} +8 -7
- package/dist/src/year-iso-id.vo.d.ts +7 -0
- package/dist/src/year-iso-id.vo.js +7 -0
- package/dist/{year.vo.js → src/year.vo.js} +6 -5
- package/dist/tests/age-years.vo.test.d.ts +1 -0
- package/dist/tests/age-years.vo.test.js +24 -0
- package/dist/tests/age.vo.test.d.ts +1 -0
- package/dist/tests/age.vo.test.js +106 -0
- package/dist/tests/api-key.vo.test.d.ts +1 -0
- package/dist/tests/api-key.vo.test.js +24 -0
- package/dist/tests/basename.vo.test.d.ts +1 -0
- package/dist/tests/basename.vo.test.js +53 -0
- package/dist/tests/batch.test.d.ts +1 -0
- package/dist/tests/batch.test.js +24 -0
- package/dist/tests/date-calculator.service.test.d.ts +1 -0
- package/dist/tests/date-calculator.service.test.js +32 -0
- package/dist/tests/date-formatter.service.test.d.ts +1 -0
- package/dist/tests/date-formatter.service.test.js +22 -0
- package/dist/tests/date-range.vo.test.d.ts +1 -0
- package/dist/tests/date-range.vo.test.js +49 -0
- package/dist/tests/day-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/day-iso-id.vo.test.js +36 -0
- package/dist/tests/day.vo.test.d.ts +1 -0
- package/dist/tests/day.vo.test.js +68 -0
- package/dist/tests/directory-path-absolute.vo.test.d.ts +1 -0
- package/dist/tests/directory-path-absolute.vo.test.js +47 -0
- package/dist/tests/directory-path-relative.vo.test.d.ts +1 -0
- package/dist/tests/directory-path-relative.vo.test.js +44 -0
- package/dist/tests/distance-value.vo.test.d.ts +1 -0
- package/dist/tests/distance-value.vo.test.js +21 -0
- package/dist/tests/distance.vo.test.d.ts +1 -0
- package/dist/tests/distance.vo.test.js +74 -0
- package/dist/tests/division-factor.vo.test.d.ts +1 -0
- package/dist/tests/division-factor.vo.test.js +21 -0
- package/dist/tests/dll.service.test.d.ts +1 -0
- package/dist/tests/dll.service.test.js +381 -0
- package/dist/tests/duration-ms.vo.test.d.ts +1 -0
- package/dist/tests/duration-ms.vo.test.js +18 -0
- package/dist/tests/duration.service.test.d.ts +1 -0
- package/dist/tests/duration.service.test.js +126 -0
- package/dist/tests/email-mask.service.test.d.ts +1 -0
- package/dist/tests/email-mask.service.test.js +15 -0
- package/dist/tests/email.vo.test.d.ts +1 -0
- package/dist/tests/email.vo.test.js +17 -0
- package/dist/tests/etags.vo.test.d.ts +1 -0
- package/dist/tests/etags.vo.test.js +54 -0
- package/dist/tests/extension.vo.test.d.ts +1 -0
- package/dist/tests/extension.vo.test.js +51 -0
- package/dist/tests/feature-flag-value.vo.test.d.ts +1 -0
- package/dist/tests/feature-flag-value.vo.test.js +12 -0
- package/dist/tests/feature-flag.vo.test.d.ts +1 -0
- package/dist/tests/feature-flag.vo.test.js +13 -0
- package/dist/tests/file-path-absolute-schema.vo.test.d.ts +1 -0
- package/dist/tests/file-path-absolute-schema.vo.test.js +53 -0
- package/dist/tests/file-path-relative-schema.vo.test.d.ts +1 -0
- package/dist/tests/file-path-relative-schema.vo.test.js +52 -0
- package/dist/tests/file-path.vo.test.d.ts +1 -0
- package/dist/tests/file-path.vo.test.js +74 -0
- package/dist/tests/filename-affix.vo.test.d.ts +1 -0
- package/dist/tests/filename-affix.vo.test.js +30 -0
- package/dist/tests/filename-from-string.vo.test.d.ts +1 -0
- package/dist/tests/filename-from-string.vo.test.js +37 -0
- package/dist/tests/filename.vo.test.d.ts +1 -0
- package/dist/tests/filename.vo.test.js +93 -0
- package/dist/tests/height-milimiters.vo.test.d.ts +1 -0
- package/dist/tests/height-milimiters.vo.test.js +21 -0
- package/dist/tests/height.vo.test.d.ts +1 -0
- package/dist/tests/height.vo.test.js +64 -0
- package/dist/tests/hour-value.vo.test.d.ts +1 -0
- package/dist/tests/hour-value.vo.test.js +24 -0
- package/dist/tests/hour.vo.test.d.ts +1 -0
- package/dist/tests/hour.vo.test.js +64 -0
- package/dist/tests/iban-mask.service.test.d.ts +1 -0
- package/dist/tests/iban-mask.service.test.js +13 -0
- package/dist/tests/iban-schema.vo.test.d.ts +1 -0
- package/dist/tests/iban-schema.vo.test.js +43 -0
- package/dist/tests/iban.vo.test.d.ts +1 -0
- package/dist/tests/iban.vo.test.js +46 -0
- package/dist/tests/image.vo.test.d.ts +1 -0
- package/dist/tests/image.vo.test.js +41 -0
- package/dist/tests/integer-non-negative.vo.test.d.ts +1 -0
- package/dist/tests/integer-non-negative.vo.test.js +22 -0
- package/dist/tests/integer-positive.vo.test.d.ts +1 -0
- package/dist/tests/integer-positive.vo.test.js +21 -0
- package/dist/tests/integer.vo.test.d.ts +1 -0
- package/dist/tests/integer.vo.test.js +21 -0
- package/dist/tests/language.vo.test.d.ts +1 -0
- package/dist/tests/language.vo.test.js +28 -0
- package/dist/tests/linear-regression.service.test.d.ts +1 -0
- package/dist/tests/linear-regression.service.test.js +111 -0
- package/dist/tests/mean.service.test.d.ts +1 -0
- package/dist/tests/mean.service.test.js +23 -0
- package/dist/tests/mime-registry-entry.vo.test.d.ts +1 -0
- package/dist/tests/mime-registry-entry.vo.test.js +15 -0
- package/dist/tests/mime-registry.service.test.d.ts +1 -0
- package/dist/tests/mime-registry.service.test.js +45 -0
- package/dist/tests/mime-value.vo.test.d.ts +1 -0
- package/dist/tests/mime-value.vo.test.js +49 -0
- package/dist/tests/mime.vo.test.d.ts +1 -0
- package/dist/tests/mime.vo.test.js +53 -0
- package/dist/tests/mimes.test.d.ts +1 -0
- package/dist/tests/mimes.test.js +28 -0
- package/dist/tests/min-max-scaler.service.test.d.ts +1 -0
- package/dist/tests/min-max-scaler.service.test.js +116 -0
- package/dist/tests/minute-value.vo.test.d.ts +1 -0
- package/dist/tests/minute-value.vo.test.js +24 -0
- package/dist/tests/minute.vo.test.d.ts +1 -0
- package/dist/tests/minute.vo.test.js +64 -0
- package/dist/tests/mocks.d.ts +6 -0
- package/dist/tests/mocks.js +7 -0
- package/dist/tests/money-amount.vo.test.d.ts +1 -0
- package/dist/tests/money-amount.vo.test.js +21 -0
- package/dist/tests/money.vo.test.d.ts +1 -0
- package/dist/tests/money.vo.test.js +90 -0
- package/dist/tests/month-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/month-iso-id.vo.test.js +36 -0
- package/dist/tests/month.vo.test.d.ts +1 -0
- package/dist/tests/month.vo.test.js +65 -0
- package/dist/tests/multiplication-factor.vo.test.d.ts +1 -0
- package/dist/tests/multiplication-factor.vo.test.js +19 -0
- package/dist/tests/noop.test.d.ts +1 -0
- package/dist/tests/noop.test.js +12 -0
- package/dist/tests/object-key.vo.test.d.ts +1 -0
- package/dist/tests/object-key.vo.test.js +56 -0
- package/dist/tests/outlier-detector.service.test.d.ts +1 -0
- package/dist/tests/outlier-detector.service.test.js +35 -0
- package/dist/tests/package-version-schema.vo.test.d.ts +1 -0
- package/dist/tests/package-version-schema.vo.test.js +32 -0
- package/dist/tests/package-version.vo.test.d.ts +1 -0
- package/dist/tests/package-version.vo.test.js +138 -0
- package/dist/tests/pagination-page.vo.test.d.ts +1 -0
- package/dist/tests/pagination-page.vo.test.js +26 -0
- package/dist/tests/pagination-skip.vo.test.d.ts +1 -0
- package/dist/tests/pagination-skip.vo.test.js +23 -0
- package/dist/tests/pagination-take.vo.test.d.ts +1 -0
- package/dist/tests/pagination-take.vo.test.js +25 -0
- package/dist/tests/pagination.service.test.d.ts +1 -0
- package/dist/tests/pagination.service.test.js +92 -0
- package/dist/tests/percentage.service.test.d.ts +1 -0
- package/dist/tests/percentage.service.test.js +16 -0
- package/dist/tests/population-standard-deviation.service.test.d.ts +1 -0
- package/dist/tests/population-standard-deviation.service.test.js +20 -0
- package/dist/tests/quarter-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/quarter-iso-id.vo.test.js +30 -0
- package/dist/tests/quarter.vo.test.d.ts +1 -0
- package/dist/tests/quarter.vo.test.js +54 -0
- package/dist/tests/random.service.test.d.ts +1 -0
- package/dist/tests/random.service.test.js +93 -0
- package/dist/tests/rate-limiter.service.test.d.ts +1 -0
- package/dist/tests/rate-limiter.service.test.js +39 -0
- package/dist/tests/relative-date.vo.test.d.ts +1 -0
- package/dist/tests/relative-date.vo.test.js +22 -0
- package/dist/tests/reordering-item-position-value.vo.test.d.ts +1 -0
- package/dist/tests/reordering-item-position-value.vo.test.js +21 -0
- package/dist/tests/reordering.service.test.d.ts +1 -0
- package/dist/tests/reordering.service.test.js +76 -0
- package/dist/tests/repeat.test.d.ts +1 -0
- package/dist/tests/repeat.test.js +8 -0
- package/dist/tests/revision-value.vo.test.d.ts +1 -0
- package/dist/tests/revision-value.vo.test.js +21 -0
- package/dist/tests/revision.vo.test.d.ts +1 -0
- package/dist/tests/revision.vo.test.js +52 -0
- package/dist/tests/rounding-decimal.strategy.test.d.ts +1 -0
- package/dist/tests/rounding-decimal.strategy.test.js +17 -0
- package/dist/tests/rounding-down.strategy.test.d.ts +1 -0
- package/dist/tests/rounding-down.strategy.test.js +9 -0
- package/dist/tests/rounding-to-nearest.strategy.test.d.ts +1 -0
- package/dist/tests/rounding-to-nearest.strategy.test.js +9 -0
- package/dist/tests/rounding-up.strategy.test.d.ts +1 -0
- package/dist/tests/rounding-up.strategy.test.js +9 -0
- package/dist/tests/size-bytes.vo.test.d.ts +1 -0
- package/dist/tests/size-bytes.vo.test.js +21 -0
- package/dist/tests/size.vo.test.d.ts +1 -0
- package/dist/tests/size.vo.test.js +93 -0
- package/dist/tests/slug.service.test.d.ts +1 -0
- package/dist/tests/slug.service.test.js +45 -0
- package/dist/tests/sum.service.test.d.ts +1 -0
- package/dist/tests/sum.service.test.js +22 -0
- package/dist/tests/thousands-separator.service.test.d.ts +1 -0
- package/dist/tests/thousands-separator.service.test.js +27 -0
- package/dist/tests/time-zone-offset-value.test.d.ts +1 -0
- package/dist/tests/time-zone-offset-value.test.js +27 -0
- package/dist/tests/timestamp-value.vo.test.d.ts +1 -0
- package/dist/tests/timestamp-value.vo.test.js +21 -0
- package/dist/tests/timestamp.vo.test.d.ts +1 -0
- package/dist/tests/timestamp.vo.test.js +73 -0
- package/dist/tests/timezone.vo.test.d.ts +1 -0
- package/dist/tests/timezone.vo.test.js +29 -0
- package/dist/tests/url-with-slash.vo.test.d.ts +1 -0
- package/dist/tests/url-with-slash.vo.test.js +24 -0
- package/dist/tests/url-without-slash.vo.test.d.ts +1 -0
- package/dist/tests/url-without-slash.vo.test.js +25 -0
- package/dist/tests/visually-unambiguous-characters-generator.service.test.d.ts +1 -0
- package/dist/tests/visually-unambiguous-characters-generator.service.test.js +89 -0
- package/dist/tests/week-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/week-iso-id.vo.test.js +37 -0
- package/dist/tests/week.vo.test.d.ts +1 -0
- package/dist/tests/week.vo.test.js +64 -0
- package/dist/tests/weekday-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/weekday-iso-id.vo.test.js +24 -0
- package/dist/tests/weekday.vo.test.d.ts +1 -0
- package/dist/tests/weekday.vo.test.js +51 -0
- package/dist/tests/weight-grams.vo.test.d.ts +1 -0
- package/dist/tests/weight-grams.vo.test.js +21 -0
- package/dist/tests/weight.vo.test.d.ts +1 -0
- package/dist/tests/weight.vo.test.js +66 -0
- package/dist/tests/year-iso-id.vo.test.d.ts +1 -0
- package/dist/tests/year-iso-id.vo.test.js +23 -0
- package/dist/tests/year.vo.test.d.ts +1 -0
- package/dist/tests/year.vo.test.js +79 -0
- package/dist/tests/z-score.service.test.d.ts +1 -0
- package/dist/tests/z-score.service.test.js +26 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -12
- package/dist/age-years.vo.d.ts +0 -11
- package/dist/age-years.vo.js +0 -11
- package/dist/api-key.vo.d.ts +0 -8
- package/dist/api-key.vo.js +0 -11
- package/dist/basename.vo.d.ts +0 -12
- package/dist/basename.vo.js +0 -27
- package/dist/day-iso-id.vo.d.ts +0 -9
- package/dist/directory-path-absolute.vo.d.ts +0 -12
- package/dist/directory-path-relative.vo.d.ts +0 -12
- package/dist/distance-value.vo.d.ts +0 -7
- package/dist/distance-value.vo.js +0 -9
- package/dist/division-factor.vo.d.ts +0 -7
- package/dist/division-factor.vo.js +0 -8
- package/dist/duration-ms.vo.d.ts +0 -6
- package/dist/duration-ms.vo.js +0 -4
- package/dist/email.vo.d.ts +0 -6
- package/dist/email.vo.js +0 -4
- package/dist/extension.vo.d.ts +0 -9
- package/dist/extension.vo.js +0 -21
- package/dist/feature-flag-value.vo.d.ts +0 -10
- package/dist/file-path-absolute-schema.vo.d.ts +0 -14
- package/dist/file-path-relative-schema.vo.d.ts +0 -14
- package/dist/filename-affix.vo.d.ts +0 -13
- package/dist/filename-from-string.vo.d.ts +0 -10
- package/dist/height-milimiters.vo.d.ts +0 -7
- package/dist/height-milimiters.vo.js +0 -12
- package/dist/hour-value.vo.d.ts +0 -7
- package/dist/hour-value.vo.js +0 -10
- package/dist/iban-schema.vo.d.ts +0 -7
- package/dist/iban-schema.vo.js +0 -12
- package/dist/image.vo.d.ts +0 -13
- package/dist/image.vo.js +0 -20
- package/dist/integer-non-negative.vo.d.ts +0 -7
- package/dist/integer-non-negative.vo.js +0 -12
- package/dist/integer-positive.vo.d.ts +0 -7
- package/dist/integer-positive.vo.js +0 -9
- package/dist/integer.vo.d.ts +0 -6
- package/dist/integer.vo.js +0 -4
- package/dist/language.vo.d.ts +0 -7
- package/dist/mime-value.vo.d.ts +0 -6
- package/dist/mimes.js +0 -18
- package/dist/minute-value.vo.d.ts +0 -7
- package/dist/minute-value.vo.js +0 -10
- package/dist/money-amount.vo.d.ts +0 -7
- package/dist/money-amount.vo.js +0 -9
- package/dist/month-iso-id.vo.d.ts +0 -8
- package/dist/multiplication-factor.vo.d.ts +0 -7
- package/dist/multiplication-factor.vo.js +0 -11
- package/dist/object-key.vo.d.ts +0 -11
- package/dist/object-key.vo.js +0 -24
- package/dist/package-version-schema.vo.d.ts +0 -8
- package/dist/pagination-page.vo.d.ts +0 -6
- package/dist/pagination-page.vo.js +0 -7
- package/dist/pagination-skip.vo.d.ts +0 -7
- package/dist/pagination-skip.vo.js +0 -6
- package/dist/pagination-take.vo.d.ts +0 -7
- package/dist/pagination-take.vo.js +0 -6
- package/dist/quarter-iso-id.vo.d.ts +0 -7
- package/dist/quarter-iso-id.vo.js +0 -11
- package/dist/reordering-item-position-value.vo.d.ts +0 -6
- package/dist/reordering-item-position-value.vo.js +0 -6
- package/dist/revision-value.vo.d.ts +0 -7
- package/dist/revision-value.vo.js +0 -6
- package/dist/rounding-decimal.strategy.js +0 -19
- package/dist/size-bytes.vo.d.ts +0 -6
- package/dist/size-bytes.vo.js +0 -9
- package/dist/time-zone-offset-value.vo.d.ts +0 -8
- package/dist/time-zone-offset-value.vo.js +0 -17
- package/dist/timestamp-value.vo.d.ts +0 -6
- package/dist/timestamp-value.vo.js +0 -9
- package/dist/timezone.vo.d.ts +0 -9
- package/dist/url-with-slash.vo.d.ts +0 -6
- package/dist/url-with-slash.vo.js +0 -8
- package/dist/url-without-slash.vo.d.ts +0 -6
- package/dist/url-without-slash.vo.js +0 -8
- package/dist/week-iso-id.vo.d.ts +0 -8
- package/dist/weekday-iso-id.vo.d.ts +0 -7
- package/dist/weekday-iso-id.vo.js +0 -10
- package/dist/weight-grams.vo.d.ts +0 -7
- package/dist/weight-grams.vo.js +0 -9
- package/dist/year-iso-id.vo.d.ts +0 -7
- package/dist/year-iso-id.vo.js +0 -10
- package/dist/{age.vo.d.ts → src/age.vo.d.ts} +0 -0
- package/dist/{batch.d.ts → src/batch.d.ts} +0 -0
- package/dist/{batch.js → src/batch.js} +0 -0
- package/dist/{date-calculator.service.d.ts → src/date-calculator.service.d.ts} +0 -0
- package/dist/{date-calculator.service.js → src/date-calculator.service.js} +0 -0
- package/dist/{date-formatter.service.d.ts → src/date-formatter.service.d.ts} +0 -0
- package/dist/{date-formatter.service.js → src/date-formatter.service.js} +0 -0
- package/dist/{date-range.vo.d.ts → src/date-range.vo.d.ts} +0 -0
- package/dist/{date-range.vo.js → src/date-range.vo.js} +0 -0
- package/dist/{day.vo.d.ts → src/day.vo.d.ts} +1 -1
- /package/dist/{distance.vo.d.ts → src/distance.vo.d.ts} +0 -0
- /package/dist/{dll.service.d.ts → src/dll.service.d.ts} +0 -0
- /package/dist/{dll.service.js → src/dll.service.js} +0 -0
- /package/dist/{duration.service.d.ts → src/duration.service.d.ts} +0 -0
- /package/dist/{email-mask.service.d.ts → src/email-mask.service.d.ts} +0 -0
- /package/dist/{email-mask.service.js → src/email-mask.service.js} +0 -0
- /package/dist/{etags.vo.d.ts → src/etags.vo.d.ts} +0 -0
- /package/dist/{feature-flag.vo.d.ts → src/feature-flag.vo.d.ts} +0 -0
- /package/dist/{feature-flag.vo.js → src/feature-flag.vo.js} +0 -0
- /package/dist/{file-path.vo.d.ts → src/file-path.vo.d.ts} +0 -0
- /package/dist/{filename.vo.d.ts → src/filename.vo.d.ts} +0 -0
- /package/dist/{height.vo.d.ts → src/height.vo.d.ts} +0 -0
- /package/dist/{hour.vo.d.ts → src/hour.vo.d.ts} +0 -0
- /package/dist/{iban-mask.service.d.ts → src/iban-mask.service.d.ts} +0 -0
- /package/dist/{iban-mask.service.js → src/iban-mask.service.js} +0 -0
- /package/dist/{iban.vo.d.ts → src/iban.vo.d.ts} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{linear-regression.service.d.ts → src/linear-regression.service.d.ts} +0 -0
- /package/dist/{linear-regression.service.js → src/linear-regression.service.js} +0 -0
- /package/dist/{mean.service.d.ts → src/mean.service.d.ts} +0 -0
- /package/dist/{mean.service.js → src/mean.service.js} +0 -0
- /package/dist/{mime-registry-entry.vo.d.ts → src/mime-registry-entry.vo.d.ts} +0 -0
- /package/dist/{mime-registry-entry.vo.js → src/mime-registry-entry.vo.js} +0 -0
- /package/dist/{mime-registry.service.d.ts → src/mime-registry.service.d.ts} +0 -0
- /package/dist/{mime-registry.service.js → src/mime-registry.service.js} +0 -0
- /package/dist/{mime.vo.d.ts → src/mime.vo.d.ts} +0 -0
- /package/dist/{mimes.d.ts → src/mimes.d.ts} +0 -0
- /package/dist/{min-max-scaler.service.d.ts → src/min-max-scaler.service.d.ts} +0 -0
- /package/dist/{min-max-scaler.service.js → src/min-max-scaler.service.js} +0 -0
- /package/dist/{minute.vo.d.ts → src/minute.vo.d.ts} +0 -0
- /package/dist/{money.vo.d.ts → src/money.vo.d.ts} +0 -0
- /package/dist/{month.vo.d.ts → src/month.vo.d.ts} +0 -0
- /package/dist/{noop.service.d.ts → src/noop.service.d.ts} +0 -0
- /package/dist/{noop.service.js → src/noop.service.js} +0 -0
- /package/dist/{outlier-detector.service.d.ts → src/outlier-detector.service.d.ts} +0 -0
- /package/dist/{outlier-detector.service.js → src/outlier-detector.service.js} +0 -0
- /package/dist/{package-version.vo.d.ts → src/package-version.vo.d.ts} +0 -0
- /package/dist/{pagination.service.d.ts → src/pagination.service.d.ts} +0 -0
- /package/dist/{percentage.service.d.ts → src/percentage.service.d.ts} +0 -0
- /package/dist/{percentage.service.js → src/percentage.service.js} +0 -0
- /package/dist/{population-standard-deviation.service.d.ts → src/population-standard-deviation.service.d.ts} +0 -0
- /package/dist/{population-standard-deviation.service.js → src/population-standard-deviation.service.js} +0 -0
- /package/dist/{quarter.vo.d.ts → src/quarter.vo.d.ts} +0 -0
- /package/dist/{random.service.d.ts → src/random.service.d.ts} +0 -0
- /package/dist/{random.service.js → src/random.service.js} +0 -0
- /package/dist/{rate-limiter.service.d.ts → src/rate-limiter.service.d.ts} +0 -0
- /package/dist/{rate-limiter.service.js → src/rate-limiter.service.js} +0 -0
- /package/dist/{relative-date.vo.d.ts → src/relative-date.vo.d.ts} +0 -0
- /package/dist/{relative-date.vo.js → src/relative-date.vo.js} +0 -0
- /package/dist/{repeat.d.ts → src/repeat.d.ts} +0 -0
- /package/dist/{repeat.js → src/repeat.js} +0 -0
- /package/dist/{revision.vo.d.ts → src/revision.vo.d.ts} +0 -0
- /package/dist/{rounding-down.strategy.d.ts → src/rounding-down.strategy.d.ts} +0 -0
- /package/dist/{rounding-down.strategy.js → src/rounding-down.strategy.js} +0 -0
- /package/dist/{rounding-to-nearest.strategy.d.ts → src/rounding-to-nearest.strategy.d.ts} +0 -0
- /package/dist/{rounding-to-nearest.strategy.js → src/rounding-to-nearest.strategy.js} +0 -0
- /package/dist/{rounding-up.strategy.d.ts → src/rounding-up.strategy.d.ts} +0 -0
- /package/dist/{rounding-up.strategy.js → src/rounding-up.strategy.js} +0 -0
- /package/dist/{rounding.strategy.d.ts → src/rounding.strategy.d.ts} +0 -0
- /package/dist/{rounding.strategy.js → src/rounding.strategy.js} +0 -0
- /package/dist/{size.vo.d.ts → src/size.vo.d.ts} +0 -0
- /package/dist/{slug.service.d.ts → src/slug.service.d.ts} +0 -0
- /package/dist/{slug.service.js → src/slug.service.js} +0 -0
- /package/dist/{sum.service.d.ts → src/sum.service.d.ts} +0 -0
- /package/dist/{sum.service.js → src/sum.service.js} +0 -0
- /package/dist/{thousands-separator.service.d.ts → src/thousands-separator.service.d.ts} +0 -0
- /package/dist/{thousands-separator.service.js → src/thousands-separator.service.js} +0 -0
- /package/dist/{timestamp.vo.d.ts → src/timestamp.vo.d.ts} +0 -0
- /package/dist/{ts-utils.d.ts → src/ts-utils.d.ts} +0 -0
- /package/dist/{ts-utils.js → src/ts-utils.js} +0 -0
- /package/dist/{visually-unambiguous-characters-generator.service.d.ts → src/visually-unambiguous-characters-generator.service.d.ts} +0 -0
- /package/dist/{visually-unambiguous-characters-generator.service.js → src/visually-unambiguous-characters-generator.service.js} +0 -0
- /package/dist/{week.vo.d.ts → src/week.vo.d.ts} +0 -0
- /package/dist/{weekday.vo.d.ts → src/weekday.vo.d.ts} +0 -0
- /package/dist/{weight.vo.d.ts → src/weight.vo.d.ts} +0 -0
- /package/dist/{year.vo.d.ts → src/year.vo.d.ts} +0 -0
- /package/dist/{z-score.service.d.ts → src/z-score.service.d.ts} +0 -0
- /package/dist/{z-score.service.js → src/z-score.service.js} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { endOfYear, getYear, startOfYear } from "date-fns";
|
|
2
|
+
import * as v from "valibot";
|
|
2
3
|
import { DateRange } from "./date-range.vo";
|
|
3
4
|
import { Integer } from "./integer.vo";
|
|
4
5
|
import { Timestamp } from "./timestamp.vo";
|
|
@@ -16,14 +17,14 @@ export class Year extends DateRange {
|
|
|
16
17
|
return Year.fromTimestamp(now);
|
|
17
18
|
}
|
|
18
19
|
static fromNumber(candidate) {
|
|
19
|
-
return Year.fromIsoId(
|
|
20
|
+
return Year.fromIsoId(v.parse(YearIsoId, String(candidate)));
|
|
20
21
|
}
|
|
21
22
|
static fromIsoId(isoId) {
|
|
22
23
|
const year = Number(isoId);
|
|
23
24
|
return new Year(Timestamp.fromNumber(Date.UTC(year, 0, 1)), Timestamp.fromNumber(Date.UTC(year + 1, 0, 1) - 1));
|
|
24
25
|
}
|
|
25
26
|
toIsoId() {
|
|
26
|
-
return
|
|
27
|
+
return v.parse(YearIsoId, String(getYear(this.getStart().ms)));
|
|
27
28
|
}
|
|
28
29
|
isLeapYear() {
|
|
29
30
|
const year = getYear(this.getStart().ms);
|
|
@@ -34,14 +35,14 @@ export class Year extends DateRange {
|
|
|
34
35
|
return year % 4 === 0;
|
|
35
36
|
}
|
|
36
37
|
previous() {
|
|
37
|
-
return this.shift(
|
|
38
|
+
return this.shift(v.parse(Integer, -1));
|
|
38
39
|
}
|
|
39
40
|
next() {
|
|
40
|
-
return this.shift(
|
|
41
|
+
return this.shift(v.parse(Integer, 1));
|
|
41
42
|
}
|
|
42
43
|
shift(count) {
|
|
43
44
|
const year = getYear(this.getStart().ms) + count;
|
|
44
|
-
return Year.
|
|
45
|
+
return Year.fromNumber(year);
|
|
45
46
|
}
|
|
46
47
|
toString() {
|
|
47
48
|
return this.toIsoId();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { AgeYears } from "../src/age-years.vo";
|
|
4
|
+
describe("AgeYears", () => {
|
|
5
|
+
test("happy path", () => {
|
|
6
|
+
expect(v.safeParse(AgeYears, 0).success).toEqual(true);
|
|
7
|
+
expect(v.safeParse(AgeYears, 130).success).toEqual(true);
|
|
8
|
+
});
|
|
9
|
+
test("rejects non-number - null", () => {
|
|
10
|
+
expect(() => v.parse(AgeYears, null)).toThrow("age.years.type");
|
|
11
|
+
});
|
|
12
|
+
test("rejects non-number - string", () => {
|
|
13
|
+
expect(() => v.parse(AgeYears, "100")).toThrow("age.years.type");
|
|
14
|
+
});
|
|
15
|
+
test("rejects fraction", () => {
|
|
16
|
+
expect(() => v.parse(AgeYears, 100.5)).toThrow("age.years.type");
|
|
17
|
+
});
|
|
18
|
+
test("rejects negative", () => {
|
|
19
|
+
expect(() => v.parse(AgeYears, -1)).toThrow("age.years.invalid");
|
|
20
|
+
});
|
|
21
|
+
test("rejects 131", () => {
|
|
22
|
+
expect(() => v.parse(AgeYears, 131)).toThrow("age.years.invalid");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { Age } from "../src/age.vo";
|
|
4
|
+
import { AgeYears } from "../src/age-years.vo";
|
|
5
|
+
import { Timestamp } from "../src/timestamp.vo";
|
|
6
|
+
import * as mocks from "./mocks";
|
|
7
|
+
const min = v.parse(AgeYears, 0);
|
|
8
|
+
const max = v.parse(AgeYears, 130);
|
|
9
|
+
const twentyThree = v.parse(AgeYears, 23);
|
|
10
|
+
describe("Age", () => {
|
|
11
|
+
test("fromValue", () => {
|
|
12
|
+
expect(Age.fromValue(0).get()).toEqual(min);
|
|
13
|
+
expect(Age.fromValue(130).get()).toEqual(max);
|
|
14
|
+
});
|
|
15
|
+
test("fromValueSafe", () => {
|
|
16
|
+
expect(Age.fromValueSafe(min).get()).toEqual(min);
|
|
17
|
+
expect(Age.fromValueSafe(max).get()).toEqual(max);
|
|
18
|
+
});
|
|
19
|
+
test("fromBirthdateTimestamp - birthday has already happened", () => {
|
|
20
|
+
expect(Age.fromBirthdateTimestamp({
|
|
21
|
+
birthdate: Timestamp.fromDateLike("2000-11-13"),
|
|
22
|
+
now: mocks.TIME_ZERO,
|
|
23
|
+
}).get()).toEqual(twentyThree);
|
|
24
|
+
});
|
|
25
|
+
test("fromBirthdateTimestamp - birthday has NOT yet happened", () => {
|
|
26
|
+
expect(Age.fromBirthdateTimestamp({
|
|
27
|
+
birthdate: Timestamp.fromDateLike("2000-11-15"),
|
|
28
|
+
now: mocks.TIME_ZERO,
|
|
29
|
+
}).get()).toEqual(v.parse(AgeYears, 22));
|
|
30
|
+
});
|
|
31
|
+
test("fromBirthdateTimestamp - exactly on birthday", () => {
|
|
32
|
+
expect(Age.fromBirthdateTimestamp({
|
|
33
|
+
birthdate: Timestamp.fromDateLike("2000-11-14"),
|
|
34
|
+
now: mocks.TIME_ZERO,
|
|
35
|
+
}).get()).toEqual(twentyThree);
|
|
36
|
+
});
|
|
37
|
+
test("fromBirthdateTimestamp - rejects future birthdates", () => {
|
|
38
|
+
expect(() => Age.fromBirthdateTimestamp({ birthdate: Timestamp.fromDateLike("2125-10-01"), now: mocks.TIME_ZERO })).toThrowError("age.future.birthdate");
|
|
39
|
+
});
|
|
40
|
+
test("fromBirthdate - birthday has already happened", () => {
|
|
41
|
+
expect(Age.fromBirthdate({ birthdate: "2000-11-13", now: mocks.TIME_ZERO }).get()).toEqual(twentyThree);
|
|
42
|
+
});
|
|
43
|
+
test("fromBirthdate - birthday has NOT yet happened", () => {
|
|
44
|
+
expect(Age.fromBirthdate({ birthdate: "2000-11-15", now: mocks.TIME_ZERO }).get()).toEqual(v.parse(AgeYears, 22));
|
|
45
|
+
});
|
|
46
|
+
test("fromBirthdate - exactly on birthday", () => {
|
|
47
|
+
expect(Age.fromBirthdate({ birthdate: "2000-11-14", now: mocks.TIME_ZERO }).get()).toEqual(twentyThree);
|
|
48
|
+
});
|
|
49
|
+
test("fromBirthdate - rejects future birthdates", () => {
|
|
50
|
+
expect(() => Age.fromBirthdate({ birthdate: "2125-10-01", now: mocks.TIME_ZERO })).toThrowError("age.future.birthdate");
|
|
51
|
+
});
|
|
52
|
+
test("fromBirthdate - rejects above upper bound", () => {
|
|
53
|
+
expect(() => Age.fromBirthdate({ birthdate: "1800-01-01", now: mocks.TIME_ZERO })).toThrow("timestamp.invalid");
|
|
54
|
+
});
|
|
55
|
+
test("fromBirthdate - invalid date string throws", () => {
|
|
56
|
+
expect(() => Age.fromBirthdate({ birthdate: "not-a-date", now: mocks.TIME_ZERO })).toThrow("timestamp.invalid");
|
|
57
|
+
});
|
|
58
|
+
test("MIN", () => {
|
|
59
|
+
expect(Age.MIN).toEqual(0);
|
|
60
|
+
});
|
|
61
|
+
test("MAX", () => {
|
|
62
|
+
expect(Age.MAX).toEqual(130);
|
|
63
|
+
});
|
|
64
|
+
test("get", () => {
|
|
65
|
+
expect(Age.fromValue(twentyThree).get()).toEqual(twentyThree);
|
|
66
|
+
});
|
|
67
|
+
test("equals - true", () => {
|
|
68
|
+
const first = Age.fromValue(18);
|
|
69
|
+
const second = Age.fromValue(18);
|
|
70
|
+
expect(first.equals(second)).toEqual(true);
|
|
71
|
+
});
|
|
72
|
+
test("equals - false", () => {
|
|
73
|
+
const first = Age.fromValue(18);
|
|
74
|
+
const second = Age.fromValue(19);
|
|
75
|
+
expect(first.equals(second)).toEqual(false);
|
|
76
|
+
});
|
|
77
|
+
test("isOlderThan", () => {
|
|
78
|
+
const youngerAge = Age.fromValue(17);
|
|
79
|
+
const olderAge = Age.fromValue(18);
|
|
80
|
+
expect(olderAge.isOlderThan(youngerAge)).toEqual(true);
|
|
81
|
+
expect(youngerAge.isOlderThan(olderAge)).toEqual(false);
|
|
82
|
+
expect(youngerAge.isOlderThan(youngerAge)).toEqual(false);
|
|
83
|
+
});
|
|
84
|
+
test("isYoungerThan", () => {
|
|
85
|
+
const youngerAge = Age.fromValue(17);
|
|
86
|
+
const olderAge = Age.fromValue(18);
|
|
87
|
+
expect(youngerAge.isYoungerThan(olderAge)).toEqual(true);
|
|
88
|
+
expect(olderAge.isYoungerThan(youngerAge)).toEqual(false);
|
|
89
|
+
expect(youngerAge.isYoungerThan(youngerAge)).toEqual(false);
|
|
90
|
+
});
|
|
91
|
+
test("isAdult - treats exactly the same age as adult", () => {
|
|
92
|
+
expect(Age.fromValue(18).isAdult(Age.fromValue(18))).toEqual(true);
|
|
93
|
+
});
|
|
94
|
+
test("isAdult - treats older age as adult", () => {
|
|
95
|
+
expect(Age.fromValue(21).isAdult(Age.fromValue(18))).toEqual(true);
|
|
96
|
+
});
|
|
97
|
+
test("isAdult - treats younger age as not adult", () => {
|
|
98
|
+
expect(Age.fromValue(17).isAdult(Age.fromValue(18))).toEqual(false);
|
|
99
|
+
});
|
|
100
|
+
test("toString", () => {
|
|
101
|
+
expect(Age.fromValue(42).toString()).toEqual("42");
|
|
102
|
+
});
|
|
103
|
+
test("toJSON", () => {
|
|
104
|
+
expect(Age.fromValue(42).toJSON()).toEqual(42);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { ApiKey } from "../src/api-key.vo";
|
|
4
|
+
describe("ApiKey", () => {
|
|
5
|
+
test("happy path", () => {
|
|
6
|
+
expect(v.safeParse(ApiKey, "a".repeat(64)).success).toEqual(true);
|
|
7
|
+
expect(v.safeParse(ApiKey, "A".repeat(64)).success).toEqual(true);
|
|
8
|
+
});
|
|
9
|
+
test("rejects non-string - null", () => {
|
|
10
|
+
expect(() => v.parse(ApiKey, null)).toThrow("api.key.type");
|
|
11
|
+
});
|
|
12
|
+
test("rejects non-string - number", () => {
|
|
13
|
+
expect(() => v.parse(ApiKey, 123)).toThrow("api.key.type");
|
|
14
|
+
});
|
|
15
|
+
test("rejects empty", () => {
|
|
16
|
+
expect(() => v.parse(ApiKey, "")).toThrow("api.key.bad.chars");
|
|
17
|
+
});
|
|
18
|
+
test("rejects too long", () => {
|
|
19
|
+
expect(() => v.parse(ApiKey, `${"a".repeat(64)}abc`)).toThrow("api.key.bad.chars");
|
|
20
|
+
});
|
|
21
|
+
test("rejects bad chars", () => {
|
|
22
|
+
expect(() => v.parse(ApiKey, `${"a".repeat(63)}!`)).toThrow("api.key.bad.chars");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { Basename } from "../src/basename.vo";
|
|
4
|
+
describe("Basename", () => {
|
|
5
|
+
test("happy path", () => {
|
|
6
|
+
expect(v.safeParse(Basename, "avatar").success).toEqual(true);
|
|
7
|
+
expect(v.safeParse(Basename, "Report_v1.2-rc").success).toEqual(true);
|
|
8
|
+
expect(v.safeParse(Basename, "a".repeat(128)).success).toEqual(true);
|
|
9
|
+
});
|
|
10
|
+
test("rejects non-string - null", () => {
|
|
11
|
+
expect(() => v.parse(Basename, null)).toThrow("basename.type");
|
|
12
|
+
});
|
|
13
|
+
test("rejects non-string - number", () => {
|
|
14
|
+
expect(() => v.parse(Basename, 42)).toThrow("basename.type");
|
|
15
|
+
});
|
|
16
|
+
test("rejects 129 chars", () => {
|
|
17
|
+
expect(() => v.parse(Basename, "a".repeat(129))).toThrow("basename.too.long");
|
|
18
|
+
});
|
|
19
|
+
test("rejects empty", () => {
|
|
20
|
+
expect(() => v.parse(Basename, "")).toThrow("basename.empty");
|
|
21
|
+
});
|
|
22
|
+
test("rejects forward slash", () => {
|
|
23
|
+
expect(() => v.parse(Basename, "a/b")).toThrow("basename.bad.chars");
|
|
24
|
+
});
|
|
25
|
+
test("rejects backslash", () => {
|
|
26
|
+
expect(() => v.parse(Basename, "a\\b")).toThrow("basename.bad.chars");
|
|
27
|
+
});
|
|
28
|
+
test("rejects control chars", () => {
|
|
29
|
+
expect(() => v.parse(Basename, "line\nbreak")).toThrow("basename.bad.chars");
|
|
30
|
+
expect(() => v.parse(Basename, "nul\u0000byte")).toThrow("basename.bad.chars");
|
|
31
|
+
});
|
|
32
|
+
test("rejects single dot", () => {
|
|
33
|
+
expect(() => v.parse(Basename, ".")).toThrow("basename.dot.segments");
|
|
34
|
+
});
|
|
35
|
+
test("rejects double dot", () => {
|
|
36
|
+
expect(() => v.parse(Basename, "..")).toThrow("basename.dot.segments");
|
|
37
|
+
});
|
|
38
|
+
test("rejects dotfile", () => {
|
|
39
|
+
expect(() => v.parse(Basename, ".env")).toThrow("basename.dotfiles");
|
|
40
|
+
});
|
|
41
|
+
test("rejects trailing dot", () => {
|
|
42
|
+
expect(() => v.parse(Basename, "name.")).toThrow("basename.trailing.dot");
|
|
43
|
+
});
|
|
44
|
+
test("rejects space", () => {
|
|
45
|
+
expect(() => v.parse(Basename, "name name")).toThrow("basename.bad.chars");
|
|
46
|
+
});
|
|
47
|
+
test("rejects emoji", () => {
|
|
48
|
+
expect(() => v.parse(Basename, "name🙂")).toThrow("basename.bad.chars");
|
|
49
|
+
});
|
|
50
|
+
test("rejects symbol", () => {
|
|
51
|
+
expect(() => v.parse(Basename, "name@")).toThrow("basename.bad.chars");
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { batch } from "../src/batch";
|
|
4
|
+
import { IntegerPositive } from "../src/integer-positive.vo";
|
|
5
|
+
const size = v.parse(IntegerPositive, 10);
|
|
6
|
+
describe("batch", () => {
|
|
7
|
+
test("happy path", () => {
|
|
8
|
+
const strings = Array.from({ length: 25 }, (_, i) => `item-${i}`);
|
|
9
|
+
const result = batch(strings, size);
|
|
10
|
+
expect(result.length).toEqual(3);
|
|
11
|
+
expect(result[0].length).toEqual(10);
|
|
12
|
+
expect(result[1].length).toEqual(10);
|
|
13
|
+
expect(result[2].length).toEqual(5);
|
|
14
|
+
});
|
|
15
|
+
test("happy path - less than size", () => {
|
|
16
|
+
const strings = ["a", "b", "c"];
|
|
17
|
+
const result = batch(strings, size);
|
|
18
|
+
expect(result.length).toEqual(1);
|
|
19
|
+
expect(result[0]).toEqual(["a", "b", "c"]);
|
|
20
|
+
});
|
|
21
|
+
test("empty array", () => {
|
|
22
|
+
expect(batch([], size)).toEqual([]);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, jest, test } from "bun:test";
|
|
2
|
+
import { DateCalculator } from "../src/date-calculator.service";
|
|
3
|
+
import { Duration } from "../src/duration.service";
|
|
4
|
+
import { Timestamp } from "../src/timestamp.vo";
|
|
5
|
+
describe("DateCalculator", () => {
|
|
6
|
+
beforeEach(() => jest.setSystemTime(new Date("2024-06-01T12:00:00Z")));
|
|
7
|
+
afterEach(() => jest.setSystemTime());
|
|
8
|
+
test("UTC timezone", () => {
|
|
9
|
+
const now = Timestamp.fromNumber(Date.now()); // 2024-06-01T12:00:00Z
|
|
10
|
+
const result = DateCalculator.getStartOfDayTsInTz({ now, timeZoneOffset: Duration.Ms(0) });
|
|
11
|
+
expect(result).toEqual(Timestamp.fromNumber(new Date("2024-06-01T00:00:00Z").getTime()));
|
|
12
|
+
});
|
|
13
|
+
test("UTC+2 timezone", () => {
|
|
14
|
+
const now = Timestamp.fromNumber(Date.now()); // 2024-06-01T12:00:00Z
|
|
15
|
+
const result = DateCalculator.getStartOfDayTsInTz({ now, timeZoneOffset: Duration.Hours(2) });
|
|
16
|
+
// Local day = 2024-06-01 (because 12:00Z is 14:00 local).
|
|
17
|
+
// Local midnight (00:00 +02:00) corresponds to 2024-06-01T02:00:00Z.
|
|
18
|
+
expect(result).toEqual(Timestamp.fromNumber(new Date("2024-06-01T02:00:00Z").getTime()));
|
|
19
|
+
});
|
|
20
|
+
test("UTC-5 timezone", () => {
|
|
21
|
+
const now = Timestamp.fromNumber(Date.now()); // 2024-06-01T12:00:00Z
|
|
22
|
+
const result = DateCalculator.getStartOfDayTsInTz({ now, timeZoneOffset: Duration.Hours(-5) });
|
|
23
|
+
// Local day = 2024-06-01 (because 12:00Z is 07:00 local).
|
|
24
|
+
// Local midnight (00:00 -05:00) corresponds to 2024-05-31T19:00:00Z.
|
|
25
|
+
expect(result).toEqual(Timestamp.fromNumber(new Date("2024-05-31T19:00:00Z").getTime()));
|
|
26
|
+
});
|
|
27
|
+
test("UTC+2 timezone - between days", () => {
|
|
28
|
+
const now = Timestamp.fromNumber(new Date("2024-06-01T01:00:00Z").getTime());
|
|
29
|
+
const result = DateCalculator.getStartOfDayTsInTz({ now, timeZoneOffset: Duration.Hours(2) });
|
|
30
|
+
expect(result).toEqual(Timestamp.fromNumber(new Date("2024-05-31T02:00:00Z").getTime()));
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, jest, test } from "bun:test";
|
|
2
|
+
import { DateFormatters } from "../src/date-formatter.service";
|
|
3
|
+
import * as mocks from "./mocks";
|
|
4
|
+
const date = new Date(mocks.TIME_ZERO.ms);
|
|
5
|
+
describe("DateFormatters", () => {
|
|
6
|
+
test("datetime", () => {
|
|
7
|
+
expect(DateFormatters.datetime(date)).toEqual("2023/11/14 22:13");
|
|
8
|
+
});
|
|
9
|
+
test("date", () => {
|
|
10
|
+
expect(DateFormatters.date(date)).toEqual("2023/11/14");
|
|
11
|
+
});
|
|
12
|
+
test("monthDay", () => {
|
|
13
|
+
expect(DateFormatters.monthDay(date)).toEqual("11/14");
|
|
14
|
+
});
|
|
15
|
+
describe("relative", () => {
|
|
16
|
+
beforeEach(() => jest.setSystemTime(new Date("2024-06-01T15:35:00Z")));
|
|
17
|
+
afterEach(() => jest.setSystemTime());
|
|
18
|
+
test("happy path", () => {
|
|
19
|
+
expect(DateFormatters.relative(date)).toEqual("7 months ago");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { DateRange } from "../src/date-range.vo";
|
|
3
|
+
import { Duration } from "../src/duration.service";
|
|
4
|
+
import * as mocks from "./mocks";
|
|
5
|
+
const duration = Duration.Seconds(1);
|
|
6
|
+
const START = mocks.TIME_ZERO;
|
|
7
|
+
const END = START.add(duration);
|
|
8
|
+
const range = new DateRange(START, END);
|
|
9
|
+
describe("DateRange", () => {
|
|
10
|
+
test("constructor - start after end", () => {
|
|
11
|
+
expect(() => new DateRange(END, START)).toThrow("date.range.invalid");
|
|
12
|
+
});
|
|
13
|
+
test("constructor - start equals end", () => {
|
|
14
|
+
expect(() => new DateRange(START, START)).toThrow("date.range.invalid");
|
|
15
|
+
});
|
|
16
|
+
test("getStart", () => {
|
|
17
|
+
expect(range.getStart()).toEqual(START);
|
|
18
|
+
});
|
|
19
|
+
test("getEnd", () => {
|
|
20
|
+
expect(range.getEnd()).toEqual(END);
|
|
21
|
+
});
|
|
22
|
+
test("get", () => {
|
|
23
|
+
expect(range.get()).toEqual([START, END]);
|
|
24
|
+
});
|
|
25
|
+
test("getDuration", () => {
|
|
26
|
+
expect(range.getDuration()).toEqual(duration);
|
|
27
|
+
});
|
|
28
|
+
test("contains - true", () => {
|
|
29
|
+
expect(range.contains(START)).toEqual(true);
|
|
30
|
+
expect(range.contains(START.add(Duration.Ms(500)))).toEqual(true);
|
|
31
|
+
expect(range.contains(END)).toEqual(true);
|
|
32
|
+
});
|
|
33
|
+
test("contains - false", () => {
|
|
34
|
+
expect(range.contains(START.subtract(Duration.Ms(1)))).toEqual(false);
|
|
35
|
+
expect(range.contains(END.add(Duration.Ms(1)))).toEqual(false);
|
|
36
|
+
});
|
|
37
|
+
test("equals - true", () => {
|
|
38
|
+
expect(range.equals(range)).toEqual(true);
|
|
39
|
+
});
|
|
40
|
+
test("equals - false", () => {
|
|
41
|
+
expect(range.equals(new DateRange(START, END.add(Duration.Seconds(1))))).toEqual(false);
|
|
42
|
+
});
|
|
43
|
+
test("toString", () => {
|
|
44
|
+
expect(range.toString()).toEqual(`${START.toString()} - ${END.toString()}`);
|
|
45
|
+
});
|
|
46
|
+
test("toJSON", () => {
|
|
47
|
+
expect(range.toJSON()).toEqual({ start: START.ms, end: END.ms });
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { DayIsoId } from "../src/day-iso-id.vo";
|
|
4
|
+
describe("DayIsoId", () => {
|
|
5
|
+
test("happy path", () => {
|
|
6
|
+
expect(v.safeParse(DayIsoId, "2025-07-15").success).toEqual(true);
|
|
7
|
+
expect(v.safeParse(DayIsoId, "2024-02-29").success).toEqual(true);
|
|
8
|
+
});
|
|
9
|
+
test("rejects prefix", () => {
|
|
10
|
+
expect(() => v.parse(DayIsoId, "prefix2025-07-15")).toThrow("day.iso.id.bad.chars");
|
|
11
|
+
});
|
|
12
|
+
test("rejects suffix", () => {
|
|
13
|
+
expect(() => v.parse(DayIsoId, "2025-07-15suffix")).toThrow("day.iso.id.bad.chars");
|
|
14
|
+
});
|
|
15
|
+
test("rejects non-string - null", () => {
|
|
16
|
+
expect(() => v.parse(DayIsoId, null)).toThrow("day.iso.id.type");
|
|
17
|
+
});
|
|
18
|
+
test("rejects non-string - number", () => {
|
|
19
|
+
expect(() => v.parse(DayIsoId, 2024)).toThrow("day.iso.id.type");
|
|
20
|
+
});
|
|
21
|
+
test("rejects empty", () => {
|
|
22
|
+
expect(() => v.parse(DayIsoId, "")).toThrow("day.iso.id.bad.chars");
|
|
23
|
+
});
|
|
24
|
+
test("rejects strings that don't match YYYY-MM-DD", () => {
|
|
25
|
+
const invalid = ["2025-7-15", "25-07-15", "2025/07/15", "20250715"];
|
|
26
|
+
for (const value of invalid) {
|
|
27
|
+
expect(() => v.parse(DayIsoId, value)).toThrow("day.iso.id.bad.chars");
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
test("rejects impossible calendar dates", () => {
|
|
31
|
+
const invalid = ["2025-02-30", "2025-13-01", "2025-00-10", "2025-04-31", "2025-02-29"];
|
|
32
|
+
for (const value of invalid) {
|
|
33
|
+
expect(() => v.parse(DayIsoId, value)).toThrow("day.iso.id.invalid.date");
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { Day } from "../src/day.vo";
|
|
4
|
+
import { DayIsoId } from "../src/day-iso-id.vo";
|
|
5
|
+
import { Duration } from "../src/duration.service";
|
|
6
|
+
import { Integer } from "../src/integer.vo";
|
|
7
|
+
import { Timestamp } from "../src/timestamp.vo";
|
|
8
|
+
import * as mocks from "./mocks";
|
|
9
|
+
const start = Timestamp.fromNumber(Date.UTC(mocks.TIME_ZERO_DATE.getUTCFullYear(), mocks.TIME_ZERO_DATE.getUTCMonth(), mocks.TIME_ZERO_DATE.getUTCDate()));
|
|
10
|
+
const end = start.add(Duration.Days(1)).subtract(mocks.epsilon);
|
|
11
|
+
const dayIsoId = v.parse(DayIsoId, mocks.TIME_ZERO_DATE_LIKE);
|
|
12
|
+
describe("Day", () => {
|
|
13
|
+
test("happy path", () => {
|
|
14
|
+
const day = Day.fromTimestamp(mocks.TIME_ZERO);
|
|
15
|
+
expect(day.getStart()).toEqual(start);
|
|
16
|
+
expect(day.getEnd()).toEqual(end);
|
|
17
|
+
expect(day.toIsoId()).toEqual(dayIsoId);
|
|
18
|
+
expect(day.contains(mocks.TIME_ZERO)).toEqual(true);
|
|
19
|
+
});
|
|
20
|
+
test("fromTimestamp", () => {
|
|
21
|
+
expect(Day.fromTimestamp(mocks.TIME_ZERO).toIsoId()).toEqual(dayIsoId);
|
|
22
|
+
});
|
|
23
|
+
test("fromTimestampValue", () => {
|
|
24
|
+
expect(Day.fromTimestampValue(mocks.TIME_ZERO.ms).toIsoId()).toEqual(dayIsoId);
|
|
25
|
+
});
|
|
26
|
+
test("fromNow", () => {
|
|
27
|
+
expect(Day.fromNow(mocks.TIME_ZERO).toIsoId()).toEqual(dayIsoId);
|
|
28
|
+
});
|
|
29
|
+
test("fromIsoId", () => {
|
|
30
|
+
expect(Day.fromIsoId(dayIsoId).toIsoId()).toEqual(dayIsoId);
|
|
31
|
+
});
|
|
32
|
+
test("leap-day", () => {
|
|
33
|
+
const timestamp = Timestamp.fromDateLike("2024-02-29");
|
|
34
|
+
const day = Day.fromTimestamp(timestamp);
|
|
35
|
+
expect(day.toIsoId()).toEqual(v.parse(DayIsoId, "2024-02-29"));
|
|
36
|
+
expect(day.contains(timestamp)).toEqual(true);
|
|
37
|
+
});
|
|
38
|
+
test("equals", () => {
|
|
39
|
+
const day = Day.fromTimestamp(mocks.TIME_ZERO);
|
|
40
|
+
const now = Day.fromNow(Timestamp.fromNumber(Date.now()));
|
|
41
|
+
expect(day.equals(now)).toEqual(false);
|
|
42
|
+
expect(day.equals(day)).toEqual(true);
|
|
43
|
+
});
|
|
44
|
+
test("next", () => {
|
|
45
|
+
expect(Day.fromTimestamp(mocks.TIME_ZERO).next().toIsoId()).toEqual(v.parse(DayIsoId, "2023-11-15"));
|
|
46
|
+
});
|
|
47
|
+
test("previous", () => {
|
|
48
|
+
expect(Day.fromTimestamp(mocks.TIME_ZERO).previous().toIsoId()).toEqual(v.parse(DayIsoId, "2023-11-13"));
|
|
49
|
+
});
|
|
50
|
+
test("shift", () => {
|
|
51
|
+
expect(Day.fromTimestamp(mocks.TIME_ZERO).shift(v.parse(Integer, 2)).toIsoId()).toEqual(v.parse(DayIsoId, "2023-11-16"));
|
|
52
|
+
expect(Day.fromTimestamp(mocks.TIME_ZERO).shift(v.parse(Integer, -2)).toIsoId()).toEqual(v.parse(DayIsoId, "2023-11-12"));
|
|
53
|
+
});
|
|
54
|
+
test("round-trips", () => {
|
|
55
|
+
expect(Day.fromIsoId(dayIsoId).toIsoId()).toEqual(dayIsoId);
|
|
56
|
+
});
|
|
57
|
+
test("contains", () => {
|
|
58
|
+
const day = Day.fromTimestamp(mocks.TIME_ZERO);
|
|
59
|
+
expect(day.contains(day.getStart().subtract(mocks.epsilon))).toEqual(false);
|
|
60
|
+
expect(day.contains(day.getEnd().add(mocks.epsilon))).toEqual(false);
|
|
61
|
+
});
|
|
62
|
+
test("toString", () => {
|
|
63
|
+
expect(Day.fromIsoId(dayIsoId).toString()).toEqual(mocks.TIME_ZERO_DATE_LIKE);
|
|
64
|
+
});
|
|
65
|
+
test("toJSON", () => {
|
|
66
|
+
expect(Day.fromIsoId(dayIsoId).toJSON()).toEqual({ start: 1699920000000, end: 1700006399999 });
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { DirectoryPathAbsoluteSchema } from "../src/directory-path-absolute.vo";
|
|
4
|
+
describe("DirectoryPathAbsoluteSchema", () => {
|
|
5
|
+
test("happy path", () => {
|
|
6
|
+
const valid = ["/tmp/app/users", "/", "/ok.png"];
|
|
7
|
+
for (const value of valid) {
|
|
8
|
+
expect(v.safeParse(DirectoryPathAbsoluteSchema, value)).toMatchObject({ success: true, output: value });
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
test("rejects non-string - null", () => {
|
|
12
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, null)).toThrow("directory.path.absolue.type");
|
|
13
|
+
});
|
|
14
|
+
test("rejects non-string - number", () => {
|
|
15
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, 42)).toThrow("directory.path.absolue.type");
|
|
16
|
+
});
|
|
17
|
+
test("rejects too long", () => {
|
|
18
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, `/${"a".repeat(512)}`)).toThrow("directory.path.absolue.too.long");
|
|
19
|
+
});
|
|
20
|
+
test("rejects empty", () => {
|
|
21
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, "")).toThrow("directory.path.absolue.empty");
|
|
22
|
+
});
|
|
23
|
+
test("rejects empty segment", () => {
|
|
24
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, "/tmp//app///users")).toThrow("directory.path.absolue.bad.segments");
|
|
25
|
+
});
|
|
26
|
+
test("rejects trailing slash", () => {
|
|
27
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, "/tmp/app/")).toThrow("directory.path.absolue.trailing.slash");
|
|
28
|
+
});
|
|
29
|
+
test("rejects relative path", () => {
|
|
30
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, "tmp/app")).toThrow("directory.path.absolue.leading.slash");
|
|
31
|
+
});
|
|
32
|
+
test("rejects backslash", () => {
|
|
33
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, "/tmp\\app")).toThrow("directory.path.absolue.bad.segments");
|
|
34
|
+
});
|
|
35
|
+
test("rejects control chars", () => {
|
|
36
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, "/tmp\napp")).toThrow("directory.path.absolue.bad.segments");
|
|
37
|
+
});
|
|
38
|
+
test("rejects dot segment", () => {
|
|
39
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, "/tmp/../etc")).toThrow("directory.path.absolue.bad.segments");
|
|
40
|
+
});
|
|
41
|
+
test("rejects double-dot segment", () => {
|
|
42
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, "/tmp/./users")).toThrow("directory.path.absolue.bad.segments");
|
|
43
|
+
});
|
|
44
|
+
test("rejects invalid segment", () => {
|
|
45
|
+
expect(() => v.parse(DirectoryPathAbsoluteSchema, "/tmp/app/invalid segment")).toThrow("directory.path.absolue.bad.segments");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { DirectoryPathRelativeSchema } from "../src/directory-path-relative.vo";
|
|
4
|
+
describe("DirectoryPathRelativeSchema", () => {
|
|
5
|
+
test("happy path", () => {
|
|
6
|
+
const valid = ["users/avatars", "users"];
|
|
7
|
+
for (const value of valid) {
|
|
8
|
+
expect(v.safeParse(DirectoryPathRelativeSchema, value)).toMatchObject({ success: true, output: value });
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
test("rejects non-string - null", () => {
|
|
12
|
+
expect(() => v.parse(DirectoryPathRelativeSchema, null)).toThrow("directory.path.relative.type");
|
|
13
|
+
});
|
|
14
|
+
test("rejects non-string - number", () => {
|
|
15
|
+
expect(() => v.parse(DirectoryPathRelativeSchema, 123)).toThrow("directory.path.relative.type");
|
|
16
|
+
});
|
|
17
|
+
test("rejects empty", () => {
|
|
18
|
+
expect(() => v.parse(DirectoryPathRelativeSchema, "")).toThrow("directory.path.relative.empty");
|
|
19
|
+
});
|
|
20
|
+
test("rejects too long", () => {
|
|
21
|
+
expect(() => v.parse(DirectoryPathRelativeSchema, "a".repeat(513))).toThrow("directory.path.absolue.too.long");
|
|
22
|
+
});
|
|
23
|
+
test("rejects empty segment", () => {
|
|
24
|
+
expect(() => v.parse(DirectoryPathRelativeSchema, "tmp//app///users")).toThrow("directory.path.relative.bad.segments");
|
|
25
|
+
});
|
|
26
|
+
test("rejects leading slash", () => {
|
|
27
|
+
expect(() => v.parse(DirectoryPathRelativeSchema, "/users/avatars")).toThrow("directory.path.relative.leading.slash");
|
|
28
|
+
});
|
|
29
|
+
test("rejects trailing slash", () => {
|
|
30
|
+
expect(() => v.parse(DirectoryPathRelativeSchema, "tmp/app/")).toThrow("directory.path.absolue.trailing.slash");
|
|
31
|
+
});
|
|
32
|
+
test("rejects backslash", () => {
|
|
33
|
+
expect(() => v.parse(DirectoryPathRelativeSchema, "users\\avatars")).toThrow("directory.path.relative.bad.segments");
|
|
34
|
+
});
|
|
35
|
+
test("rejects control chars", () => {
|
|
36
|
+
expect(() => v.parse(DirectoryPathRelativeSchema, "users\navatars")).toThrow("directory.path.relative.bad.segments");
|
|
37
|
+
});
|
|
38
|
+
test("rejects dot segment", () => {
|
|
39
|
+
expect(() => v.parse(DirectoryPathRelativeSchema, "users/./avatars")).toThrow("directory.path.relative.bad.segments");
|
|
40
|
+
});
|
|
41
|
+
test("rejects double dot segment", () => {
|
|
42
|
+
expect(() => v.parse(DirectoryPathRelativeSchema, "users/../avatars")).toThrow("directory.path.relative.bad.segments");
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { DistanceValue } from "../src/distance-value.vo";
|
|
4
|
+
describe("DistanceValue", () => {
|
|
5
|
+
test("happy path", () => {
|
|
6
|
+
expect(v.safeParse(DistanceValue, 0).success).toEqual(true);
|
|
7
|
+
expect(v.safeParse(DistanceValue, 1_000).success).toEqual(true);
|
|
8
|
+
});
|
|
9
|
+
test("rejects non-number - null", () => {
|
|
10
|
+
expect(() => v.parse(DistanceValue, null)).toThrow("distance.value.type");
|
|
11
|
+
});
|
|
12
|
+
test("rejects non-number - string", () => {
|
|
13
|
+
expect(() => v.parse(DistanceValue, "123")).toThrow("distance.value.type");
|
|
14
|
+
});
|
|
15
|
+
test("rejects fractions", () => {
|
|
16
|
+
expect(() => v.parse(DistanceValue, 1.5)).toThrow("distance.value.type");
|
|
17
|
+
});
|
|
18
|
+
test("rejects negative numbers", () => {
|
|
19
|
+
expect(() => v.parse(DistanceValue, -1)).toThrow("distance.value.invalid");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|