@bgord/tools 1.3.24 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/dist/age-years.vo.d.ts +3 -3
  2. package/dist/age-years.vo.js +4 -9
  3. package/dist/age.vo.js +2 -1
  4. package/dist/api-key.vo.d.ts +3 -4
  5. package/dist/api-key.vo.js +5 -9
  6. package/dist/basename.vo.d.ts +3 -3
  7. package/dist/basename.vo.js +10 -15
  8. package/dist/day-iso-id.vo.d.ts +3 -3
  9. package/dist/day-iso-id.vo.js +4 -8
  10. package/dist/day.vo.d.ts +1 -1
  11. package/dist/day.vo.js +7 -6
  12. package/dist/directory-path-absolute.vo.d.ts +3 -3
  13. package/dist/directory-path-absolute.vo.js +5 -12
  14. package/dist/directory-path-relative.vo.d.ts +3 -3
  15. package/dist/directory-path-relative.vo.js +5 -12
  16. package/dist/distance-value.vo.d.ts +3 -3
  17. package/dist/distance-value.vo.js +4 -8
  18. package/dist/distance.vo.js +7 -6
  19. package/dist/division-factor.vo.d.ts +3 -3
  20. package/dist/division-factor.vo.js +4 -7
  21. package/dist/duration-ms.vo.d.ts +3 -3
  22. package/dist/duration-ms.vo.js +4 -3
  23. package/dist/duration.service.js +2 -1
  24. package/dist/email.vo.d.ts +3 -3
  25. package/dist/email.vo.js +3 -3
  26. package/dist/etags.vo.js +3 -2
  27. package/dist/extension.vo.d.ts +3 -3
  28. package/dist/extension.vo.js +6 -12
  29. package/dist/feature-flag-value.vo.d.ts +3 -3
  30. package/dist/feature-flag-value.vo.js +2 -2
  31. package/dist/file-path-absolute-schema.vo.d.ts +8 -5
  32. package/dist/file-path-absolute-schema.vo.js +6 -13
  33. package/dist/file-path-relative-schema.vo.d.ts +8 -5
  34. package/dist/file-path-relative-schema.vo.js +6 -13
  35. package/dist/file-path.vo.js +5 -4
  36. package/dist/filename-affix.vo.d.ts +3 -3
  37. package/dist/filename-affix.vo.js +4 -9
  38. package/dist/filename-from-string.vo.d.ts +6 -6
  39. package/dist/filename-from-string.vo.js +5 -8
  40. package/dist/filename.vo.js +8 -7
  41. package/dist/height-milimiters.vo.d.ts +3 -3
  42. package/dist/height-milimiters.vo.js +4 -8
  43. package/dist/height.vo.js +4 -3
  44. package/dist/hour-value.vo.d.ts +3 -3
  45. package/dist/hour-value.vo.js +4 -9
  46. package/dist/hour.vo.js +3 -2
  47. package/dist/iban-schema.vo.d.ts +3 -3
  48. package/dist/iban-schema.vo.js +4 -9
  49. package/dist/iban.vo.js +2 -1
  50. package/dist/image.vo.d.ts +5 -5
  51. package/dist/image.vo.js +7 -17
  52. package/dist/integer-non-negative.vo.d.ts +3 -3
  53. package/dist/integer-non-negative.vo.js +4 -8
  54. package/dist/integer-positive.vo.d.ts +3 -3
  55. package/dist/integer-positive.vo.js +4 -8
  56. package/dist/integer.vo.d.ts +3 -3
  57. package/dist/integer.vo.js +3 -3
  58. package/dist/language.vo.d.ts +3 -3
  59. package/dist/language.vo.js +2 -2
  60. package/dist/mime-value.vo.d.ts +3 -2
  61. package/dist/mime-value.vo.js +4 -7
  62. package/dist/mime.vo.js +2 -1
  63. package/dist/mimes.js +12 -11
  64. package/dist/minute-value.vo.d.ts +3 -3
  65. package/dist/minute-value.vo.js +4 -9
  66. package/dist/minute.vo.js +3 -2
  67. package/dist/money-amount.vo.d.ts +3 -3
  68. package/dist/money-amount.vo.js +4 -8
  69. package/dist/money.vo.js +7 -6
  70. package/dist/month-iso-id.vo.d.ts +3 -3
  71. package/dist/month-iso-id.vo.js +5 -9
  72. package/dist/month.vo.js +5 -4
  73. package/dist/multiplication-factor.vo.d.ts +3 -3
  74. package/dist/multiplication-factor.vo.js +4 -7
  75. package/dist/object-key.vo.d.ts +3 -3
  76. package/dist/object-key.vo.js +8 -13
  77. package/dist/package-version-schema.vo.d.ts +3 -3
  78. package/dist/package-version-schema.vo.js +4 -7
  79. package/dist/package-version.vo.js +3 -4
  80. package/dist/pagination-page.vo.d.ts +3 -3
  81. package/dist/pagination-page.vo.js +2 -6
  82. package/dist/pagination-skip.vo.d.ts +3 -3
  83. package/dist/pagination-skip.vo.js +2 -5
  84. package/dist/pagination-take.vo.d.ts +3 -3
  85. package/dist/pagination-take.vo.js +2 -5
  86. package/dist/pagination.service.js +8 -7
  87. package/dist/quarter-iso-id.vo.d.ts +4 -3
  88. package/dist/quarter-iso-id.vo.js +7 -11
  89. package/dist/quarter.vo.js +3 -2
  90. package/dist/reordering-item-position-value.vo.d.ts +3 -3
  91. package/dist/reordering-item-position-value.vo.js +2 -5
  92. package/dist/reordering.service.d.ts +9 -9
  93. package/dist/reordering.service.js +7 -7
  94. package/dist/revision-value.vo.d.ts +3 -3
  95. package/dist/revision-value.vo.js +2 -5
  96. package/dist/revision.vo.js +3 -2
  97. package/dist/rounding-decimal.strategy.d.ts +2 -2
  98. package/dist/rounding-decimal.strategy.js +5 -10
  99. package/dist/size-bytes.vo.d.ts +3 -3
  100. package/dist/size-bytes.vo.js +4 -8
  101. package/dist/size.vo.js +5 -4
  102. package/dist/time-zone-offset-value.vo.d.ts +3 -3
  103. package/dist/time-zone-offset-value.vo.js +8 -12
  104. package/dist/timestamp-value.vo.d.ts +3 -3
  105. package/dist/timestamp-value.vo.js +4 -8
  106. package/dist/timestamp.vo.js +2 -1
  107. package/dist/timezone.vo.d.ts +3 -3
  108. package/dist/timezone.vo.js +7 -10
  109. package/dist/url-with-slash.vo.d.ts +3 -3
  110. package/dist/url-with-slash.vo.js +4 -7
  111. package/dist/url-without-slash.vo.d.ts +3 -3
  112. package/dist/url-without-slash.vo.js +4 -7
  113. package/dist/week-iso-id.vo.d.ts +3 -3
  114. package/dist/week-iso-id.vo.js +5 -9
  115. package/dist/week.vo.js +5 -4
  116. package/dist/weekday-iso-id.vo.d.ts +3 -3
  117. package/dist/weekday-iso-id.vo.js +4 -9
  118. package/dist/weekday.vo.js +9 -8
  119. package/dist/weight-grams.vo.d.ts +3 -3
  120. package/dist/weight-grams.vo.js +4 -8
  121. package/dist/weight.vo.js +8 -7
  122. package/dist/year-iso-id.vo.d.ts +3 -3
  123. package/dist/year-iso-id.vo.js +4 -7
  124. package/dist/year.vo.js +6 -5
  125. package/package.json +9 -12
