@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.
- package/dist/age-years.vo.d.ts +1 -1
- package/dist/age-years.vo.js +2 -0
- package/dist/api-key.vo.d.ts +1 -1
- package/dist/api-key.vo.js +2 -0
- package/dist/basename.vo.d.ts +1 -1
- package/dist/basename.vo.js +2 -0
- package/dist/day-iso-id.vo.d.ts +1 -1
- package/dist/day-iso-id.vo.js +2 -0
- package/dist/directory-path-absolute.vo.d.ts +1 -1
- package/dist/directory-path-absolute.vo.js +2 -0
- package/dist/directory-path-relative.vo.d.ts +1 -1
- package/dist/directory-path-relative.vo.js +3 -1
- package/dist/distance-value.vo.d.ts +1 -1
- package/dist/distance-value.vo.js +2 -0
- package/dist/division-factor.vo.d.ts +1 -1
- package/dist/division-factor.vo.js +2 -0
- package/dist/dll.service.js +2 -6
- package/dist/duration-ms.vo.d.ts +1 -1
- package/dist/duration-ms.vo.js +1 -0
- package/dist/email.vo.d.ts +1 -1
- package/dist/email.vo.js +1 -0
- package/dist/etags.vo.js +0 -2
- package/dist/extension.vo.d.ts +1 -1
- package/dist/extension.vo.js +2 -0
- package/dist/file-path-absolute-schema.vo.d.ts +1 -1
- package/dist/file-path-absolute-schema.vo.js +2 -0
- package/dist/file-path-relative-schema.vo.d.ts +1 -1
- package/dist/file-path-relative-schema.vo.js +2 -0
- package/dist/filename-affix.vo.d.ts +1 -1
- package/dist/filename-affix.vo.js +2 -0
- package/dist/height-milimiters.vo.d.ts +1 -1
- package/dist/height-milimiters.vo.js +2 -0
- package/dist/hour-schema.vo.d.ts +1 -1
- package/dist/hour-schema.vo.js +3 -1
- package/dist/iban-schema.vo.d.ts +1 -1
- package/dist/iban-schema.vo.js +2 -0
- package/dist/image.vo.d.ts +2 -2
- package/dist/image.vo.js +4 -0
- package/dist/integer-non-negative.vo.d.ts +1 -1
- package/dist/integer-non-negative.vo.js +2 -0
- package/dist/integer-positive.vo.d.ts +1 -1
- package/dist/integer-positive.vo.js +2 -0
- package/dist/integer.vo.d.ts +1 -1
- package/dist/integer.vo.js +1 -0
- package/dist/linear-regression.service.js +2 -0
- package/dist/mime-value.vo.d.ts +1 -1
- package/dist/mime-value.vo.js +2 -0
- package/dist/min-max-scaler.service.js +1 -1
- package/dist/minute-schema.vo.d.ts +1 -1
- package/dist/minute-schema.vo.js +2 -0
- package/dist/minute.vo.d.ts +1 -1
- package/dist/minute.vo.js +3 -3
- package/dist/money-amount.vo.d.ts +1 -1
- package/dist/money-amount.vo.js +2 -0
- package/dist/month-iso-id.vo.d.ts +1 -1
- package/dist/month-iso-id.vo.js +2 -0
- package/dist/multiplication-factor.vo.d.ts +1 -1
- package/dist/multiplication-factor.vo.js +2 -0
- package/dist/object-key.vo.d.ts +1 -1
- package/dist/object-key.vo.js +2 -0
- package/dist/package-version-schema.vo.d.ts +1 -1
- package/dist/package-version-schema.vo.js +2 -0
- package/dist/package-version.vo.js +1 -5
- package/dist/pagination-page.vo.js +1 -1
- package/dist/percentage.service.js +0 -2
- package/dist/quarter-iso-id.vo.d.ts +1 -1
- package/dist/quarter-iso-id.vo.js +2 -0
- package/dist/random.service.js +1 -3
- package/dist/reordering.service.js +2 -0
- package/dist/rounding-decimal.strategy.d.ts +1 -1
- package/dist/rounding-decimal.strategy.js +2 -0
- package/dist/size-bytes.vo.d.ts +1 -1
- package/dist/size-bytes.vo.js +2 -0
- package/dist/time-zone-offset-value.vo.d.ts +1 -1
- package/dist/time-zone-offset-value.vo.js +6 -4
- package/dist/timestamp-value.vo.d.ts +1 -1
- package/dist/timestamp-value.vo.js +2 -0
- package/dist/timezone.vo.d.ts +1 -1
- package/dist/timezone.vo.js +2 -0
- package/dist/url-with-slash.vo.d.ts +1 -1
- package/dist/url-with-slash.vo.js +3 -1
- package/dist/url-without-slash.vo.d.ts +1 -1
- package/dist/url-without-slash.vo.js +3 -1
- package/dist/week-iso-id.vo.d.ts +1 -1
- package/dist/week-iso-id.vo.js +2 -0
- package/dist/weekday.vo.d.ts +3 -1
- package/dist/weekday.vo.js +4 -3
- package/dist/weight-grams.vo.d.ts +1 -1
- package/dist/weight-grams.vo.js +2 -0
- package/dist/weight.vo.d.ts +0 -2
- package/dist/weight.vo.js +1 -7
- package/dist/year-iso-id.vo.d.ts +1 -1
- package/dist/year-iso-id.vo.js +2 -0
- package/dist/year.vo.js +5 -1
- package/package.json +4 -3
- package/src/age-years.vo.ts +2 -0
- package/src/api-key.vo.ts +2 -0
- package/src/basename.vo.ts +2 -0
- package/src/day-iso-id.vo.ts +2 -0
- package/src/directory-path-absolute.vo.ts +2 -0
- package/src/directory-path-relative.vo.ts +3 -1
- package/src/distance-value.vo.ts +2 -0
- package/src/division-factor.vo.ts +2 -0
- package/src/dll.service.ts +4 -8
- package/src/duration-ms.vo.ts +2 -0
- package/src/email.vo.ts +2 -0
- package/src/etags.vo.ts +0 -2
- package/src/extension.vo.ts +2 -0
- package/src/file-path-absolute-schema.vo.ts +2 -0
- package/src/file-path-relative-schema.vo.ts +2 -0
- package/src/filename-affix.vo.ts +2 -0
- package/src/height-milimiters.vo.ts +2 -0
- package/src/hour-schema.vo.ts +3 -1
- package/src/iban-schema.vo.ts +2 -0
- package/src/image.vo.ts +4 -0
- package/src/integer-non-negative.vo.ts +2 -0
- package/src/integer-positive.vo.ts +2 -0
- package/src/integer.vo.ts +2 -0
- package/src/linear-regression.service.ts +2 -0
- package/src/mime-value.vo.ts +2 -0
- package/src/min-max-scaler.service.ts +1 -1
- package/src/minute-schema.vo.ts +2 -0
- package/src/minute.vo.ts +4 -4
- package/src/money-amount.vo.ts +2 -0
- package/src/month-iso-id.vo.ts +2 -0
- package/src/multiplication-factor.vo.ts +2 -0
- package/src/object-key.vo.ts +2 -0
- package/src/package-version-schema.vo.ts +2 -0
- package/src/package-version.vo.ts +1 -4
- package/src/pagination-page.vo.ts +1 -1
- package/src/percentage.service.ts +0 -1
- package/src/quarter-iso-id.vo.ts +2 -0
- package/src/random.service.ts +1 -2
- package/src/reordering.service.ts +2 -0
- package/src/rounding-decimal.strategy.ts +2 -0
- package/src/size-bytes.vo.ts +2 -0
- package/src/time-zone-offset-value.vo.ts +6 -4
- package/src/timestamp-value.vo.ts +2 -0
- package/src/timezone.vo.ts +2 -0
- package/src/url-with-slash.vo.ts +3 -1
- package/src/url-without-slash.vo.ts +3 -1
- package/src/week-iso-id.vo.ts +2 -0
- package/src/weekday.vo.ts +4 -2
- package/src/weight-grams.vo.ts +2 -0
- package/src/weight.vo.ts +1 -9
- package/src/year-iso-id.vo.ts +2 -0
- 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
|
|
package/src/mime-value.vo.ts
CHANGED
|
@@ -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:
|
|
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;
|
package/src/minute-schema.vo.ts
CHANGED
|
@@ -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
|
}
|
package/src/money-amount.vo.ts
CHANGED
|
@@ -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)
|
package/src/month-iso-id.vo.ts
CHANGED
|
@@ -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");
|
package/src/object-key.vo.ts
CHANGED
|
@@ -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
|
-
|
|
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 {
|
|
@@ -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
|
}
|
package/src/quarter-iso-id.vo.ts
CHANGED
|
@@ -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");
|
package/src/random.service.ts
CHANGED
|
@@ -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
|
|
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
|
}
|
|
@@ -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)
|
package/src/size-bytes.vo.ts
CHANGED
|
@@ -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
|
-
|
|
11
|
-
.
|
|
11
|
+
// Stryker restore all
|
|
12
|
+
.number(TimeZoneOffsetValueError.Type)
|
|
13
|
+
.int(TimeZoneOffsetValueError.Type)
|
|
12
14
|
// UTC+14 (Kiribati)
|
|
13
|
-
.min(-840,
|
|
15
|
+
.min(-840, TimeZoneOffsetValueError.Min)
|
|
14
16
|
// UTC-12 (Baker Island)
|
|
15
|
-
.max(720,
|
|
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)
|
package/src/timezone.vo.ts
CHANGED
package/src/url-with-slash.vo.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
7
|
+
// Stryker restore all
|
|
8
|
+
.url(UrlWithoutSlashError.Invalid)
|
|
7
9
|
.refine((value) => !value.endsWith("/"), UrlWithoutSlashError.Invalid)
|
|
8
10
|
.brand("UrlWithoutSlash");
|
|
9
11
|
|
package/src/week-iso-id.vo.ts
CHANGED
|
@@ -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
|
|
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)
|
|
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;
|
package/src/weight-grams.vo.ts
CHANGED
|
@@ -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(
|
|
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
|
}
|
package/src/year-iso-id.vo.ts
CHANGED
|
@@ -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
|
-
|
|
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 {
|