@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.
- package/dist/age-years.vo.d.ts +3 -3
- package/dist/age-years.vo.js +4 -9
- package/dist/age.vo.js +2 -1
- package/dist/api-key.vo.d.ts +3 -4
- package/dist/api-key.vo.js +5 -9
- package/dist/basename.vo.d.ts +3 -3
- package/dist/basename.vo.js +10 -15
- package/dist/day-iso-id.vo.d.ts +3 -3
- package/dist/day-iso-id.vo.js +4 -8
- package/dist/day.vo.d.ts +1 -1
- package/dist/day.vo.js +7 -6
- package/dist/directory-path-absolute.vo.d.ts +3 -3
- package/dist/directory-path-absolute.vo.js +5 -12
- package/dist/directory-path-relative.vo.d.ts +3 -3
- package/dist/directory-path-relative.vo.js +5 -12
- package/dist/distance-value.vo.d.ts +3 -3
- package/dist/distance-value.vo.js +4 -8
- package/dist/distance.vo.js +7 -6
- package/dist/division-factor.vo.d.ts +3 -3
- package/dist/division-factor.vo.js +4 -7
- package/dist/duration-ms.vo.d.ts +3 -3
- package/dist/duration-ms.vo.js +4 -3
- package/dist/duration.service.js +2 -1
- package/dist/email.vo.d.ts +3 -3
- package/dist/email.vo.js +3 -3
- package/dist/etags.vo.js +3 -2
- package/dist/extension.vo.d.ts +3 -3
- package/dist/extension.vo.js +6 -12
- package/dist/feature-flag-value.vo.d.ts +3 -3
- package/dist/feature-flag-value.vo.js +2 -2
- package/dist/file-path-absolute-schema.vo.d.ts +8 -5
- package/dist/file-path-absolute-schema.vo.js +6 -13
- package/dist/file-path-relative-schema.vo.d.ts +8 -5
- package/dist/file-path-relative-schema.vo.js +6 -13
- package/dist/file-path.vo.js +5 -4
- package/dist/filename-affix.vo.d.ts +3 -3
- package/dist/filename-affix.vo.js +4 -9
- package/dist/filename-from-string.vo.d.ts +6 -6
- package/dist/filename-from-string.vo.js +5 -8
- package/dist/filename.vo.js +8 -7
- package/dist/height-milimiters.vo.d.ts +3 -3
- package/dist/height-milimiters.vo.js +4 -8
- package/dist/height.vo.js +4 -3
- package/dist/hour-value.vo.d.ts +3 -3
- package/dist/hour-value.vo.js +4 -9
- package/dist/hour.vo.js +3 -2
- package/dist/iban-schema.vo.d.ts +3 -3
- package/dist/iban-schema.vo.js +4 -9
- package/dist/iban.vo.js +2 -1
- package/dist/image.vo.d.ts +5 -5
- package/dist/image.vo.js +7 -17
- package/dist/integer-non-negative.vo.d.ts +3 -3
- package/dist/integer-non-negative.vo.js +4 -8
- package/dist/integer-positive.vo.d.ts +3 -3
- package/dist/integer-positive.vo.js +4 -8
- package/dist/integer.vo.d.ts +3 -3
- package/dist/integer.vo.js +3 -3
- package/dist/language.vo.d.ts +3 -3
- package/dist/language.vo.js +2 -2
- package/dist/mime-value.vo.d.ts +3 -2
- package/dist/mime-value.vo.js +4 -7
- package/dist/mime.vo.js +2 -1
- package/dist/mimes.js +12 -11
- package/dist/minute-value.vo.d.ts +3 -3
- package/dist/minute-value.vo.js +4 -9
- package/dist/minute.vo.js +3 -2
- package/dist/money-amount.vo.d.ts +3 -3
- package/dist/money-amount.vo.js +4 -8
- package/dist/money.vo.js +7 -6
- package/dist/month-iso-id.vo.d.ts +3 -3
- package/dist/month-iso-id.vo.js +5 -9
- package/dist/month.vo.js +5 -4
- package/dist/multiplication-factor.vo.d.ts +3 -3
- package/dist/multiplication-factor.vo.js +4 -7
- package/dist/object-key.vo.d.ts +3 -3
- package/dist/object-key.vo.js +8 -13
- package/dist/package-version-schema.vo.d.ts +3 -3
- package/dist/package-version-schema.vo.js +4 -7
- package/dist/package-version.vo.js +3 -4
- package/dist/pagination-page.vo.d.ts +3 -3
- package/dist/pagination-page.vo.js +2 -6
- package/dist/pagination-skip.vo.d.ts +3 -3
- package/dist/pagination-skip.vo.js +2 -5
- package/dist/pagination-take.vo.d.ts +3 -3
- package/dist/pagination-take.vo.js +2 -5
- package/dist/pagination.service.js +8 -7
- package/dist/quarter-iso-id.vo.d.ts +4 -3
- package/dist/quarter-iso-id.vo.js +7 -11
- package/dist/quarter.vo.js +3 -2
- package/dist/reordering-item-position-value.vo.d.ts +3 -3
- package/dist/reordering-item-position-value.vo.js +2 -5
- package/dist/reordering.service.d.ts +9 -9
- package/dist/reordering.service.js +7 -7
- package/dist/revision-value.vo.d.ts +3 -3
- package/dist/revision-value.vo.js +2 -5
- package/dist/revision.vo.js +3 -2
- package/dist/rounding-decimal.strategy.d.ts +2 -2
- package/dist/rounding-decimal.strategy.js +5 -10
- package/dist/size-bytes.vo.d.ts +3 -3
- package/dist/size-bytes.vo.js +4 -8
- package/dist/size.vo.js +5 -4
- package/dist/time-zone-offset-value.vo.d.ts +3 -3
- package/dist/time-zone-offset-value.vo.js +8 -12
- package/dist/timestamp-value.vo.d.ts +3 -3
- package/dist/timestamp-value.vo.js +4 -8
- package/dist/timestamp.vo.js +2 -1
- package/dist/timezone.vo.d.ts +3 -3
- package/dist/timezone.vo.js +7 -10
- package/dist/url-with-slash.vo.d.ts +3 -3
- package/dist/url-with-slash.vo.js +4 -7
- package/dist/url-without-slash.vo.d.ts +3 -3
- package/dist/url-without-slash.vo.js +4 -7
- package/dist/week-iso-id.vo.d.ts +3 -3
- package/dist/week-iso-id.vo.js +5 -9
- package/dist/week.vo.js +5 -4
- package/dist/weekday-iso-id.vo.d.ts +3 -3
- package/dist/weekday-iso-id.vo.js +4 -9
- package/dist/weekday.vo.js +9 -8
- package/dist/weight-grams.vo.d.ts +3 -3
- package/dist/weight-grams.vo.js +4 -8
- package/dist/weight.vo.js +8 -7
- package/dist/year-iso-id.vo.d.ts +3 -3
- package/dist/year-iso-id.vo.js +4 -7
- package/dist/year.vo.js +6 -5
- package/package.json +9 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
import { DirectoryPathRelativeSchema } from "./directory-path-relative.vo";
|
|
3
3
|
import { Filename } from "./filename.vo";
|
|
4
4
|
export const FilePathRelativeSchemaError = {
|
|
@@ -8,20 +8,13 @@ export const FilePathRelativeSchemaError = {
|
|
|
8
8
|
RequiresDirectory: "file.path.relative.requires.directory",
|
|
9
9
|
Empty: "file.path.relative.empty",
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
export const FilePathRelativeSchema = z
|
|
13
|
-
// Stryker restore all
|
|
14
|
-
.string(FilePathRelativeSchemaError.Type)
|
|
15
|
-
.min(1, FilePathRelativeSchemaError.Empty)
|
|
16
|
-
.refine((value) => !value.startsWith("/"), FilePathRelativeSchemaError.LeadingSlash)
|
|
17
|
-
.refine((value) => !value.includes("\\"), FilePathRelativeSchemaError.BackslashForbidden)
|
|
18
|
-
.refine((value) => value.includes("/"), FilePathRelativeSchemaError.RequiresDirectory)
|
|
19
|
-
.transform((normalized) => {
|
|
11
|
+
export const FilePathRelativeSchema = v.pipe(v.string(FilePathRelativeSchemaError.Type), v.minLength(1, FilePathRelativeSchemaError.Empty), v.check((value) => !value.startsWith("/"), FilePathRelativeSchemaError.LeadingSlash), v.check((value) => !value.includes("\\"), FilePathRelativeSchemaError.BackslashForbidden), v.check((value) => value.includes("/"), FilePathRelativeSchemaError.RequiresDirectory), v.transform((normalized) => {
|
|
20
12
|
const lastSlashIndex = normalized.lastIndexOf("/");
|
|
21
13
|
const directoryCandidate = normalized.slice(0, lastSlashIndex);
|
|
22
14
|
const filenameCandidate = normalized.slice(lastSlashIndex + 1);
|
|
23
|
-
const directory =
|
|
15
|
+
const directory = v.parse(DirectoryPathRelativeSchema, directoryCandidate);
|
|
24
16
|
const filename = Filename.fromString(filenameCandidate);
|
|
25
17
|
return { directory, filename };
|
|
26
|
-
})
|
|
27
|
-
|
|
18
|
+
}),
|
|
19
|
+
// Stryker disable next-line StringLiteral
|
|
20
|
+
v.brand("FilePathRelativeSchema"));
|
package/dist/file-path.vo.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { DirectoryPathAbsoluteSchema } from "./directory-path-absolute.vo";
|
|
2
3
|
import { DirectoryPathRelativeSchema } from "./directory-path-relative.vo";
|
|
3
4
|
import { FilePathAbsoluteSchema } from "./file-path-absolute-schema.vo";
|
|
@@ -10,14 +11,14 @@ export class FilePathRelative {
|
|
|
10
11
|
this.filename = filename;
|
|
11
12
|
}
|
|
12
13
|
static fromParts(directoryCandidate, filename) {
|
|
13
|
-
const directory =
|
|
14
|
+
const directory = v.parse(DirectoryPathRelativeSchema, directoryCandidate);
|
|
14
15
|
return new FilePathRelative(directory, filename);
|
|
15
16
|
}
|
|
16
17
|
static fromPartsSafe(directory, filename) {
|
|
17
18
|
return new FilePathRelative(directory, filename);
|
|
18
19
|
}
|
|
19
20
|
static fromString(candidate) {
|
|
20
|
-
const schema =
|
|
21
|
+
const schema = v.parse(FilePathRelativeSchema, candidate);
|
|
21
22
|
return new FilePathRelative(schema.directory, schema.filename);
|
|
22
23
|
}
|
|
23
24
|
get() {
|
|
@@ -47,14 +48,14 @@ export class FilePathAbsolute {
|
|
|
47
48
|
this.filename = filename;
|
|
48
49
|
}
|
|
49
50
|
static fromParts(directoryCandidate, filename) {
|
|
50
|
-
const directory =
|
|
51
|
+
const directory = v.parse(DirectoryPathAbsoluteSchema, directoryCandidate);
|
|
51
52
|
return new FilePathAbsolute(directory, filename);
|
|
52
53
|
}
|
|
53
54
|
static fromPartsSafe(directory, filename) {
|
|
54
55
|
return new FilePathAbsolute(directory, filename);
|
|
55
56
|
}
|
|
56
57
|
static fromString(candidate) {
|
|
57
|
-
const schema =
|
|
58
|
+
const schema = v.parse(FilePathAbsoluteSchema, candidate);
|
|
58
59
|
return new FilePathAbsolute(schema.directory, schema.filename);
|
|
59
60
|
}
|
|
60
61
|
get() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare enum FilenameAffixStrategy {
|
|
3
3
|
prefix = "prefix",
|
|
4
4
|
suffix = "suffix"
|
|
@@ -9,5 +9,5 @@ export declare const FilenameAffixError: {
|
|
|
9
9
|
TooLong: string;
|
|
10
10
|
BadChars: string;
|
|
11
11
|
};
|
|
12
|
-
export declare const FilenameAffix:
|
|
13
|
-
export type FilenameAffixType =
|
|
12
|
+
export declare const FilenameAffix: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.MinLengthAction<string, 1, string>, v.MaxLengthAction<string, 32, string>, v.RegexAction<string, string>, v.BrandAction<string, "FilenameAffix">]>;
|
|
13
|
+
export type FilenameAffixType = v.InferOutput<typeof FilenameAffix>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export var FilenameAffixStrategy;
|
|
3
3
|
(function (FilenameAffixStrategy) {
|
|
4
4
|
FilenameAffixStrategy["prefix"] = "prefix";
|
|
@@ -12,11 +12,6 @@ export const FilenameAffixError = {
|
|
|
12
12
|
};
|
|
13
13
|
// Letters, digits, underscores, and hyphens allowed
|
|
14
14
|
const FILENAME_AFFIX_WHITELIST = /^[a-zA-Z0-9_-]+$/;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.string(FilenameAffixError.Type)
|
|
19
|
-
.min(1, FilenameAffixError.Empty)
|
|
20
|
-
.max(32, FilenameAffixError.TooLong)
|
|
21
|
-
.regex(FILENAME_AFFIX_WHITELIST, FilenameAffixError.BadChars)
|
|
22
|
-
.brand("FilenameAffix");
|
|
15
|
+
export const FilenameAffix = v.pipe(v.string(FilenameAffixError.Type), v.minLength(1, FilenameAffixError.Empty), v.maxLength(32, FilenameAffixError.TooLong), v.regex(FILENAME_AFFIX_WHITELIST, FilenameAffixError.BadChars),
|
|
16
|
+
// Stryker disable next-line StringLiteral
|
|
17
|
+
v.brand("FilenameAffix"));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const FilenameFromStringError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Invalid: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const FilenameFromString:
|
|
7
|
-
basename: string &
|
|
8
|
-
extension: string &
|
|
9
|
-
}
|
|
10
|
-
export type FilenameFromStringType =
|
|
6
|
+
export declare const FilenameFromString: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.TransformAction<string, {
|
|
7
|
+
basename: string & v.Brand<"Basename">;
|
|
8
|
+
extension: string & v.Brand<"Extension">;
|
|
9
|
+
}>]>;
|
|
10
|
+
export type FilenameFromStringType = v.InferOutput<typeof FilenameFromString>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
import { Basename } from "./basename.vo";
|
|
3
3
|
import { Extension } from "./extension.vo";
|
|
4
4
|
export const FilenameFromStringError = {
|
|
@@ -9,12 +9,9 @@ export const FilenameFromStringError = {
|
|
|
9
9
|
// .
|
|
10
10
|
// .+ at least one character
|
|
11
11
|
const DOT_WITH_SIDES = /^.+\..+$/;
|
|
12
|
-
export const FilenameFromString =
|
|
13
|
-
.string(FilenameFromStringError.Type)
|
|
14
|
-
.regex(DOT_WITH_SIDES, FilenameFromStringError.Invalid)
|
|
15
|
-
.transform((value) => {
|
|
12
|
+
export const FilenameFromString = v.pipe(v.string(FilenameFromStringError.Type), v.regex(DOT_WITH_SIDES, FilenameFromStringError.Invalid), v.transform((value) => {
|
|
16
13
|
const index = value.lastIndexOf(".");
|
|
17
|
-
const basename =
|
|
18
|
-
const extension =
|
|
14
|
+
const basename = v.parse(Basename, value.slice(0, index));
|
|
15
|
+
const extension = v.parse(Extension, value.slice(index + 1));
|
|
19
16
|
return { basename, extension };
|
|
20
|
-
});
|
|
17
|
+
}));
|
package/dist/filename.vo.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { Basename } from "./basename.vo";
|
|
2
3
|
import { Extension } from "./extension.vo";
|
|
3
4
|
import { FilenameAffix, FilenameAffixStrategy } from "./filename-affix.vo";
|
|
@@ -10,13 +11,13 @@ export class Filename {
|
|
|
10
11
|
this.extension = extension;
|
|
11
12
|
}
|
|
12
13
|
static fromParts(basename, extension) {
|
|
13
|
-
return new Filename(
|
|
14
|
+
return new Filename(v.parse(Basename, basename), v.parse(Extension, extension));
|
|
14
15
|
}
|
|
15
16
|
static fromPartsSafe(basename, extension) {
|
|
16
17
|
return new Filename(basename, extension);
|
|
17
18
|
}
|
|
18
19
|
static fromString(candidate) {
|
|
19
|
-
const filename =
|
|
20
|
+
const filename = v.parse(FilenameFromString, candidate);
|
|
20
21
|
return new Filename(filename.basename, filename.extension);
|
|
21
22
|
}
|
|
22
23
|
get() {
|
|
@@ -35,17 +36,17 @@ export class Filename {
|
|
|
35
36
|
return new Filename(basename, this.extension);
|
|
36
37
|
}
|
|
37
38
|
withAffix(candidate, strategy) {
|
|
38
|
-
const affix =
|
|
39
|
+
const affix = v.parse(FilenameAffix, candidate);
|
|
39
40
|
if (strategy === FilenameAffixStrategy.prefix) {
|
|
40
|
-
return new Filename(
|
|
41
|
+
return new Filename(v.parse(Basename, `${affix}${this.basename}`), this.extension);
|
|
41
42
|
}
|
|
42
|
-
return new Filename(
|
|
43
|
+
return new Filename(v.parse(Basename, `${this.basename}${affix}`), this.extension);
|
|
43
44
|
}
|
|
44
45
|
withAffixSafe(affix, strategy) {
|
|
45
46
|
if (strategy === FilenameAffixStrategy.prefix) {
|
|
46
|
-
return new Filename(
|
|
47
|
+
return new Filename(v.parse(Basename, `${affix}${this.basename}`), this.extension);
|
|
47
48
|
}
|
|
48
|
-
return new Filename(
|
|
49
|
+
return new Filename(v.parse(Basename, `${this.basename}${affix}`), this.extension);
|
|
49
50
|
}
|
|
50
51
|
withSuffix(candidate) {
|
|
51
52
|
return this.withAffix(candidate, FilenameAffixStrategy.suffix);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const HeightMillimetersError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Invalid: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const HeightMillimeters:
|
|
7
|
-
export type HeightMillimetersType =
|
|
6
|
+
export declare const HeightMillimeters: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "HeightMillimeters">]>;
|
|
7
|
+
export type HeightMillimetersType = v.InferOutput<typeof HeightMillimeters>;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const HeightMillimetersError = {
|
|
3
3
|
Type: "height.millimeters.type",
|
|
4
4
|
Invalid: "height.millimeters.invalid",
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.number(HeightMillimetersError.Type)
|
|
10
|
-
.int(HeightMillimetersError.Type)
|
|
11
|
-
.min(0, HeightMillimetersError.Invalid)
|
|
12
|
-
.brand("HeightMillimeters");
|
|
6
|
+
export const HeightMillimeters = v.pipe(v.number(HeightMillimetersError.Type), v.integer(HeightMillimetersError.Type), v.minValue(0, HeightMillimetersError.Invalid),
|
|
7
|
+
// Stryker disable next-line StringLiteral
|
|
8
|
+
v.brand("HeightMillimeters"));
|
package/dist/height.vo.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { HeightMillimeters } from "./height-milimiters.vo";
|
|
2
3
|
import { RoundingToNearestStrategy } from "./rounding-to-nearest.strategy";
|
|
3
4
|
export class Height {
|
|
4
5
|
millimeters;
|
|
5
|
-
static ZERO =
|
|
6
|
+
static ZERO = v.parse(HeightMillimeters, 0);
|
|
6
7
|
static MILLIMETERS_PER_CENTIMETER = 10;
|
|
7
8
|
constructor(millimeters) {
|
|
8
9
|
this.millimeters = millimeters;
|
|
9
10
|
}
|
|
10
11
|
static fromMillimeters(millimeters) {
|
|
11
|
-
return new Height(
|
|
12
|
+
return new Height(v.parse(HeightMillimeters, millimeters));
|
|
12
13
|
}
|
|
13
14
|
static fromMillimetersSafe(millimeters) {
|
|
14
15
|
return new Height(millimeters);
|
|
15
16
|
}
|
|
16
17
|
static fromCentimeters(centimeters, rounding = new RoundingToNearestStrategy()) {
|
|
17
18
|
const millimeters = rounding.round(centimeters * Height.MILLIMETERS_PER_CENTIMETER);
|
|
18
|
-
return new Height(
|
|
19
|
+
return new Height(v.parse(HeightMillimeters, millimeters));
|
|
19
20
|
}
|
|
20
21
|
static zero() {
|
|
21
22
|
return Height.fromMillimetersSafe(Height.ZERO);
|
package/dist/hour-value.vo.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const HourValueError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Invalid: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const HourValue:
|
|
7
|
-
export type HourValueType =
|
|
6
|
+
export declare const HourValue: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.MaxValueAction<number, 23, string>, v.BrandAction<number, "HourSchema">]>;
|
|
7
|
+
export type HourValueType = v.InferOutput<typeof HourValue>;
|
package/dist/hour-value.vo.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const HourValueError = { Type: "hour.value.type", Invalid: "hour.value.invalid" };
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.number(HourValueError.Type)
|
|
7
|
-
.int(HourValueError.Type)
|
|
8
|
-
.gte(0, HourValueError.Invalid)
|
|
9
|
-
.lte(23, HourValueError.Invalid)
|
|
10
|
-
.brand("HourSchema");
|
|
3
|
+
export const HourValue = v.pipe(v.number(HourValueError.Type), v.integer(HourValueError.Type), v.minValue(0, HourValueError.Invalid), v.maxValue(23, HourValueError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("HourSchema"));
|
package/dist/hour.vo.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { HourValue } from "./hour-value.vo";
|
|
2
3
|
import { Timestamp } from "./timestamp.vo";
|
|
3
4
|
export class Hour {
|
|
@@ -6,13 +7,13 @@ export class Hour {
|
|
|
6
7
|
this.value = value;
|
|
7
8
|
}
|
|
8
9
|
static fromValue(candidate) {
|
|
9
|
-
return new Hour(
|
|
10
|
+
return new Hour(v.parse(HourValue, candidate));
|
|
10
11
|
}
|
|
11
12
|
static fromValueSafe(candidate) {
|
|
12
13
|
return new Hour(candidate);
|
|
13
14
|
}
|
|
14
15
|
static fromTimestamp(timestamp) {
|
|
15
|
-
return new Hour(
|
|
16
|
+
return new Hour(v.parse(HourValue, new Date(timestamp.ms).getUTCHours()));
|
|
16
17
|
}
|
|
17
18
|
static fromTimestampValue(timestamp) {
|
|
18
19
|
return Hour.fromTimestamp(Timestamp.fromValue(timestamp));
|
package/dist/iban-schema.vo.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const IbanSchemaError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Invalid: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const IbanSchema:
|
|
7
|
-
export type IbanSchemaType =
|
|
6
|
+
export declare const IbanSchema: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.ToUpperCaseAction, v.TransformAction<string, string>, v.CheckAction<string, string>, v.BrandAction<string, "IbanSchema">]>;
|
|
7
|
+
export type IbanSchemaType = v.InferOutput<typeof IbanSchema>;
|
package/dist/iban-schema.vo.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const IbanSchemaError = { Type: "iban.schema.type", Invalid: "iban.schema.invalid" };
|
|
3
3
|
// Two letters for country code, two digits, 11–30 uppercase letters or digits
|
|
4
4
|
const IBAN_CHARS_WHITELIST = /^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$/;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.string(IbanSchemaError.Type)
|
|
9
|
-
.toUpperCase()
|
|
10
|
-
.transform((value) => value.replaceAll(" ", ""))
|
|
11
|
-
.refine((value) => IBAN_CHARS_WHITELIST.test(value), IbanSchemaError.Invalid)
|
|
12
|
-
.brand("IbanSchema");
|
|
5
|
+
export const IbanSchema = v.pipe(v.string(IbanSchemaError.Type), v.toUpperCase(), v.transform((value) => value.replaceAll(" ", "")), v.check((value) => IBAN_CHARS_WHITELIST.test(value), IbanSchemaError.Invalid),
|
|
6
|
+
// Stryker disable next-line StringLiteral
|
|
7
|
+
v.brand("IbanSchema"));
|
package/dist/iban.vo.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { IbanSchema } from "./iban-schema.vo";
|
|
2
3
|
export class IBAN {
|
|
3
4
|
value;
|
|
4
5
|
constructor(candidate) {
|
|
5
|
-
this.value =
|
|
6
|
+
this.value = v.parse(IbanSchema, candidate);
|
|
6
7
|
}
|
|
7
8
|
toString() {
|
|
8
9
|
return this.value;
|
package/dist/image.vo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const ImageWidthError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Length: string;
|
|
@@ -7,7 +7,7 @@ export declare const ImageHeightError: {
|
|
|
7
7
|
Type: string;
|
|
8
8
|
Length: string;
|
|
9
9
|
};
|
|
10
|
-
export declare const ImageWidth:
|
|
11
|
-
export type ImageWidthType =
|
|
12
|
-
export declare const ImageHeight:
|
|
13
|
-
export type ImageHeightType =
|
|
10
|
+
export declare const ImageWidth: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, number, string>, v.MaxValueAction<number, number, string>, v.BrandAction<number, "ImageWidth">]>;
|
|
11
|
+
export type ImageWidthType = v.InferOutput<typeof ImageWidth>;
|
|
12
|
+
export declare const ImageHeight: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, number, string>, v.MaxValueAction<number, number, string>, v.BrandAction<number, "ImageHeight">]>;
|
|
13
|
+
export type ImageHeightType = v.InferOutput<typeof ImageHeight>;
|
package/dist/image.vo.js
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const ImageWidthError = { Type: "image.width.type", Length: "image.width.length" };
|
|
3
3
|
export const ImageHeightError = { Type: "image.height.type", Length: "image.height.length" };
|
|
4
4
|
const IMAGE_DIMENSIONS_CONSTRAINTS = { min: 1, max: 10_000 };
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.max(IMAGE_DIMENSIONS_CONSTRAINTS.max, ImageWidthError.Length)
|
|
12
|
-
.brand("ImageWidth");
|
|
13
|
-
// Stryker disable all
|
|
14
|
-
export const ImageHeight = z
|
|
15
|
-
// Stryker restore all
|
|
16
|
-
.number(ImageHeightError.Type)
|
|
17
|
-
.int(ImageHeightError.Type)
|
|
18
|
-
.min(IMAGE_DIMENSIONS_CONSTRAINTS.min, ImageHeightError.Length)
|
|
19
|
-
.max(IMAGE_DIMENSIONS_CONSTRAINTS.max, ImageHeightError.Length)
|
|
20
|
-
.brand("ImageHeight");
|
|
5
|
+
export const ImageWidth = v.pipe(v.number(ImageWidthError.Type), v.integer(ImageWidthError.Type), v.minValue(IMAGE_DIMENSIONS_CONSTRAINTS.min, ImageWidthError.Length), v.maxValue(IMAGE_DIMENSIONS_CONSTRAINTS.max, ImageWidthError.Length),
|
|
6
|
+
// Stryker disable next-line StringLiteral
|
|
7
|
+
v.brand("ImageWidth"));
|
|
8
|
+
export const ImageHeight = v.pipe(v.number(ImageHeightError.Type), v.integer(ImageHeightError.Type), v.minValue(IMAGE_DIMENSIONS_CONSTRAINTS.min, ImageHeightError.Length), v.maxValue(IMAGE_DIMENSIONS_CONSTRAINTS.max, ImageHeightError.Length),
|
|
9
|
+
// Stryker disable next-line StringLiteral
|
|
10
|
+
v.brand("ImageHeight"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const IntegerNonNegativeError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Invalid: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const IntegerNonNegative:
|
|
7
|
-
export type IntegerNonNegativeType =
|
|
6
|
+
export declare const IntegerNonNegative: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.BrandAction<number, "IntegerNonNegative">]>;
|
|
7
|
+
export type IntegerNonNegativeType = v.InferOutput<typeof IntegerNonNegative>;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const IntegerNonNegativeError = {
|
|
3
3
|
Type: "integer.non.negative.type",
|
|
4
4
|
Invalid: "integer.non.negative.invalid",
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.number(IntegerNonNegativeError.Type)
|
|
10
|
-
.int(IntegerNonNegativeError.Type)
|
|
11
|
-
.min(0, IntegerNonNegativeError.Invalid)
|
|
12
|
-
.brand("IntegerNonNegative");
|
|
6
|
+
export const IntegerNonNegative = v.pipe(v.number(IntegerNonNegativeError.Type), v.integer(IntegerNonNegativeError.Type), v.minValue(0, IntegerNonNegativeError.Invalid),
|
|
7
|
+
// Stryker disable next-line StringLiteral
|
|
8
|
+
v.brand("IntegerNonNegative"));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const IntegerPositiveError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Invalid: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const IntegerPositive:
|
|
7
|
-
export type IntegerPositiveType =
|
|
6
|
+
export declare const IntegerPositive: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 1, string>, v.BrandAction<number, "IntegerPositive">]>;
|
|
7
|
+
export type IntegerPositiveType = v.InferOutput<typeof IntegerPositive>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const IntegerPositiveError = { Type: "integer.positive.type", Invalid: "integer.positive.invalid" };
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.number(IntegerPositiveError.Type)
|
|
7
|
-
.int(IntegerPositiveError.Type)
|
|
8
|
-
.min(1, IntegerPositiveError.Invalid)
|
|
9
|
-
.brand("IntegerPositive");
|
|
3
|
+
export const IntegerPositive = v.pipe(v.number(IntegerPositiveError.Type), v.integer(IntegerPositiveError.Type), v.minValue(1, IntegerPositiveError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("IntegerPositive"));
|
package/dist/integer.vo.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const IntegerError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const Integer:
|
|
6
|
-
export type IntegerType =
|
|
5
|
+
export declare const Integer: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.BrandAction<number, "Integer">]>;
|
|
6
|
+
export type IntegerType = v.InferOutput<typeof Integer>;
|
package/dist/integer.vo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const IntegerError = { Type: "integer.type" };
|
|
3
|
-
// Stryker disable
|
|
4
|
-
export const Integer =
|
|
3
|
+
// Stryker disable next-line StringLiteral
|
|
4
|
+
export const Integer = v.pipe(v.number(IntegerError.Type), v.integer(IntegerError.Type), v.brand("Integer"));
|
package/dist/language.vo.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const LanguageError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
BadChars: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const Language:
|
|
7
|
-
export type LanguageType =
|
|
6
|
+
export declare const Language: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>]>;
|
|
7
|
+
export type LanguageType = v.InferOutput<typeof Language>;
|
package/dist/language.vo.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const LanguageError = { Type: "language.type", BadChars: "language.bad.chars" };
|
|
3
3
|
// Two lowercase letters
|
|
4
4
|
const LANGUAGE_CHARS_WHITELIST = /^[a-z]{2}$/;
|
|
5
|
-
export const Language =
|
|
5
|
+
export const Language = v.pipe(v.string(LanguageError.Type), v.regex(LANGUAGE_CHARS_WHITELIST, LanguageError.BadChars));
|
package/dist/mime-value.vo.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const MimeValueError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Invalid: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const MimeValue:
|
|
6
|
+
export declare const MimeValue: v.SchemaWithPipe<readonly [v.StringSchema<string>, v.RegexAction<string, string>, v.BrandAction<string, "MimeValue">]>;
|
|
7
|
+
export type MimeValueType = v.InferOutput<typeof MimeValue>;
|
package/dist/mime-value.vo.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const MimeValueError = { Type: "mime.value.type", Invalid: "mime.value.invalid" };
|
|
3
3
|
// One to twenty four lowercase letters, asterisk or hyphen, forward slash, one to seventy two lowercase letters, digits, asterisk, hyphen, plus, dot or underscore
|
|
4
4
|
const MIME_VALUE_CHARS_WHITELIST = /^[a-z*-]{1,24}\/[a-z0-9*+-_.]{1,72}$/;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.string(MimeValueError.Type)
|
|
9
|
-
.regex(MIME_VALUE_CHARS_WHITELIST, MimeValueError.Invalid)
|
|
10
|
-
.brand("MimeValue");
|
|
5
|
+
export const MimeValue = v.pipe(v.string(MimeValueError.Type), v.regex(MIME_VALUE_CHARS_WHITELIST, MimeValueError.Invalid),
|
|
6
|
+
// Stryker disable next-line StringLiteral
|
|
7
|
+
v.brand("MimeValue"));
|
package/dist/mime.vo.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { MimeValue } from "./mime-value.vo";
|
|
2
3
|
export class Mime {
|
|
3
4
|
type;
|
|
@@ -7,7 +8,7 @@ export class Mime {
|
|
|
7
8
|
this.subtype = subtype;
|
|
8
9
|
}
|
|
9
10
|
static fromString(candidate) {
|
|
10
|
-
const value =
|
|
11
|
+
const value = v.parse(MimeValue, candidate.split(";")[0].trim());
|
|
11
12
|
const [type, subtype] = value.split("/");
|
|
12
13
|
return new Mime(type, subtype);
|
|
13
14
|
}
|
package/dist/mimes.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { Extension } from "./extension.vo";
|
|
2
3
|
import { Mime } from "./mime.vo";
|
|
3
4
|
import { MimeRegistryEntry } from "./mime-registry-entry.vo";
|
|
4
5
|
export const Mimes = {
|
|
5
|
-
csv: new MimeRegistryEntry(Mime.fromString("text/csv"), [
|
|
6
|
+
csv: new MimeRegistryEntry(Mime.fromString("text/csv"), [v.parse(Extension, "csv")]),
|
|
6
7
|
jpg: new MimeRegistryEntry(Mime.fromString("image/jpeg"), [
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
v.parse(Extension, "jpg"),
|
|
9
|
+
v.parse(Extension, "jpeg"),
|
|
9
10
|
]),
|
|
10
|
-
markdown: new MimeRegistryEntry(Mime.fromString("text/markdown"), [
|
|
11
|
-
mp4: new MimeRegistryEntry(Mime.fromString("video/mp4"), [
|
|
12
|
-
pdf: new MimeRegistryEntry(Mime.fromString("application/pdf"), [
|
|
13
|
-
png: new MimeRegistryEntry(Mime.fromString("image/png"), [
|
|
14
|
-
text: new MimeRegistryEntry(Mime.fromString("text/plain"), [
|
|
15
|
-
webp: new MimeRegistryEntry(Mime.fromString("image/webp"), [
|
|
16
|
-
wav: new MimeRegistryEntry(Mime.fromString("audio/wav"), [
|
|
17
|
-
zip: new MimeRegistryEntry(Mime.fromString("application/zip"), [
|
|
11
|
+
markdown: new MimeRegistryEntry(Mime.fromString("text/markdown"), [v.parse(Extension, "md")]),
|
|
12
|
+
mp4: new MimeRegistryEntry(Mime.fromString("video/mp4"), [v.parse(Extension, "mp4")]),
|
|
13
|
+
pdf: new MimeRegistryEntry(Mime.fromString("application/pdf"), [v.parse(Extension, "pdf")]),
|
|
14
|
+
png: new MimeRegistryEntry(Mime.fromString("image/png"), [v.parse(Extension, "png")]),
|
|
15
|
+
text: new MimeRegistryEntry(Mime.fromString("text/plain"), [v.parse(Extension, "txt")]),
|
|
16
|
+
webp: new MimeRegistryEntry(Mime.fromString("image/webp"), [v.parse(Extension, "webp")]),
|
|
17
|
+
wav: new MimeRegistryEntry(Mime.fromString("audio/wav"), [v.parse(Extension, "wav")]),
|
|
18
|
+
zip: new MimeRegistryEntry(Mime.fromString("application/zip"), [v.parse(Extension, "zip")]),
|
|
18
19
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export declare const MinuteValueError: {
|
|
3
3
|
Type: string;
|
|
4
4
|
Invalid: string;
|
|
5
5
|
};
|
|
6
|
-
export declare const MinuteValue:
|
|
7
|
-
export type MinuteValueType =
|
|
6
|
+
export declare const MinuteValue: v.SchemaWithPipe<readonly [v.NumberSchema<string>, v.IntegerAction<number, string>, v.MinValueAction<number, 0, string>, v.MaxValueAction<number, 59, string>, v.BrandAction<number, "MinuteValue">]>;
|
|
7
|
+
export type MinuteValueType = v.InferOutput<typeof MinuteValue>;
|
package/dist/minute-value.vo.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as v from "valibot";
|
|
2
2
|
export const MinuteValueError = { Type: "minute.value.type", Invalid: "minute.value.invalid" };
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.number(MinuteValueError.Type)
|
|
7
|
-
.int(MinuteValueError.Type)
|
|
8
|
-
.gte(0, MinuteValueError.Invalid)
|
|
9
|
-
.lte(59, MinuteValueError.Invalid)
|
|
10
|
-
.brand("MinuteValue");
|
|
3
|
+
export const MinuteValue = v.pipe(v.number(MinuteValueError.Type), v.integer(MinuteValueError.Type), v.minValue(0, MinuteValueError.Invalid), v.maxValue(59, MinuteValueError.Invalid),
|
|
4
|
+
// Stryker disable next-line StringLiteral
|
|
5
|
+
v.brand("MinuteValue"));
|
package/dist/minute.vo.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
1
2
|
import { MinuteValue } from "./minute-value.vo";
|
|
2
3
|
import { Timestamp } from "./timestamp.vo";
|
|
3
4
|
export class Minute {
|
|
@@ -6,13 +7,13 @@ export class Minute {
|
|
|
6
7
|
this.value = value;
|
|
7
8
|
}
|
|
8
9
|
static fromValue(candidate) {
|
|
9
|
-
return new Minute(
|
|
10
|
+
return new Minute(v.parse(MinuteValue, candidate));
|
|
10
11
|
}
|
|
11
12
|
static fromValueSafe(candidate) {
|
|
12
13
|
return new Minute(candidate);
|
|
13
14
|
}
|
|
14
15
|
static fromTimestamp(timestamp) {
|
|
15
|
-
return new Minute(
|
|
16
|
+
return new Minute(v.parse(MinuteValue, new Date(timestamp.ms).getUTCMinutes()));
|
|
16
17
|
}
|
|
17
18
|
static fromTimestampValue(timestamp) {
|
|
18
19
|
return Minute.fromTimestamp(Timestamp.fromValue(timestamp));
|