@@ -1,6 +1,6 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export declare const SizeBytesError: {
3
3
  Invalid: string;
4
4
  };
5
- export declare const SizeBytes: z.core.$ZodBranded<z.ZodNumber, "SizeBytes", "out">;
6
- export type SizeBytesType = z.infer<typeof SizeBytes>;
5
+ export declare const SizeBytes: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "SizeBytes">]>;
6
+ export type SizeBytesType = v.InferOutput<typeof SizeBytes>;
@@ -1,9 +1,5 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export const SizeBytesError = { Invalid: "size.bytes.invalid" };
3
- // Stryker disable all
4
- export const SizeBytes = z
5
- // Stryker restore all
6
- .number(SizeBytesError.Invalid)
7
- .int(SizeBytesError.Invalid)
8
- .gte(0, SizeBytesError.Invalid)
9
- .brand("SizeBytes");
3
+ export const SizeBytes = v.pipe(v.number(SizeBytesError.Invalid), v.integer(SizeBytesError.Invalid), v.minValue(0, SizeBytesError.Invalid),
4
+ // Stryker disable next-line StringLiteral
5
+ v.brand("SizeBytes"));
package/dist/size.vo.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as v from "valibot";
1
2
  import { RoundingDecimalStrategy } from "./rounding-decimal.strategy";
