@bgord/tools 1.2.12 → 1.2.14

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 (147) hide show
  1. package/dist/age-years.vo.d.ts +1 -1
  2. package/dist/age-years.vo.js +2 -0
  3. package/dist/api-key.vo.d.ts +1 -1
  4. package/dist/api-key.vo.js +2 -0
  5. package/dist/basename.vo.d.ts +1 -1
  6. package/dist/basename.vo.js +2 -0
  7. package/dist/day-iso-id.vo.d.ts +1 -1
  8. package/dist/day-iso-id.vo.js +2 -0
  9. package/dist/directory-path-absolute.vo.d.ts +1 -1
  10. package/dist/directory-path-absolute.vo.js +2 -0
  11. package/dist/directory-path-relative.vo.d.ts +1 -1
  12. package/dist/directory-path-relative.vo.js +3 -1
  13. package/dist/distance-value.vo.d.ts +1 -1
  14. package/dist/distance-value.vo.js +2 -0
  15. package/dist/division-factor.vo.d.ts +1 -1
  16. package/dist/division-factor.vo.js +2 -0
  17. package/dist/dll.service.js +2 -6
  18. package/dist/duration-ms.vo.d.ts +1 -1
  19. package/dist/duration-ms.vo.js +1 -0
  20. package/dist/email.vo.d.ts +1 -1
  21. package/dist/email.vo.js +1 -0
  22. package/dist/etags.vo.js +0 -2
  23. package/dist/extension.vo.d.ts +1 -1
  24. package/dist/extension.vo.js +2 -0
  25. package/dist/file-path-absolute-schema.vo.d.ts +1 -1
  26. package/dist/file-path-absolute-schema.vo.js +2 -0
  27. package/dist/file-path-relative-schema.vo.d.ts +1 -1
  28. package/dist/file-path-relative-schema.vo.js +2 -0
  29. package/dist/filename-affix.vo.d.ts +1 -1
  30. package/dist/filename-affix.vo.js +2 -0
  31. package/dist/height-milimiters.vo.d.ts +1 -1
  32. package/dist/height-milimiters.vo.js +2 -0
  33. package/dist/hour-schema.vo.d.ts +1 -1
  34. package/dist/hour-schema.vo.js +3 -1
  35. package/dist/iban-schema.vo.d.ts +1 -1
  36. package/dist/iban-schema.vo.js +2 -0
  37. package/dist/image.vo.d.ts +2 -2
  38. package/dist/image.vo.js +4 -0
  39. package/dist/integer-non-negative.vo.d.ts +1 -1
  40. package/dist/integer-non-negative.vo.js +2 -0
  41. package/dist/integer-positive.vo.d.ts +1 -1
  42. package/dist/integer-positive.vo.js +2 -0
  43. package/dist/integer.vo.d.ts +1 -1
  44. package/dist/integer.vo.js +1 -0
  45. package/dist/linear-regression.service.js +2 -0
  46. package/dist/mime-value.vo.d.ts +1 -1
  47. package/dist/mime-value.vo.js +2 -0
  48. package/dist/min-max-scaler.service.js +1 -1
  49. package/dist/minute-schema.vo.d.ts +1 -1
  50. package/dist/minute-schema.vo.js +2 -0
  51. package/dist/minute.vo.d.ts +1 -1
  52. package/dist/minute.vo.js +3 -3
  53. package/dist/money-amount.vo.d.ts +1 -1
  54. package/dist/money-amount.vo.js +2 -0
  55. package/dist/month-iso-id.vo.d.ts +1 -1
  56. package/dist/month-iso-id.vo.js +2 -0
  57. package/dist/multiplication-factor.vo.d.ts +1 -1
  58. package/dist/multiplication-factor.vo.js +2 -0
  59. package/dist/object-key.vo.d.ts +1 -1
  60. package/dist/object-key.vo.js +2 -0
  61. package/dist/package-version-schema.vo.d.ts +1 -1
  62. package/dist/package-version-schema.vo.js +2 -0
  63. package/dist/package-version.vo.js +1 -5
  64. package/dist/pagination-page.vo.js +1 -1
  65. package/dist/percentage.service.js +0 -2
  66. package/dist/quarter-iso-id.vo.d.ts +1 -1
  67. package/dist/quarter-iso-id.vo.js +2 -0
  68. package/dist/random.service.js +1 -3
  69. package/dist/reordering.service.js +2 -0
  70. package/dist/rounding-decimal.strategy.d.ts +1 -1
  71. package/dist/rounding-decimal.strategy.js +2 -0
  72. package/dist/size-bytes.vo.d.ts +1 -1
  73. package/dist/size-bytes.vo.js +2 -0
  74. package/dist/time-zone-offset-value.vo.d.ts +1 -1
  75. package/dist/time-zone-offset-value.vo.js +6 -4
  76. package/dist/timestamp-value.vo.d.ts +1 -1
  77. package/dist/timestamp-value.vo.js +2 -0
  78. package/dist/timezone.vo.d.ts +1 -1
  79. package/dist/timezone.vo.js +2 -0
  80. package/dist/url-with-slash.vo.d.ts +1 -1
  81. package/dist/url-with-slash.vo.js +3 -1
  82. package/dist/url-without-slash.vo.d.ts +1 -1
  83. package/dist/url-without-slash.vo.js +3 -1
  84. package/dist/week-iso-id.vo.d.ts +1 -1
  85. package/dist/week-iso-id.vo.js +2 -0
  86. package/dist/weekday.vo.d.ts +3 -1
  87. package/dist/weekday.vo.js +4 -3
  88. package/dist/weight-grams.vo.d.ts +1 -1
  89. package/dist/weight-grams.vo.js +2 -0
  90. package/dist/weight.vo.d.ts +0 -2
  91. package/dist/weight.vo.js +1 -7
  92. package/dist/year-iso-id.vo.d.ts +1 -1
  93. package/dist/year-iso-id.vo.js +2 -0
  94. package/dist/year.vo.js +5 -1
  95. package/package.json +4 -3
  96. package/src/age-years.vo.ts +2 -0
  97. package/src/api-key.vo.ts +2 -0
  98. package/src/basename.vo.ts +2 -0
  99. package/src/day-iso-id.vo.ts +2 -0
  100. package/src/directory-path-absolute.vo.ts +2 -0
  101. package/src/directory-path-relative.vo.ts +3 -1
  102. package/src/distance-value.vo.ts +2 -0
  103. package/src/division-factor.vo.ts +2 -0
  104. package/src/dll.service.ts +4 -8
  105. package/src/duration-ms.vo.ts +2 -0
  106. package/src/email.vo.ts +2 -0
  107. package/src/etags.vo.ts +0 -2
  108. package/src/extension.vo.ts +2 -0
  109. package/src/file-path-absolute-schema.vo.ts +2 -0
  110. package/src/file-path-relative-schema.vo.ts +2 -0
  111. package/src/filename-affix.vo.ts +2 -0
  112. package/src/height-milimiters.vo.ts +2 -0
  113. package/src/hour-schema.vo.ts +3 -1
  114. package/src/iban-schema.vo.ts +2 -0
  115. package/src/image.vo.ts +4 -0
  116. package/src/integer-non-negative.vo.ts +2 -0
  117. package/src/integer-positive.vo.ts +2 -0
  118. package/src/integer.vo.ts +2 -0
  119. package/src/linear-regression.service.ts +2 -0
  120. package/src/mime-value.vo.ts +2 -0
  121. package/src/min-max-scaler.service.ts +1 -1
  122. package/src/minute-schema.vo.ts +2 -0
  123. package/src/minute.vo.ts +4 -4
  124. package/src/money-amount.vo.ts +2 -0
  125. package/src/month-iso-id.vo.ts +2 -0
  126. package/src/multiplication-factor.vo.ts +2 -0
  127. package/src/object-key.vo.ts +2 -0
  128. package/src/package-version-schema.vo.ts +2 -0
  129. package/src/package-version.vo.ts +1 -4
  130. package/src/pagination-page.vo.ts +1 -1
  131. package/src/percentage.service.ts +0 -1
  132. package/src/quarter-iso-id.vo.ts +2 -0
  133. package/src/random.service.ts +1 -2
  134. package/src/reordering.service.ts +2 -0
  135. package/src/rounding-decimal.strategy.ts +2 -0
  136. package/src/size-bytes.vo.ts +2 -0
  137. package/src/time-zone-offset-value.vo.ts +6 -4
  138. package/src/timestamp-value.vo.ts +2 -0
  139. package/src/timezone.vo.ts +2 -0
  140. package/src/url-with-slash.vo.ts +3 -1
  141. package/src/url-without-slash.vo.ts +3 -1
  142. package/src/week-iso-id.vo.ts +2 -0
  143. package/src/weekday.vo.ts +4 -2
  144. package/src/weight-grams.vo.ts +2 -0
  145. package/src/weight.vo.ts +1 -9
  146. package/src/year-iso-id.vo.ts +2 -0
  147. package/src/year.vo.ts +3 -1