2
3
  import { RoundingUpStrategy } from "./rounding-up.strategy";
3
4
  import { SizeBytes } from "./size-bytes.vo";
@@ -72,13 +73,13 @@ export class Size {
72
73
  calculateBytes(value, unit) {
73
74
  switch (unit) {
74
75
  case SizeUnitEnum.kB:
75
- return SizeBytes.parse(value * Size.KB_MULTIPLIER);
76
+ return v.parse(SizeBytes, value * Size.KB_MULTIPLIER);
76
77
  case SizeUnitEnum.MB:
77
- return SizeBytes.parse(value * Size.MB_MULTIPLIER);
78
+ return v.parse(SizeBytes, value * Size.MB_MULTIPLIER);
78
79
  case SizeUnitEnum.GB:
79
- return SizeBytes.parse(value * Size.GB_MULTIPLIER);
80
+ return v.parse(SizeBytes, value * Size.GB_MULTIPLIER);
80
81
  default:
81
- return SizeBytes.parse(value);
82
+ return v.parse(SizeBytes, value);
82
83
  }
83
84
  }
84
85
  toString() {
@@ -1,8 +1,8 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export declare const TimeZoneOffsetValueError: {
3
3
  Type: string;
4
4
  Min: string;
5
5
  Max: string;
6
6
  };
7
- export declare const TimeZoneOffsetValue: z.core.$ZodBranded<z.ZodDefault<z.ZodCoercedNumber<unknown>>, "TimeZoneOffsetValue", "out">;
8
- export type TimeZoneOffsetValueType = z.infer<typeof TimeZoneOffsetValue>;
7
+ export declare const TimeZoneOffsetValue: v.SchemaWithPipe<readonly [v.UnknownSchema, v.TransformAction<unknown, number>, v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, -840, string>, v.MaxValueAction<number, 720, string>, v.BrandAction<number, "TimeZoneOffsetValue">]>;
8
+ export type TimeZoneOffsetValueType = v.InferOutput<typeof TimeZoneOffsetValue>;
@@ -1,17 +1,13 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export const TimeZoneOffsetValueError = {
3
3
  Type: "time.zone.offset.value.type",
4
4
  Min: "time.zone.offset.value.min",
5
5
  Max: "time.zone.offset.value.max",
6
6
  };
7
- // Stryker disable all
8
- export const TimeZoneOffsetValue = z.coerce
9
- // Stryker restore all
10
- .number(TimeZoneOffsetValueError.Type)
11
- .int(TimeZoneOffsetValueError.Type)
12
- // UTC+14 (Kiribati)
13
- .min(-840, TimeZoneOffsetValueError.Min)
14
- // UTC-12 (Baker Island)
15
- .max(720, TimeZoneOffsetValueError.Max)
16
- .default(0) // Default to UTC if missing or invalid
17
- .brand("TimeZoneOffsetValue");
7
+ export const TimeZoneOffsetValue = v.pipe(v.unknown(), v.transform((value) => (value === undefined ? 0 : Number(value))), v.number(TimeZoneOffsetValueError.Type), v.integer(TimeZoneOffsetValueError.Type),
8
+ // UTC+14 (Kiribati)
9
+ v.minValue(-840, TimeZoneOffsetValueError.Min),
10
+ // UTC-12 (Baker Island)
11
+ v.maxValue(720, TimeZoneOffsetValueError.Max),
12
+ // Stryker disable next-line StringLiteral
13
+ v.brand("TimeZoneOffsetValue"));
@@ -1,6 +1,6 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export declare const TimestampValueError: {
3
3
  Invalid: string;
4
4
  };
5
- export declare const TimestampValue: z.core.$ZodBranded<z.ZodNumber, "TimestampValue", "out">;
6
- export type TimestampValueType = z.infer<typeof TimestampValue>;
5
+ export declare const TimestampValue: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "TimestampValue">]>;
6
+ export type TimestampValueType = v.InferOutput<typeof TimestampValue>;
@@ -1,9 +1,5 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export const TimestampValueError = { Invalid: "timestamp.invalid" };
3
- // Stryker disable all
4
- export const TimestampValue = z
5
- // Stryker restore all
6
- .number(TimestampValueError.Invalid)
7
- .int(TimestampValueError.Invalid)
8
- .gte(0, TimestampValueError.Invalid)
9
- .brand("TimestampValue");
3
+ export const TimestampValue = v.pipe(v.number(TimestampValueError.Invalid), v.integer(TimestampValueError.Invalid), v.minValue(0, TimestampValueError.Invalid),
4
+ // Stryker disable next-line StringLiteral
5
+ v.brand("TimestampValue"));
@@ -1,3 +1,4 @@
1
+ import * as v from "valibot";
1
2
  import { Duration } from "./duration.service";
2
3
  import { TimestampValue } from "./timestamp-value.vo";
3
4
  export class Timestamp {
@@ -9,7 +10,7 @@ export class Timestamp {
9
10
  return new Timestamp(value);
10
11
  }
11
12
  static fromNumber(value) {
12
- return new Timestamp(TimestampValue.parse(value));
13
+ return new Timestamp(v.parse(TimestampValue, value));
13
14
  }
14
15
  static fromDate(value) {
15
16
  return Timestamp.fromNumber(value.getTime());
@@ -1,9 +1,9 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export declare const TimezoneError: {
3
3
  Type: string;
4
4
  Empty: string;
5
5
  TooLong: string;
6
6
  Invalid: string;
7
7
  };
8
- export declare const Timezone: z.core.$ZodBranded<z.ZodString, "Timezone", "out">;
9
- export type TimezoneType = z.infer<typeof Timezone>;
8
+ export declare const Timezone: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.MaxLengthAction<string, 128, string>, v.CheckAction<string, string>, v.BrandAction<string, "Timezone">]>;
9
+ export type TimezoneType = v.InferOutput<typeof Timezone>;
@@ -1,17 +1,12 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export const TimezoneError = {
3
3
  Type: "timezone.type",
4
4
  Empty: "timezone.empty",
5
5
  TooLong: "timezone.too.long",
6
6
  Invalid: "timezone.invalid",
7
7
  };
8
- // Stryker disable all
9
- export const Timezone = z
10
- // Stryker restore all
11
- .string(TimezoneError.Type)
12
- .min(1, TimezoneError.Empty)
13
- .max(128, TimezoneError.TooLong)
14
- .refine((value) => {
8
+ export const Timezone = v.pipe(v.string(TimezoneError.Type), v.minLength(1, TimezoneError.Empty), v.maxLength(128, TimezoneError.TooLong), v.check((value) => {
9
+ // Stryker disable all
15
10
  try {
16
11
  new Intl.DateTimeFormat("en-US", { timeZone: value }).format(Date.now());
17
12
  return true;
@@ -19,5 +14,7 @@ export const Timezone = z
19
14
  catch {
20
15
  return false;
21
16
  }
22
- }, TimezoneError.Invalid)
23
- .brand("Timezone");
17
+ // Stryker restore all
18
+ }, TimezoneError.Invalid),
19
+ // Stryker disable next-line StringLiteral
20
+ v.brand("Timezone"));
@@ -1,6 +1,6 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export declare const UrlWithSlashError: {
3
3
  Invalid: string;
4
4
  };
5
- export declare const UrlWithSlash: z.core.$ZodBranded<z.ZodURL, "UrlWithSlash", "out">;
6
- export type UrlWithSlashType = z.infer<typeof UrlWithSlash>;
5
+ export declare const UrlWithSlash: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.UrlAction<string, string>, v.EndsWithAction<string, "/", string>, v.BrandAction<string, "UrlWithSlash">]>;
6
+ export type UrlWithSlashType = v.InferOutput<typeof UrlWithSlash>;
@@ -1,8 +1,5 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export const UrlWithSlashError = { Invalid: "url.with.slash.invalid" };
3
- // Stryker disable all
4
- export const UrlWithSlash = z
5
- // Stryker disable all
6
- .url(UrlWithSlashError.Invalid)
7
- .refine((value) => value.endsWith("/"), UrlWithSlashError.Invalid)
8
- .brand("UrlWithSlash");
3
+ export const UrlWithSlash = v.pipe(v.string(UrlWithSlashError.Invalid), v.url(UrlWithSlashError.Invalid), v.endsWith("/", UrlWithSlashError.Invalid),
4
+ // Stryker disable next-line StringLiteral
5
+ v.brand("UrlWithSlash"));
@@ -1,6 +1,6 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export declare const UrlWithoutSlashError: {
3
3
  Invalid: string;
4
4
  };
5
- export declare const UrlWithoutSlash: z.core.$ZodBranded<z.ZodURL, "UrlWithoutSlash", "out">;
6
- export type UrlWithoutSlashType = z.infer<typeof UrlWithoutSlash>;
5
+ export declare const UrlWithoutSlash: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.UrlAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "UrlWithoutSlash">]>;
6
+ export type UrlWithoutSlashType = v.InferOutput<typeof UrlWithoutSlash>;
@@ -1,8 +1,5 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export const UrlWithoutSlashError = { Invalid: "url.without.slash.invalid" };
3
- // Stryker disable all
4
- export const UrlWithoutSlash = z
5
- // Stryker restore all
6
- .url(UrlWithoutSlashError.Invalid)
7
- .refine((value) => !value.endsWith("/"), UrlWithoutSlashError.Invalid)
8
- .brand("UrlWithoutSlash");
3
+ export const UrlWithoutSlash = v.pipe(v.string(UrlWithoutSlashError.Invalid), v.url(UrlWithoutSlashError.Invalid), v.check((value) => !value.endsWith("/"), UrlWithoutSlashError.Invalid),
4
+ // Stryker disable next-line StringLiteral
5
+ v.brand("UrlWithoutSlash"));
@@ -1,8 +1,8 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export declare const WeekIsoIdError: {
3
3
  Type: string;
4
4
  BadChars: string;
5
5
  Invalid: string;
6
6
  };
7
- export declare const WeekIsoId: z.core.$ZodBranded<z.ZodString, "WeekIsoId", "out">;
8
- export type WeekIsoIdType = z.infer<typeof WeekIsoId>;
7
+ export declare const WeekIsoId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "WeekIsoId">]>;
8
+ export type WeekIsoIdType = v.InferOutput<typeof WeekIsoId>;
@@ -1,5 +1,5 @@
1
1
  import { getISOWeeksInYear } from "date-fns";
2
- import * as z from "zod/v4";
2
+ import * as v from "valibot";
3
3
  export const WeekIsoIdError = {
4
4
  Type: "week.iso.id.type",
5
5
  BadChars: "week.iso.id.bad.chars",
@@ -7,17 +7,13 @@ export const WeekIsoIdError = {
7
7
  };
8
8
  // Four digits, hypen, W, followed by two digits
9
9
  const WEEK_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}-W[0-9]{2}$/;
10
- // Stryker disable all
11
- export const WeekIsoId = z
12
- // Stryker restore all
13
- .string(WeekIsoIdError.Type)
14
- .regex(WEEK_ISO_ID_CHARS_WHITELIST, WeekIsoIdError.BadChars)
15
- .refine((value) => {
10
+ export const WeekIsoId = v.pipe(v.string(WeekIsoIdError.Type), v.regex(WEEK_ISO_ID_CHARS_WHITELIST, WeekIsoIdError.BadChars), v.check((value) => {
16
11
  const [year, week] = value.split("-W").map(Number);
17
12
  // ISO-8601 rule: Jan 4 is always in week 01 of the ISO week-year.
18
13
  const weeksInYear = getISOWeeksInYear(Date.UTC(year, 0, 4));
19
14
  if (week < 1)
20
15
  return false;
21
16
  return week <= weeksInYear;
22
- }, WeekIsoIdError.Invalid)
23
- .brand("WeekIsoId");
17
+ }, WeekIsoIdError.Invalid),
18
+ // Stryker disable next-line StringLiteral
19
+ v.brand("WeekIsoId"));
package/dist/week.vo.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { addWeeks, endOfISOWeek, getISOWeek, getISOWeekYear, startOfISOWeek } from "date-fns";
2
+ import * as v from "valibot";
2
3
  import { DateRange } from "./date-range.vo";