package/src/image.vo.ts CHANGED
@@ -5,7 +5,9 @@ export const ImageHeightError = { Type: "image.height.type", Length: "image.heig
5
5
 
6
6
  const IMAGE_DIMENSIONS_CONSTRAINTS = { min: 1, max: 10_000 };
7
7
 
8
+ // Stryker disable all
8
9
  export const ImageWidth = z
10
+ // Stryker restore all
9
11
  .number(ImageWidthError.Type)
10
12
  .int(ImageWidthError.Type)
11
13
  .min(IMAGE_DIMENSIONS_CONSTRAINTS.min, ImageWidthError.Length)
@@ -14,7 +16,9 @@ export const ImageWidth = z
14
16
 
15
17
  export type ImageWidthType = z.infer<typeof ImageWidth>;
16
18
 
19
+ // Stryker disable all
17
20
  export const ImageHeight = z
21
+ // Stryker restore all
18
22
  .number(ImageHeightError.Type)
19
23
  .int(ImageHeightError.Type)
20
24
  .min(IMAGE_DIMENSIONS_CONSTRAINTS.min, ImageHeightError.Length)
@@ -5,7 +5,9 @@ export const IntegerNonNegativeError = {
5
5
  Invalid: "integer.non.negative.invalid",
6
6
  };
7
7
 
8
+ // Stryker disable all
8
9
  export const IntegerNonNegative = z
10
+ // Stryker restore all
9
11
  .number(IntegerNonNegativeError.Type)
10
12
  .int(IntegerNonNegativeError.Type)
11
13
  .min(0, IntegerNonNegativeError.Invalid)
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const IntegerPositiveError = { Type: "integer.positive.type", Invalid: "integer.positive.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const IntegerPositive = z
7
+ // Stryker restore all
6
8
  .number(IntegerPositiveError.Type)
7
9
  .int(IntegerPositiveError.Type)
8
10
  .min(1, IntegerPositiveError.Invalid)
package/src/integer.vo.ts CHANGED
@@ -2,6 +2,8 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const IntegerError = { Type: "integer.type" };
4
4
 
5
+ // Stryker disable all
5
6
  export const Integer = z.number(IntegerError.Type).int(IntegerError.Type).brand("Integer");
7
+ // Stryker restore all
6
8
 
7
9
  export type IntegerType = z.infer<typeof Integer>;
@@ -45,8 +45,10 @@ export class LinearRegression {
45
45
 
46
46
  if (Math.abs(sumX) >= Number.MAX_SAFE_INTEGER) throw new Error(LinearRegressionError.SumXTooBig);
47
47
  if (Math.abs(sumY) >= Number.MAX_SAFE_INTEGER) throw new Error(LinearRegressionError.SumYTooBig);
48
+ // Stryker disable all
48
49
  if (Math.abs(sumXY) >= Number.MAX_SAFE_INTEGER) throw new Error(LinearRegressionError.SumXTimesYTooBig);
49
50
  if (Math.abs(sumXX) >= Number.MAX_SAFE_INTEGER) throw new Error(LinearRegressionError.SumXSquaredTooBig);
51
+ // Stryker restore all
50
52
 
51
53
  const bDenominator = sumXX - sumX ** 2 / count;
52
54
 
@@ -5,7 +5,9 @@ export const MimeValueError = { Type: "mime.value.type", Invalid: "mime.value.in
5
5
  // One to twenty four lowercase letters, asterisk or hyphen, forward slash, one to twenty four lowercase letters, asterisk or hyphen
6
6
  const MIME_VALUE_CHARS_WHITELIST = /^[a-z*-]{1,24}\/[a-z*-]{1,24}$/;
7
7
 
8
+ // Stryker disable all
8
9
  export const MimeValue = z
10
+ // Stryker restore all
9
11
  .string(MimeValueError.Type)
10
12
  .regex(MIME_VALUE_CHARS_WHITELIST, MimeValueError.Invalid)
11
13
  .transform((value) => ({ type: value.split("/")[0], subtype: value.split("/")[1] }))
@@ -61,7 +61,7 @@ export class MinMaxScaler {
61
61
  if (value < min || value > max) throw new Error(MinMaxScalerError.ValueOutOfRange);
62
62
 
63
63
  if (min === max) {
64
- return { original: value, scaled: (lower + upper) / 2, isMin: value === min, isMax: value === max };
64
+ return { original: value, scaled: (lower + upper) / 2, isMin: true, isMax: true };
65
65
  }
66
66
 
67
67
  const result = ((value - min) / (max - min)) * (upper - lower) + lower;
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const MinuteSchemaError = { Type: "minute.schema.error", Invalid: "minute.schema.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const MinuteSchema = z
7
+ // Stryker restore all
6
8
  .number(MinuteSchemaError.Type)
7
9
  .int(MinuteSchemaError.Type)
8
10
  .gte(0, MinuteSchemaError.Invalid)
package/src/minute.vo.ts CHANGED
@@ -37,14 +37,14 @@ export class Minute {
37
37
  return this.value === another.value;
38
38
  }
39
39
 
40
- isAfter(another: Minute): boolean {
41
- return this.value > another.value;
42
- }
43
-
44
40
  isBefore(another: Minute): boolean {
45
41
  return this.value < another.value;
46
42
  }
47
43
 
44
+ isAfter(another: Minute): boolean {
45
+ return this.value > another.value;
46
+ }
47
+
48
48
  static list(): readonly Minute[] {
49
49
  return Array.from({ length: 60 }, (_, index) => Minute.fromValue(index));
50
50
  }
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const MoneyAmountError = { Type: "money.amount.type", Invalid: "money.amount.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const MoneyAmount = z
7
+ // Stryker restore all
6
8
  .number(MoneyAmountError.Type)
7
9
  .int(MoneyAmountError.Type)
8
10
  .min(0, MoneyAmountError.Invalid)
@@ -9,7 +9,9 @@ export const MonthIsoIdError = {
9
9
  // Four digits, hyphen, two digits
10
10
  const MONTH_ISO_ID_CHARS_WHITELIST = /^\d{4}-\d{2}$/;
11
11
 
12
+ // Stryker disable all
12
13
  export const MonthIsoId = z
14
+ // Stryker restore all
13
15
  .string(MonthIsoIdError.Type)
14
16
  .regex(MONTH_ISO_ID_CHARS_WHITELIST, MonthIsoIdError.BadChars)
15
17
  .refine((value) => {
@@ -5,7 +5,9 @@ export const MultiplicationFactorError = {
5
5
  Invalid: "multiplication.factor.invalid",
6
6
  };
7
7
 
8
+ // Stryker disable all
8
9
  export const MultiplicationFactor = z
10
+ // Stryker restore all
9
11
  .number(MultiplicationFactorError.Type)
10
12
  .min(0, MultiplicationFactorError.Invalid)
11
13
  .brand("MultiplicationFactor");
@@ -14,7 +14,9 @@ const OBJECT_KEY_SEGMENT_CHARS_WHITELIST = /^[a-z0-9._-]+$/;
14
14
 
15
15
  const DOT_SEGMENTS = [".", ".."];
16
16
 
17
+ // Stryker disable all
17
18
  export const ObjectKey = z
19
+ // Stryker restore all
18
20
  .string(ObjectKeyError.Type)
19
21
  .min(1, ObjectKeyError.Empty)
20
22
  .max(256, ObjectKeyError.TooLong)
@@ -8,7 +8,9 @@ export const PackageVersionSchemaError = {
8
8
  // v, 1-4 digits, dot, 1-4 digits, dot, 1-4 digits - () for capturing groups
9
9
  const PACKAGE_VERSIONS_CHARS_WHITELIST = /^v([0-9]{1,4})\.([0-9]{1,4})\.([0-9]{1,4})$/;
10
10
 
11
+ // Stryker disable all
11
12
  export const PackageVersionSchema = z
13
+ // Stryker restore all
12
14
  .string(PackageVersionSchemaError.Type)
13
15
  .regex(PACKAGE_VERSIONS_CHARS_WHITELIST, PackageVersionSchemaError.BadChars)
14
16
  .transform((value) => {
@@ -30,10 +30,7 @@ export class PackageVersion {
30
30
  if (this.minor > another.minor) return true;
31
31
  if (this.minor < another.minor) return false;
32
32
 
33
- if (this.patch > another.patch) return true;
34
- if (this.patch < another.patch) return false;
35
-
36
- return true;
33
+ return this.patch >= another.patch;
37
34
  }
38
35
 
39
36
  toString(): string {
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod/v4";
2
2
 
3
- export const PaginationPageError = { Type: "pagination.page.Type" };
3
+ export const PaginationPageError = { Type: "pagination.page.type" };
4
4
 
5
5
  export const Page = z.coerce
6
6
  .number(PaginationPageError.Type)
@@ -10,7 +10,6 @@ export class Percentage {
10
10
  rounding: RoundingStrategy = new RoundingToNearestStrategy(),
11
11
  ): number {
12
12
  if (denominator === 0) throw new Error(PercentageError.InvalidDenominator);
13
- if (numerator === 0) return 0;
14
13
  return rounding.round((numerator / denominator) * 100);
15
14
  }
16
15
  }
@@ -5,7 +5,9 @@ export const QuarterIsoIdError = {
5
5
  BadChars: "quarter.iso.id.bad.chars",
6
6
  };
7
7
 
8
+ // Stryker disable all
8
9
  export const QuarterIsoId = z
10
+ // Stryker restore all
9
11
  .string(QuarterIsoIdError.Type)
10
12
  .regex(/^\d{4}-Q[1-4]$/, QuarterIsoIdError.BadChars)
11
13
  .brand("QuarterIsoId");
@@ -12,8 +12,7 @@ export class Random {
12
12
  const min = config ? config.min : Random.DEFAULT_MIN;
13
13
  const max = config ? config.max : Random.DEFAULT_MAX;
14
14
 
15
- if (min === max) throw new Error(RandomError.MinMax);
16
- if (min > max) throw new Error(RandomError.MinMax);
15
+ if (min >= max) throw new Error(RandomError.MinMax);
17
16
 
18
17
  return new RoundingDownStrategy().round(Math.random() * (max - min + 1)) + min;
19
18
  }
@@ -1,3 +1,4 @@
1
+ // Stryker disable all
1
2
  import { z } from "zod/v4";
2
3
  import { DoublyLinkedList, Node } from "./dll.service";
3
4
  import {
@@ -159,3 +160,4 @@ export class ReorderingIntegrator {
159
160
  a.position - b.position;
160
161
  }
161
162
  }
163
+ // Stryker restore all
@@ -3,7 +3,9 @@ import type { RoundingStrategy } from "./rounding.strategy";
3
3
 
4
4
  export const RoundingDecimalError = { Type: "rounding.decimal.type", Invalid: "rounding.decimal.invalid" };
5
5
 
6
+ // Stryker disable all
6
7
  export const RoundingDecimal = z
8
+ // Stryker restore all
7
9
  .number(RoundingDecimalError.Type)
8
10
  .int(RoundingDecimalError.Invalid)
9
11
  .min(1, RoundingDecimalError.Invalid)
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const SizeBytesError = { Invalid: "size.bytes.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const SizeBytes = z
7
+ // Stryker restore all
6
8
  .number(SizeBytesError.Invalid)
7
9
  .int(SizeBytesError.Invalid)
8
10
  .gte(0, SizeBytesError.Invalid)
@@ -6,13 +6,15 @@ export const TimeZoneOffsetValueError = {
6
6
  Max: "time.zone.offset.value.max",
7
7
  };
8
8
 
9
+ // Stryker disable all
9
10
  export const TimeZoneOffsetValue = z.coerce
10
- .number({ error: TimeZoneOffsetValueError.Type })
11
- .int({ error: TimeZoneOffsetValueError.Type })
11
+ // Stryker restore all
12
+ .number(TimeZoneOffsetValueError.Type)
13
+ .int(TimeZoneOffsetValueError.Type)
12
14
  // UTC+14 (Kiribati)
13
- .min(-840, { error: TimeZoneOffsetValueError.Min })
15
+ .min(-840, TimeZoneOffsetValueError.Min)
14
16
  // UTC-12 (Baker Island)
15
- .max(720, { error: TimeZoneOffsetValueError.Max })
17
+ .max(720, TimeZoneOffsetValueError.Max)
16
18
  .default(0) // Default to UTC if missing or invalid
17
19
  .brand("TimeZoneOffsetValue");
18
20
 
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const TimestampValueError = { Invalid: "timestamp.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const TimestampValue = z
7
+ // Stryker restore all
6
8
  .number(TimestampValueError.Invalid)
7
9
  .int(TimestampValueError.Invalid)
8
10
  .gte(0, TimestampValueError.Invalid)
@@ -7,7 +7,9 @@ export const TimezoneError = {
7
7
  Invalid: "timezone.invalid",
8
8
  };
9
9
 
10
+ // Stryker disable all
10
11
  export const Timezone = z
12
+ // Stryker restore all
11
13
  .string(TimezoneError.Type)
12
14
  .min(1, TimezoneError.Empty)
13
15
  .max(128, TimezoneError.TooLong)
@@ -2,8 +2,10 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const UrlWithSlashError = { Invalid: "url.with.slash.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const UrlWithSlash = z
6
- .url({ error: UrlWithSlashError.Invalid })
7
+ // Stryker disable all
8
+ .url(UrlWithSlashError.Invalid)
7
9
  .refine((value) => value.endsWith("/"), UrlWithSlashError.Invalid)
8
10
  .brand("UrlWithSlash");
9
11
 
@@ -2,8 +2,10 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const UrlWithoutSlashError = { Invalid: "url.without.slash.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const UrlWithoutSlash = z
6
- .url({ error: UrlWithoutSlashError.Invalid })
7
+ // Stryker restore all
8
+ .url(UrlWithoutSlashError.Invalid)
7
9
  .refine((value) => !value.endsWith("/"), UrlWithoutSlashError.Invalid)
8
10
  .brand("UrlWithoutSlash");
9
11
 
@@ -10,7 +10,9 @@ export const WeekIsoIdError = {
10
10
  // Four digits, hypen, W, followed by two digits
11
11
  const WEEK_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}-W[0-9]{2}$/;
12
12
 
13
+ // Stryker disable all
13
14
  export const WeekIsoId = z
15
+ // Stryker restore all
14
16
  .string(WeekIsoIdError.Type)
15
17
  .regex(WEEK_ISO_ID_CHARS_WHITELIST, WeekIsoIdError.BadChars)
16
18
  .refine((value) => {
package/src/weekday.vo.ts CHANGED
@@ -10,7 +10,7 @@ export enum WeekdayFormatterEnum {
10
10
  ZERO_BASED_NUMBER = "ZERO_BASED_NUMBER", // Sunday=0 ... Saturday=6 (JS)
11
11
  }
12
12
 
13
- export const WeekdayValueError = "invalid.weekday" as const;
13
+ export const WeekdayValueError = { Invalid: "weekday.invalid" } as const;
14
14
 
15
15
  const FULL_NAMES: readonly string[] = [
16
16
  "Sunday",
@@ -47,7 +47,9 @@ export class Weekday {
47
47
  static readonly SATURDAY = new Weekday(6);
48
48
 
49
49
  constructor(candidate: number, formatter?: WeekdayFormatter) {
50
- if (!Number.isInteger(candidate) || candidate < 0 || candidate > 6) throw new Error(WeekdayValueError);
50
+ if (!Number.isInteger(candidate) || candidate < 0 || candidate > 6) {
51
+ throw new Error(WeekdayValueError.Invalid);
52
+ }
51
53
 
52
54
  this.value = candidate;
53
55
  this.formatter = formatter ?? WeekdayFormatters.FULL;
@@ -2,7 +2,9 @@ import { z } from "zod/v4";
2
2
 
3
3
  export const WeightGramsError = { Type: "weight.grams.type", Invalid: "weight.grams.invalid" };
4
4
 
5
+ // Stryker disable all
5
6
  export const WeightGrams = z
7
+ // Stryker restore all
6
8
  .number(WeightGramsError.Type)
7
9
  .int(WeightGramsError.Type)
8
10
  .gte(0, WeightGramsError.Invalid)
package/src/weight.vo.ts CHANGED
@@ -50,7 +50,7 @@ export class Weight {
50
50
  subtract(other: Weight): Weight {
51
51
  const result = this.grams - other.grams;
52
52
 
53
- return new Weight(WeightGrams.parse(result < 0 ? 0 : result));
53
+ return new Weight(WeightGrams.parse(Math.max(0, result)), this.rounding);
54
54
  }
55
55
 
56
56
  multiply(factor: MultiplicationFactorType): Weight {
@@ -73,18 +73,10 @@ export class Weight {
73
73
  return this.grams > other.grams;
74
74
  }
75
75
 
76
- greaterThanOrEqual(other: Weight): boolean {
77
- return this.grams >= other.grams;
78
- }
79
-
80
76
  lessThan(other: Weight): boolean {
81
77
  return this.grams < other.grams;
82
78
  }
83
79
 
84
- lessThanOrEqual(other: Weight): boolean {
85
- return this.grams <= other.grams;
86
- }
87
-
88
80
  isZero(): boolean {
89
81
  return this.grams === 0;
90
82
  }
@@ -5,7 +5,9 @@ export const YearIsoIdError = { Type: "year.iso.id.type", BadChars: "year.iso.id
5
5
  // Four digits
6
6
  const YEAR_ISO_ID_CHARS_WHITELIST = /^[0-9]{4}$/;
7
7
 
8
+ // Stryker disable all
8
9
  export const YearIsoId = z
10
+ // Stryker restore all
9
11
  .string(YearIsoIdError.Type)
10
12
  .regex(YEAR_ISO_ID_CHARS_WHITELIST, YearIsoIdError.BadChars)
11
13
  .brand("YearIsoId");
package/src/year.vo.ts CHANGED
@@ -38,7 +38,9 @@ export class Year extends DateRange {
38
38
  isLeapYear(): boolean {
39
39
  const year = getYear(this.getStart().ms);
40
40
 
41
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
41
+ if (year % 400 === 0) return true;
42
+ if (year % 100 === 0) return false;
43
+ return year % 4 === 0;
42
44
  }
43
45
 
44
46
  previous(): Year {