3
4
  import { Duration } from "./duration.service";
4
5
  import { Integer } from "./integer.vo";
@@ -17,7 +18,7 @@ export class Week extends DateRange {
17
18
  return Week.fromTimestamp(now);
18
19
  }
19
20
  static fromIsoId(isoId) {
20
- const [year, week] = WeekIsoId.parse(isoId).split("-W").map(Number);
21
+ const [year, week] = v.parse(WeekIsoId, isoId).split("-W").map(Number);
21
22
  // ISO-8601 rule: Jan 4 is always in week 01 of the ISO week-year.
22
23
  const januaryFourth = Timestamp.fromNumber(Date.UTC(year, 0, 4));
23
24
  const firstWeekStart = Timestamp.fromNumber(startOfISOWeek(januaryFourth.ms).getTime());
@@ -26,13 +27,13 @@ export class Week extends DateRange {
26
27
  toIsoId() {
27
28
  const year = getISOWeekYear(this.getStart().ms);
28
29
  const week = getISOWeek(this.getStart().ms);
29
- return WeekIsoId.parse(`${year}-W${String(week).padStart(2, "0")}`);
30
+ return v.parse(WeekIsoId, `${year}-W${String(week).padStart(2, "0")}`);
30
31
  }
31
32
  previous() {
32
- return this.shift(Integer.parse(-1));
33
+ return this.shift(v.parse(Integer, -1));
33
34
  }
34
35
  next() {
35
- return this.shift(Integer.parse(1));
36
+ return this.shift(v.parse(Integer, 1));
36
37
  }
37
38
  shift(count) {
38
39
  const shifted = addWeeks(this.getStart().ms, count).getTime();
@@ -1,7 +1,7 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export declare const WeekdayIsoIdError: {
3
3
  Type: string;
4
4
  Invalid: string;
5
5
  };
6
- export declare const WeekdayIsoId: z.core.$ZodBranded<z.ZodNumber, "WeekdayIsoId", "out">;
7
- export type WeekdayIsoIdType = z.infer<typeof WeekdayIsoId>;
6
+ export declare const WeekdayIsoId: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 1, string>, v.MaxValueAction<number, 7, string>, v.BrandAction<number, "WeekdayIsoId">]>;
7
+ export type WeekdayIsoIdType = v.InferOutput<typeof WeekdayIsoId>;
@@ -1,10 +1,5 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export const WeekdayIsoIdError = { Type: "weekday.iso.id.type", Invalid: "weekday.iso.id.invalid" };
3
- // Stryker disable all
4
- export const WeekdayIsoId = z
5
- // Stryker restore all
6
- .number(WeekdayIsoIdError.Type)
7
- .int(WeekdayIsoIdError.Type)
8
- .min(1, WeekdayIsoIdError.Invalid)
9
- .max(7, WeekdayIsoIdError.Invalid)
10
- .brand("WeekdayIsoId");
3
+ export const WeekdayIsoId = v.pipe(v.number(WeekdayIsoIdError.Type), v.integer(WeekdayIsoIdError.Type), v.minValue(1, WeekdayIsoIdError.Invalid), v.maxValue(7, WeekdayIsoIdError.Invalid),
4
+ // Stryker disable next-line StringLiteral
5
+ v.brand("WeekdayIsoId"));
@@ -1,21 +1,22 @@
1
+ import * as v from "valibot";
1
2
  import { Timestamp } from "./timestamp.vo";
2
3
  import { WeekdayIsoId } from "./weekday-iso-id.vo";
3
4
  export class Weekday {
4
5
  value;
5
- static MONDAY = Weekday.fromIsoId(WeekdayIsoId.parse(1));
6
- static TUESDAY = Weekday.fromIsoId(WeekdayIsoId.parse(2));
7
- static WEDNESDAY = Weekday.fromIsoId(WeekdayIsoId.parse(3));
8
- static THURSDAY = Weekday.fromIsoId(WeekdayIsoId.parse(4));
9
- static FRIDAY = Weekday.fromIsoId(WeekdayIsoId.parse(5));
10
- static SATURDAY = Weekday.fromIsoId(WeekdayIsoId.parse(6));
11
- static SUNDAY = Weekday.fromIsoId(WeekdayIsoId.parse(7));
6
+ static MONDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 1));
7
+ static TUESDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 2));
8
+ static WEDNESDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 3));
9
+ static THURSDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 4));
10
+ static FRIDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 5));
11
+ static SATURDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 6));
12
+ static SUNDAY = Weekday.fromIsoId(v.parse(WeekdayIsoId, 7));
12
13
  constructor(value) {
13
14
  this.value = value;
14
15
  }
15
16
  static fromTimestamp(timestamp) {
16
17
  // UTC returns numbers from 0-6, starting from Sunday
17
18
  const utc = new Date(timestamp.ms).getUTCDay();
18
- return new Weekday(WeekdayIsoId.parse(utc === 0 ? 7 : utc));
19
+ return new Weekday(v.parse(WeekdayIsoId, utc === 0 ? 7 : utc));
19
20
  }
20
21
  static fromTimestampValue(timestamp) {
21
22
  return Weekday.fromTimestamp(Timestamp.fromValue(timestamp));
@@ -1,7 +1,7 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export declare const WeightGramsError: {
3
3
  Type: string;
4
4
  Invalid: string;
5
5
  };
6
- export declare const WeightGrams: z.core.$ZodBranded<z.ZodNumber, "WeightGrams", "out">;
7
- export type WeightGramsType = z.infer<typeof WeightGrams>;
6
+ export declare const WeightGrams: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "WeightGrams">]>;
7
+ export type WeightGramsType = v.InferOutput<typeof WeightGrams>;
@@ -1,9 +1,5 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export const WeightGramsError = { Type: "weight.grams.type", Invalid: "weight.grams.invalid" };
3
- // Stryker disable all
4
- export const WeightGrams = z
5
- // Stryker restore all
6
- .number(WeightGramsError.Type)
7
- .int(WeightGramsError.Type)
8
- .gte(0, WeightGramsError.Invalid)
9
- .brand("WeightGrams");
3
+ export const WeightGrams = v.pipe(v.number(WeightGramsError.Type), v.integer(WeightGramsError.Type), v.minValue(0, WeightGramsError.Invalid),
4
+ // Stryker disable next-line StringLiteral
5
+ v.brand("WeightGrams"));
package/dist/weight.vo.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as v from "valibot";
1
2
  import { RoundingToNearestStrategy } from "./rounding-to-nearest.strategy";
2
3
  import { WeightGrams } from "./weight-grams.vo";
3
4
  export class Weight {
@@ -10,13 +11,13 @@ export class Weight {
10
11
  }
11
12
  static fromKilograms(kilograms, rounding = new RoundingToNearestStrategy()) {
12
13
  const grams = rounding.round(kilograms * Weight.GRAMS_PER_KILOGRAM);
13
- return new Weight(WeightGrams.parse(grams), rounding);
14
+ return new Weight(v.parse(WeightGrams, grams), rounding);
14
15
  }
15
16
  static fromGrams(grams, rounding = new RoundingToNearestStrategy()) {
16
- return new Weight(WeightGrams.parse(grams), rounding);
17
+ return new Weight(v.parse(WeightGrams, grams), rounding);
17
18
  }
18
19
  static zero() {
19
- return new Weight(WeightGrams.parse(0));
20
+ return new Weight(v.parse(WeightGrams, 0));
20
21
  }
21
22
  get() {
22
23
  return this.grams;
@@ -29,19 +30,19 @@ export class Weight {
29
30
  return `${this.grams} g`;
30
31
  }
31
32
  add(other) {
32
- return new Weight(WeightGrams.parse(this.grams + other.grams));
33
+ return new Weight(v.parse(WeightGrams, this.grams + other.grams));
33
34
  }
34
35
  subtract(other) {
35
36
  const result = this.grams - other.grams;
36
- return new Weight(WeightGrams.parse(Math.max(0, result)), this.rounding);
37
+ return new Weight(v.parse(WeightGrams, Math.max(0, result)), this.rounding);
37
38
  }
38
39
  multiply(factor) {
39
40
  const grams = this.rounding.round(this.grams * factor);
40
- return new Weight(WeightGrams.parse(grams));
41
+ return new Weight(v.parse(WeightGrams, grams));
41
42
  }
42
43
  divide(divisor) {
43
44
  const grams = this.rounding.round(this.grams / divisor);
44
- return new Weight(WeightGrams.parse(grams));
45
+ return new Weight(v.parse(WeightGrams, grams));
45
46
  }
46
47
  equals(other) {
47
48
  return this.grams === other.grams;
@@ -1,7 +1,7 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export declare const YearIsoIdError: {
3
3
  Type: string;
4
4
  BadChars: string;
5
5
  };
6
- export declare const YearIsoId: z.core.$ZodBranded<z.ZodString, "YearIsoId", "out">;
7
- export type YearIsoIdType = z.infer<typeof YearIsoId>;
6
+ export declare const YearIsoId: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.BrandAction<string, "YearIsoId">]>;
7
+ export type YearIsoIdType = v.InferOutput<typeof YearIsoId>;
@@ -1,10 +1,7 @@
1
- import * as z from "zod/v4";
1
+ import * as v from "valibot";
2
2
  export const YearIsoIdError = { Type: "year.iso.id.type", BadChars: "year.iso.id.bad.chars" };
3
3
  // Four digits
4
4
  const YEAR_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}$/;
5
- // Stryker disable all
6
- export const YearIsoId = z
7
- // Stryker restore all
8
- .string(YearIsoIdError.Type)
9
- .regex(YEAR_ISO_ID_CHARS_WHITELIST, YearIsoIdError.BadChars)
10
- .brand("YearIsoId");
5
+ export const YearIsoId = v.pipe(v.string(YearIsoIdError.Type), v.regex(YEAR_ISO_ID_CHARS_WHITELIST, YearIsoIdError.BadChars),
6
+ // Stryker disable next-line StringLiteral
7
+ v.brand("YearIsoId"));
package/dist/year.vo.js CHANGED
@@ -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(YearIsoId.parse(String(candidate)));
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 YearIsoId.parse(String(getYear(this.getStart().ms)));
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(Integer.parse(-1));
38
+ return this.shift(v.parse(Integer, -1));
38
39
  }
39
40
  next() {
40
- return this.shift(Integer.parse(1));
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.fromIsoId(YearIsoId.parse(String(year)));
45
+ return Year.fromNumber(year);
45
46
  }
46
47
  toString() {
47
48
  return this.toIsoId();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgord/tools",
3
- "version": "1.3.24",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Bartosz Gordon",
@@ -20,25 +20,22 @@
20
20
  "preinstall": "bunx only-allow bun"
21
21
  },
22
22
  "devDependencies": {
23
- "@biomejs/biome": "2.4.6",
24
- "@commitlint/cli": "20.4.3",
25
- "@commitlint/config-conventional": "20.4.3",
23
+ "@biomejs/biome": "2.4.7",
24
+ "@commitlint/cli": "20.5.0",
25
+ "@commitlint/config-conventional": "20.5.0",
26
26
  "@stryker-mutator/core": "9.6.0",
27
27
  "@types/bun": "1.3.10",
28
28
  "cspell": "9.7.0",
29
- "knip": "5.86.0",
30
- "lefthook": "2.1.3",
29
+ "knip": "5.87.0",
30
+ "lefthook": "2.1.4",
31
31
  "lockfile-lint": "5.0.0",
32
32
  "only-allow": "1.2.2",
33
33
  "shellcheck": "4.1.0",
34
- "typescript": "5.9.3",
35
- "zod": "4.3.6"
34
+ "typescript": "5.9.3"
36
35
  },
37
36
  "dependencies": {
38
- "date-fns": "4.1.0"
39
- },
40
- "peerDependencies": {
41
- "zod": "4.3.6"
37
+ "date-fns": "4.1.0",
38
+ "valibot": "1.2.0"
42
39
  },
43
40
  "sideEffects": false
44
41
  }