@duplojs/utils 1.6.1 → 1.6.3
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/array/types/createTuple.d.ts +1 -1
- package/dist/clean/constraint/base.cjs +7 -0
- package/dist/clean/constraint/base.d.ts +26 -6
- package/dist/clean/constraint/base.mjs +7 -0
- package/dist/clean/constraint/cast.cjs +18 -0
- package/dist/clean/constraint/cast.d.ts +29 -0
- package/dist/clean/constraint/cast.mjs +16 -0
- package/dist/clean/constraint/defaultConstraint/number.cjs +2 -10
- package/dist/clean/constraint/defaultConstraint/number.d.ts +12 -37
- package/dist/clean/constraint/defaultConstraint/number.mjs +3 -10
- package/dist/clean/constraint/defaultConstraint/string.d.ts +9 -5
- package/dist/clean/constraint/index.d.ts +1 -0
- package/dist/clean/constraint/set.cjs +7 -1
- package/dist/clean/constraint/set.d.ts +25 -5
- package/dist/clean/constraint/set.mjs +7 -1
- package/dist/clean/entity/index.cjs +14 -4
- package/dist/clean/entity/index.d.ts +11 -1
- package/dist/clean/entity/index.mjs +15 -6
- package/dist/clean/index.cjs +5 -1
- package/dist/clean/index.d.ts +1 -0
- package/dist/clean/index.mjs +4 -2
- package/dist/clean/newType.cjs +6 -1
- package/dist/clean/newType.d.ts +20 -5
- package/dist/clean/newType.mjs +6 -1
- package/dist/clean/primitive/operations/equal.cjs +3 -0
- package/dist/clean/primitive/operations/equal.d.ts +2 -2
- package/dist/clean/primitive/operations/equal.mjs +3 -0
- package/dist/clean/toMapDataParser.cjs +52 -0
- package/dist/clean/toMapDataParser.d.ts +53 -0
- package/dist/clean/toMapDataParser.mjs +50 -0
- package/dist/common/asserts.cjs +12 -0
- package/dist/common/asserts.d.ts +26 -0
- package/dist/common/asserts.mjs +12 -1
- package/dist/common/callThen.cjs +14 -0
- package/dist/common/callThen.d.ts +35 -0
- package/dist/common/callThen.mjs +12 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/printer.cjs +73 -0
- package/dist/common/printer.d.ts +139 -0
- package/dist/common/printer.mjs +73 -0
- package/dist/common/queue.cjs +90 -0
- package/dist/common/queue.d.ts +46 -0
- package/dist/common/queue.mjs +87 -0
- package/dist/common/types/and.d.ts +1 -2
- package/dist/common/types/or.d.ts +1 -2
- package/dist/dataParser/base.cjs +12 -35
- package/dist/dataParser/base.d.ts +6 -9
- package/dist/dataParser/base.mjs +8 -30
- package/dist/dataParser/error.cjs +39 -21
- package/dist/dataParser/error.d.ts +19 -19
- package/dist/dataParser/error.mjs +37 -18
- package/dist/dataParser/extended/index.cjs +3 -4
- package/dist/dataParser/extended/index.mjs +1 -1
- package/dist/dataParser/identifier.d.ts +6 -6
- package/dist/dataParser/index.cjs +3 -6
- package/dist/dataParser/index.mjs +2 -2
- package/dist/dataParser/parsers/array/checkers/max.cjs +3 -6
- package/dist/dataParser/parsers/array/checkers/max.mjs +4 -7
- package/dist/dataParser/parsers/array/checkers/min.cjs +3 -6
- package/dist/dataParser/parsers/array/checkers/min.mjs +4 -7
- package/dist/dataParser/parsers/array/index.cjs +8 -8
- package/dist/dataParser/parsers/array/index.mjs +4 -4
- package/dist/dataParser/parsers/bigint/checkers/max.cjs +2 -2
- package/dist/dataParser/parsers/bigint/checkers/max.mjs +3 -3
- package/dist/dataParser/parsers/bigint/checkers/min.cjs +2 -2
- package/dist/dataParser/parsers/bigint/checkers/min.mjs +3 -3
- package/dist/dataParser/parsers/bigint/index.cjs +2 -2
- package/dist/dataParser/parsers/bigint/index.mjs +3 -3
- package/dist/dataParser/parsers/boolean.cjs +3 -3
- package/dist/dataParser/parsers/boolean.mjs +4 -4
- package/dist/dataParser/parsers/date.cjs +4 -4
- package/dist/dataParser/parsers/date.mjs +5 -5
- package/dist/dataParser/parsers/empty.cjs +2 -2
- package/dist/dataParser/parsers/empty.mjs +3 -3
- package/dist/dataParser/parsers/literal.cjs +2 -2
- package/dist/dataParser/parsers/literal.mjs +3 -3
- package/dist/dataParser/parsers/nil.cjs +2 -2
- package/dist/dataParser/parsers/nil.mjs +3 -3
- package/dist/dataParser/parsers/number/checkers/int.cjs +2 -2
- package/dist/dataParser/parsers/number/checkers/int.mjs +3 -3
- package/dist/dataParser/parsers/number/checkers/max.cjs +3 -1
- package/dist/dataParser/parsers/number/checkers/max.mjs +4 -2
- package/dist/dataParser/parsers/number/checkers/min.cjs +3 -1
- package/dist/dataParser/parsers/number/checkers/min.mjs +4 -2
- package/dist/dataParser/parsers/number/index.cjs +2 -2
- package/dist/dataParser/parsers/number/index.mjs +3 -3
- package/dist/dataParser/parsers/object/index.cjs +8 -8
- package/dist/dataParser/parsers/object/index.mjs +4 -4
- package/dist/dataParser/parsers/pipe.cjs +25 -10
- package/dist/dataParser/parsers/pipe.mjs +22 -7
- package/dist/dataParser/parsers/record/index.cjs +18 -16
- package/dist/dataParser/parsers/record/index.mjs +8 -6
- package/dist/dataParser/parsers/recover.cjs +7 -6
- package/dist/dataParser/parsers/recover.mjs +2 -1
- package/dist/dataParser/parsers/refine.cjs +3 -1
- package/dist/dataParser/parsers/refine.mjs +4 -2
- package/dist/dataParser/parsers/string/checkers/email.cjs +2 -2
- package/dist/dataParser/parsers/string/checkers/email.mjs +3 -3
- package/dist/dataParser/parsers/string/checkers/max.cjs +3 -1
- package/dist/dataParser/parsers/string/checkers/max.mjs +4 -2
- package/dist/dataParser/parsers/string/checkers/min.cjs +3 -1
- package/dist/dataParser/parsers/string/checkers/min.mjs +4 -2
- package/dist/dataParser/parsers/string/checkers/regex.cjs +2 -2
- package/dist/dataParser/parsers/string/checkers/regex.mjs +3 -3
- package/dist/dataParser/parsers/string/checkers/url.cjs +4 -4
- package/dist/dataParser/parsers/string/checkers/url.mjs +5 -5
- package/dist/dataParser/parsers/string/index.cjs +2 -2
- package/dist/dataParser/parsers/string/index.mjs +3 -3
- package/dist/dataParser/parsers/templateLiteral/index.cjs +2 -2
- package/dist/dataParser/parsers/templateLiteral/index.mjs +3 -3
- package/dist/dataParser/parsers/time/checkers/max.cjs +3 -1
- package/dist/dataParser/parsers/time/checkers/max.mjs +4 -2
- package/dist/dataParser/parsers/time/checkers/min.cjs +3 -1
- package/dist/dataParser/parsers/time/checkers/min.mjs +4 -2
- package/dist/dataParser/parsers/time/index.cjs +4 -4
- package/dist/dataParser/parsers/time/index.mjs +5 -5
- package/dist/dataParser/parsers/transform.cjs +6 -6
- package/dist/dataParser/parsers/transform.d.ts +2 -2
- package/dist/dataParser/parsers/transform.mjs +4 -4
- package/dist/dataParser/parsers/tuple.cjs +14 -14
- package/dist/dataParser/parsers/tuple.mjs +4 -4
- package/dist/dataParser/parsers/union.cjs +26 -8
- package/dist/dataParser/parsers/union.mjs +26 -8
- package/dist/flow/calledByNext.cjs +13 -0
- package/dist/flow/calledByNext.d.ts +47 -0
- package/dist/flow/calledByNext.mjs +11 -0
- package/dist/flow/debounce.cjs +16 -0
- package/dist/flow/debounce.d.ts +63 -0
- package/dist/flow/debounce.mjs +14 -0
- package/dist/flow/exec.cjs +101 -0
- package/dist/flow/exec.d.ts +4 -3
- package/dist/flow/exec.mjs +101 -0
- package/dist/flow/index.cjs +28 -0
- package/dist/flow/index.d.ts +5 -0
- package/dist/flow/index.mjs +10 -1
- package/dist/flow/queue.cjs +19 -0
- package/dist/flow/queue.d.ts +47 -0
- package/dist/flow/queue.mjs +17 -0
- package/dist/flow/run.cjs +118 -0
- package/dist/flow/run.d.ts +6 -4
- package/dist/flow/run.mjs +113 -1
- package/dist/flow/theFlow/calledByNext.cjs +11 -0
- package/dist/flow/theFlow/calledByNext.d.ts +5 -0
- package/dist/flow/theFlow/calledByNext.mjs +8 -0
- package/dist/flow/theFlow/debounce.cjs +11 -0
- package/dist/flow/theFlow/debounce.d.ts +9 -0
- package/dist/flow/theFlow/debounce.mjs +8 -0
- package/dist/flow/theFlow/index.d.ts +11 -3
- package/dist/flow/theFlow/queue.cjs +11 -0
- package/dist/flow/theFlow/queue.d.ts +9 -0
- package/dist/flow/theFlow/queue.mjs +8 -0
- package/dist/flow/theFlow/throttling.cjs +11 -0
- package/dist/flow/theFlow/throttling.d.ts +10 -0
- package/dist/flow/theFlow/throttling.mjs +8 -0
- package/dist/flow/throttling.cjs +27 -0
- package/dist/flow/throttling.d.ts +60 -0
- package/dist/flow/throttling.mjs +25 -0
- package/dist/flow/toFunction.cjs +15 -0
- package/dist/flow/toFunction.d.ts +56 -0
- package/dist/flow/toFunction.mjs +13 -0
- package/dist/index.cjs +11 -0
- package/dist/index.mjs +4 -1
- package/dist/metadata.json +126 -0
- package/dist/number/types/isGreater.d.ts +26 -3
- package/dist/object/types/getPropsWithValue.d.ts +1 -1
- package/dist/object/types/getPropsWithValueExtends.d.ts +1 -1
- package/dist/string/length.d.ts +2 -2
- package/dist/string/types/split.d.ts +6 -5
- package/package.json +1 -1
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { createDataParserKind } from './kind.mjs';
|
|
2
|
+
import { Printer } from '../common/printer.mjs';
|
|
3
|
+
import { unwrap } from '../common/unwrap.mjs';
|
|
2
4
|
|
|
3
|
-
const
|
|
5
|
+
const SymbolDataParserErrorLabel = "SymbolDataParserError";
|
|
6
|
+
const SymbolDataParserError = Symbol.for(SymbolDataParserErrorLabel);
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
*/
|
|
10
|
+
const SymbolDataParserErrorIssueLabel = "SymbolDataParserError";
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated
|
|
13
|
+
*/
|
|
4
14
|
const SymbolDataParserErrorIssue = Symbol.for(SymbolDataParserErrorIssueLabel);
|
|
5
15
|
const errorIssueKind = createDataParserKind("error-issue");
|
|
6
|
-
const SymbolDataParserErrorPromiseIssueLabel = "SymbolDataParserErrorPromiseIssue";
|
|
7
|
-
const SymbolDataParserErrorPromiseIssue = Symbol.for(SymbolDataParserErrorPromiseIssueLabel);
|
|
8
|
-
const errorPromiseIssueKind = createDataParserKind("error-issue-promise");
|
|
9
16
|
const errorKind = createDataParserKind("error");
|
|
10
17
|
function createError() {
|
|
11
18
|
return errorKind.setTo({
|
|
@@ -13,23 +20,14 @@ function createError() {
|
|
|
13
20
|
currentPath: [],
|
|
14
21
|
});
|
|
15
22
|
}
|
|
16
|
-
function addIssue(error,
|
|
23
|
+
function addIssue(error, expected, data, message) {
|
|
17
24
|
error.issues.push(errorIssueKind.setTo({
|
|
18
|
-
|
|
25
|
+
expected,
|
|
19
26
|
path: error.currentPath.join("."),
|
|
20
27
|
data,
|
|
21
|
-
|
|
28
|
+
message,
|
|
22
29
|
}));
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
function addPromiseIssue(error, source, data, moreInformation) {
|
|
26
|
-
error.issues.push(errorPromiseIssueKind.setTo({
|
|
27
|
-
source,
|
|
28
|
-
path: error.currentPath.join("."),
|
|
29
|
-
data,
|
|
30
|
-
moreInformation,
|
|
31
|
-
}));
|
|
32
|
-
return error;
|
|
30
|
+
return SymbolDataParserError;
|
|
33
31
|
}
|
|
34
32
|
function setErrorPath(error, value, index) {
|
|
35
33
|
error.currentPath[index] = value;
|
|
@@ -39,5 +37,26 @@ function popErrorPath(error) {
|
|
|
39
37
|
error.currentPath.pop();
|
|
40
38
|
return error;
|
|
41
39
|
}
|
|
40
|
+
function interpretError(error) {
|
|
41
|
+
const dataParserError = errorKind.has(error)
|
|
42
|
+
? error
|
|
43
|
+
: unwrap(error);
|
|
44
|
+
return Printer.renderParagraph([
|
|
45
|
+
Printer.colorizedBold("Validation failed", "red"),
|
|
46
|
+
dataParserError.issues.map((issue) => Printer.renderParagraph([
|
|
47
|
+
"",
|
|
48
|
+
Printer.renderLine([
|
|
49
|
+
Printer.colorizedBold("✖", "red"),
|
|
50
|
+
Printer.colorizedBold(issue.path || "<root>", "cyan"),
|
|
51
|
+
"expected",
|
|
52
|
+
Printer.colorized(issue.expected, "green"),
|
|
53
|
+
"but received",
|
|
54
|
+
Printer.colorized(Printer.stringify(issue.data), "red"),
|
|
55
|
+
]),
|
|
56
|
+
issue.message !== undefined && `${Printer.indent(1)}↳ ${issue.message}`,
|
|
57
|
+
])),
|
|
58
|
+
dataParserError.issues.length === 0 && "No issue found",
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
42
61
|
|
|
43
|
-
export { SymbolDataParserErrorIssue, SymbolDataParserErrorIssueLabel,
|
|
62
|
+
export { SymbolDataParserError, SymbolDataParserErrorIssue, SymbolDataParserErrorIssueLabel, SymbolDataParserErrorLabel, addIssue, createError, errorIssueKind, errorKind, interpretError, popErrorPath, setErrorPath };
|
|
@@ -53,15 +53,14 @@ exports.templateLiteral = templateLiteral.templateLiteral;
|
|
|
53
53
|
exports.tuple = tuple.tuple;
|
|
54
54
|
exports.unknown = unknown.unknown;
|
|
55
55
|
exports.recover = recover.recover;
|
|
56
|
+
exports.SymbolDataParserError = error.SymbolDataParserError;
|
|
56
57
|
exports.SymbolDataParserErrorIssue = error.SymbolDataParserErrorIssue;
|
|
57
58
|
exports.SymbolDataParserErrorIssueLabel = error.SymbolDataParserErrorIssueLabel;
|
|
58
|
-
exports.
|
|
59
|
-
exports.SymbolDataParserErrorPromiseIssueLabel = error.SymbolDataParserErrorPromiseIssueLabel;
|
|
59
|
+
exports.SymbolDataParserErrorLabel = error.SymbolDataParserErrorLabel;
|
|
60
60
|
exports.addIssue = error.addIssue;
|
|
61
|
-
exports.addPromiseIssue = error.addPromiseIssue;
|
|
62
61
|
exports.createError = error.createError;
|
|
63
62
|
exports.errorIssueKind = error.errorIssueKind;
|
|
64
63
|
exports.errorKind = error.errorKind;
|
|
65
|
-
exports.
|
|
64
|
+
exports.interpretError = error.interpretError;
|
|
66
65
|
exports.popErrorPath = error.popErrorPath;
|
|
67
66
|
exports.setErrorPath = error.setErrorPath;
|
|
@@ -22,4 +22,4 @@ export { templateLiteral } from './templateLiteral.mjs';
|
|
|
22
22
|
export { tuple } from './tuple.mjs';
|
|
23
23
|
export { unknown } from './unknown.mjs';
|
|
24
24
|
export { recover } from './recover.mjs';
|
|
25
|
-
export { SymbolDataParserErrorIssue, SymbolDataParserErrorIssueLabel,
|
|
25
|
+
export { SymbolDataParserError, SymbolDataParserErrorIssue, SymbolDataParserErrorIssueLabel, SymbolDataParserErrorLabel, addIssue, createError, errorIssueKind, errorKind, interpretError, popErrorPath, setErrorPath } from '../error.mjs';
|
|
@@ -8,13 +8,13 @@ import { type DataParser } from "./base";
|
|
|
8
8
|
* parsers, the correct type can be retrieved.
|
|
9
9
|
*/
|
|
10
10
|
export declare const identifier: {
|
|
11
|
-
<GenericKindHandler extends import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/bigint", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/
|
|
11
|
+
<GenericKindHandler extends import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/bigint", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/boolean", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/date", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/time", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/empty", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nil", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/number", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/string", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
12
12
|
input: string;
|
|
13
13
|
output: string;
|
|
14
|
-
}>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
14
|
+
}>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/object", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/optional", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
15
15
|
input: unknown;
|
|
16
16
|
output: unknown;
|
|
17
|
-
}>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
17
|
+
}>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/union", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/array", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/tuple", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/transform", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/template-literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/pipe", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nullable", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/lazy", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/unknown", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/record", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/recover", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/extended", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
18
18
|
input: {
|
|
19
19
|
[x: string]: unknown;
|
|
20
20
|
[x: number]: unknown;
|
|
@@ -57,13 +57,13 @@ export declare const identifier: {
|
|
|
57
57
|
input: Record<never, unknown>;
|
|
58
58
|
output: Record<never, unknown>;
|
|
59
59
|
}>>, GenericInput extends unknown, GenericGroupedKind extends import("../common").UnionToIntersection<GenericKindHandler extends import("../common").KindHandler<import("../common").KindDefinition<string, unknown>> ? import("../common").Kind<GenericKindHandler["definition"], GenericKindHandler["definition"]["value"]> : never>>(kind: GenericKindHandler | GenericKindHandler[]): (input: GenericInput) => input is (import("../common").IsEqual<import("../common").IsEqual<false | (GenericInput extends any ? import("../common").IsEqual<GenericInput, DataParser<import("./base").DataParserDefinition<import("./base").DataParserChecker<import("./base").DataParserCheckerDefinition, unknown>>, unknown, unknown>> : never), boolean>, true> extends true ? Extract<DataParser<import("./base").DataParserDefinition<import("./base").DataParserChecker<import("./base").DataParserCheckerDefinition, unknown>>, unknown, unknown>, GenericGroupedKind> | Extract<import("./parsers").DataParserString<import("./parsers").DataParserDefinitionString>, GenericGroupedKind> | Extract<import("./parsers").DataParserObject<import("./parsers").DataParserDefinitionObject>, GenericGroupedKind> | Extract<import("./parsers").DataParserNumber<import("./parsers").DataParserDefinitionNumber>, GenericGroupedKind> | Extract<import("./parsers").DataParserLiteral<import("./parsers").DataParserDefinitionLiteral>, GenericGroupedKind> | Extract<import("./parsers").DataParserUnion<import("./parsers").DataParserDefinitionUnion>, GenericGroupedKind> | Extract<import("./parsers").DataParserArray<import("./parsers").DataParserDefinitionArray>, GenericGroupedKind> | Extract<import("./parsers").DataParserBigInt<import("./parsers").DataParserDefinitionBigInt>, GenericGroupedKind> | Extract<import("./parsers").DataParserTuple<import("./parsers").DataParserDefinitionTuple>, GenericGroupedKind> | Extract<import("./parsers").DataParserTransform<import("./parsers").DataParserDefinitionTransform>, GenericGroupedKind> | Extract<import("./parsers").DataParserBoolean<import("./parsers").DataParserDefinitionBoolean>, GenericGroupedKind> | Extract<import("./parsers").DataParserDate<import("./parsers").DataParserDefinitionDate>, GenericGroupedKind> | Extract<import("./parsers").DataParserTime<import("./parsers").DataParserDefinitionTime>, GenericGroupedKind> | Extract<import("./parsers").DataParserNil<import("./parsers").DataParserDefinitionNil>, GenericGroupedKind> | Extract<import("./parsers").DataParserEmpty<import("./parsers").DataParserDefinitionEmpty>, GenericGroupedKind> | Extract<import("./parsers").DataParserTemplateLiteral<import("./parsers").DataParserDefinitionTemplateLiteral>, GenericGroupedKind> | Extract<import("./parsers").DataParserPipe<import("./parsers").DataParserDefinitionPipe>, GenericGroupedKind> | Extract<import("./parsers").DataParserNullable<import("./parsers").DataParserDefinitionNullable<unknown>>, GenericGroupedKind> | Extract<import("./parsers").DataParserOptional<import("./parsers").DataParserDefinitionOptional<unknown>>, GenericGroupedKind> | Extract<import("./parsers").DataParserLazy<import("./parsers").DataParserDefinitionLazy>, GenericGroupedKind> | Extract<import("./parsers").DataParserUnknown<import("./parsers").DataParserDefinitionUnknown>, GenericGroupedKind> | Extract<import("./parsers").DataParserRecord<import("./parsers").DataParserDefinitionRecord>, GenericGroupedKind> | Extract<import("./parsers").DataParserRecover<import("./parsers").DataParserDefinitionRecover>, GenericGroupedKind> | Extract<import("./baseExtended").DataParserExtended<import("./base").DataParserDefinition<import("./base").DataParserChecker<import("./base").DataParserCheckerDefinition, unknown>>, unknown, unknown>, GenericGroupedKind> | Extract<import("./extended").DataParserStringExtended<import("./parsers").DataParserDefinitionString>, GenericGroupedKind> | Extract<import("./extended").DataParserObjectExtended<import("./parsers").DataParserDefinitionObject>, GenericGroupedKind> | Extract<import("./extended").DataParserNumberExtended<import("./parsers").DataParserDefinitionNumber>, GenericGroupedKind> | Extract<import("./extended").DataParserLiteralExtended<import("./parsers").DataParserDefinitionLiteral>, GenericGroupedKind> | Extract<import("./extended").DataParserUnionExtended<import("./parsers").DataParserDefinitionUnion>, GenericGroupedKind> | Extract<import("./extended").DataParserArrayExtended<import("./parsers").DataParserDefinitionArray>, GenericGroupedKind> | Extract<import("./extended").DataParserBigIntExtended<import("./parsers").DataParserDefinitionBigInt>, GenericGroupedKind> | Extract<import("./extended").DataParserTupleExtended<import("./parsers").DataParserDefinitionTuple>, GenericGroupedKind> | Extract<import("./extended").DataParserTransformExtended<import("./parsers").DataParserDefinitionTransform>, GenericGroupedKind> | Extract<import("./extended").DataParserBooleanExtended<import("./parsers").DataParserDefinitionBoolean>, GenericGroupedKind> | Extract<import("./extended").DataParserDateExtended<import("./parsers").DataParserDefinitionDate>, GenericGroupedKind> | Extract<import("./extended").DataParserTimeExtended<import("./parsers").DataParserDefinitionTime>, GenericGroupedKind> | Extract<import("./extended").DataParserNilExtended<import("./parsers").DataParserDefinitionNil>, GenericGroupedKind> | Extract<import("./extended").DataParserEmptyExtended<import("./parsers").DataParserDefinitionEmpty>, GenericGroupedKind> | Extract<import("./extended").DataParserTemplateLiteralExtended<import("./parsers").DataParserDefinitionTemplateLiteral>, GenericGroupedKind> | Extract<import("./extended").DataParserPipeExtended<import("./parsers").DataParserDefinitionPipe>, GenericGroupedKind> | Extract<import("./extended").DataParserNullableExtended<import("./parsers").DataParserDefinitionNullable<unknown>>, GenericGroupedKind> | Extract<import("./extended").DataParserOptionalExtended<import("./parsers").DataParserDefinitionOptional<unknown>>, GenericGroupedKind> | Extract<import("./extended").DataParserLazyExtended<import("./parsers").DataParserDefinitionLazy>, GenericGroupedKind> | Extract<import("./extended").DataParserUnknownExtended<import("./parsers").DataParserDefinitionUnknown>, GenericGroupedKind> | Extract<import("./extended").DataParserRecordExtended<import("./parsers").DataParserDefinitionRecord>, GenericGroupedKind> | Extract<import("./extended").DataParserRecoverExtended<import("./parsers").DataParserDefinitionRecover>, GenericGroupedKind> : never) | Extract<GenericInput, GenericGroupedKind>;
|
|
60
|
-
<GenericKindHandler extends import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/bigint", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/
|
|
60
|
+
<GenericKindHandler extends import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/bigint", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/boolean", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/date", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/time", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/empty", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nil", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/number", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/string", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
61
61
|
input: string;
|
|
62
62
|
output: string;
|
|
63
|
-
}>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
63
|
+
}>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/object", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/optional", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
64
64
|
input: unknown;
|
|
65
65
|
output: unknown;
|
|
66
|
-
}>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
66
|
+
}>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/union", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/array", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/tuple", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/transform", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/template-literal", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/pipe", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/nullable", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/lazy", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/unknown", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/record", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/recover", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/extended", unknown>> | import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
67
67
|
input: {
|
|
68
68
|
[x: string]: unknown;
|
|
69
69
|
[x: number]: unknown;
|
|
@@ -54,24 +54,21 @@ var recover = require('./parsers/recover.cjs');
|
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
exports.DataParserThrowError = base.DataParserThrowError;
|
|
57
|
-
exports.SymbolDataParserError = base.SymbolDataParserError;
|
|
58
|
-
exports.SymbolDataParserErrorLabel = base.SymbolDataParserErrorLabel;
|
|
59
57
|
exports.checkerKind = base.checkerKind;
|
|
60
58
|
exports.dataParserCheckerInit = base.dataParserCheckerInit;
|
|
61
59
|
exports.dataParserInit = base.dataParserInit;
|
|
62
60
|
exports.dataParserKind = base.dataParserKind;
|
|
63
61
|
exports.dataParserExtendedInit = baseExtended.dataParserExtendedInit;
|
|
64
62
|
exports.extendedKind = baseExtended.extendedKind;
|
|
63
|
+
exports.SymbolDataParserError = error.SymbolDataParserError;
|
|
65
64
|
exports.SymbolDataParserErrorIssue = error.SymbolDataParserErrorIssue;
|
|
66
65
|
exports.SymbolDataParserErrorIssueLabel = error.SymbolDataParserErrorIssueLabel;
|
|
67
|
-
exports.
|
|
68
|
-
exports.SymbolDataParserErrorPromiseIssueLabel = error.SymbolDataParserErrorPromiseIssueLabel;
|
|
66
|
+
exports.SymbolDataParserErrorLabel = error.SymbolDataParserErrorLabel;
|
|
69
67
|
exports.addIssue = error.addIssue;
|
|
70
|
-
exports.addPromiseIssue = error.addPromiseIssue;
|
|
71
68
|
exports.createError = error.createError;
|
|
72
69
|
exports.errorIssueKind = error.errorIssueKind;
|
|
73
70
|
exports.errorKind = error.errorKind;
|
|
74
|
-
exports.
|
|
71
|
+
exports.interpretError = error.interpretError;
|
|
75
72
|
exports.popErrorPath = error.popErrorPath;
|
|
76
73
|
exports.setErrorPath = error.setErrorPath;
|
|
77
74
|
exports.extended = index;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { DataParserThrowError,
|
|
1
|
+
export { DataParserThrowError, checkerKind, dataParserCheckerInit, dataParserInit, dataParserKind } from './base.mjs';
|
|
2
2
|
export { dataParserExtendedInit, extendedKind } from './baseExtended.mjs';
|
|
3
|
-
export { SymbolDataParserErrorIssue, SymbolDataParserErrorIssueLabel,
|
|
3
|
+
export { SymbolDataParserError, SymbolDataParserErrorIssue, SymbolDataParserErrorIssueLabel, SymbolDataParserErrorLabel, addIssue, createError, errorIssueKind, errorKind, interpretError, popErrorPath, setErrorPath } from './error.mjs';
|
|
4
4
|
import * as index from './extended/index.mjs';
|
|
5
5
|
export { index as extended };
|
|
6
6
|
export { identifier } from './identifier.mjs';
|
|
@@ -11,12 +11,9 @@ function checkerArrayMax(max, definition = {}) {
|
|
|
11
11
|
...definition,
|
|
12
12
|
max,
|
|
13
13
|
},
|
|
14
|
-
}, (data, self) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return data;
|
|
19
|
-
});
|
|
14
|
+
}, (data, error$1, self) => data.length <= self.definition.max
|
|
15
|
+
? data
|
|
16
|
+
: error.addIssue(error$1, `array.length <= ${self.definition.max}`, data, self.definition.errorMessage));
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
exports.checkerArrayMax = checkerArrayMax;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dataParserCheckerInit } from '../../../base.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { addIssue } from '../../../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../../../kind.mjs';
|
|
4
4
|
|
|
5
5
|
const checkerArrayMaxKind = createDataParserKind("checker-array-max");
|
|
@@ -9,12 +9,9 @@ function checkerArrayMax(max, definition = {}) {
|
|
|
9
9
|
...definition,
|
|
10
10
|
max,
|
|
11
11
|
},
|
|
12
|
-
}, (data, self) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return data;
|
|
17
|
-
});
|
|
12
|
+
}, (data, error, self) => data.length <= self.definition.max
|
|
13
|
+
? data
|
|
14
|
+
: addIssue(error, `array.length <= ${self.definition.max}`, data, self.definition.errorMessage));
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
export { checkerArrayMax, checkerArrayMaxKind };
|
|
@@ -11,12 +11,9 @@ function checkerArrayMin(min, definition = {}) {
|
|
|
11
11
|
...definition,
|
|
12
12
|
min,
|
|
13
13
|
},
|
|
14
|
-
}, (data, self) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return data;
|
|
19
|
-
});
|
|
14
|
+
}, (data, error$1, self) => data.length >= self.definition.min
|
|
15
|
+
? data
|
|
16
|
+
: error.addIssue(error$1, `array.length >= ${self.definition.min}`, data, self.definition.errorMessage));
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
exports.checkerArrayMin = checkerArrayMin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dataParserCheckerInit } from '../../../base.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { addIssue } from '../../../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../../../kind.mjs';
|
|
4
4
|
|
|
5
5
|
const checkerArrayMinKind = createDataParserKind("checker-array-min");
|
|
@@ -9,12 +9,9 @@ function checkerArrayMin(min, definition = {}) {
|
|
|
9
9
|
...definition,
|
|
10
10
|
min,
|
|
11
11
|
},
|
|
12
|
-
}, (data, self) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return data;
|
|
17
|
-
});
|
|
12
|
+
}, (data, error, self) => data.length >= self.definition.min
|
|
13
|
+
? data
|
|
14
|
+
: addIssue(error, `array.length >= ${self.definition.min}`, data, self.definition.errorMessage));
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
export { checkerArrayMin, checkerArrayMinKind };
|
|
@@ -17,7 +17,7 @@ function array(element, definition) {
|
|
|
17
17
|
}, {
|
|
18
18
|
sync: (data, error$1, self) => {
|
|
19
19
|
if (!(data instanceof Array)) {
|
|
20
|
-
return error.
|
|
20
|
+
return error.addIssue(error$1, "array", data, self.definition.errorMessage);
|
|
21
21
|
}
|
|
22
22
|
let output = [];
|
|
23
23
|
const currentIndexPath = error$1.currentPath.length;
|
|
@@ -27,10 +27,10 @@ function array(element, definition) {
|
|
|
27
27
|
.definition
|
|
28
28
|
.element
|
|
29
29
|
.exec(data[index], error$1);
|
|
30
|
-
if (result ===
|
|
31
|
-
output =
|
|
30
|
+
if (result === error.SymbolDataParserError) {
|
|
31
|
+
output = error.SymbolDataParserError;
|
|
32
32
|
}
|
|
33
|
-
else if (output !==
|
|
33
|
+
else if (output !== error.SymbolDataParserError) {
|
|
34
34
|
output.push(result);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -39,7 +39,7 @@ function array(element, definition) {
|
|
|
39
39
|
},
|
|
40
40
|
async: async (data, error$1, self) => {
|
|
41
41
|
if (!(data instanceof Array)) {
|
|
42
|
-
return error.
|
|
42
|
+
return error.addIssue(error$1, "array", data, self.definition.errorMessage);
|
|
43
43
|
}
|
|
44
44
|
let output = [];
|
|
45
45
|
const currentIndexPath = error$1.currentPath.length;
|
|
@@ -49,10 +49,10 @@ function array(element, definition) {
|
|
|
49
49
|
.definition
|
|
50
50
|
.element
|
|
51
51
|
.asyncExec(data[index], error$1);
|
|
52
|
-
if (result ===
|
|
53
|
-
output =
|
|
52
|
+
if (result === error.SymbolDataParserError) {
|
|
53
|
+
output = error.SymbolDataParserError;
|
|
54
54
|
}
|
|
55
|
-
else if (output !==
|
|
55
|
+
else if (output !== error.SymbolDataParserError) {
|
|
56
56
|
output.push(result);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { dataParserInit
|
|
2
|
-
import {
|
|
1
|
+
import { dataParserInit } from '../../base.mjs';
|
|
2
|
+
import { addIssue, setErrorPath, SymbolDataParserError, popErrorPath } from '../../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../../kind.mjs';
|
|
4
4
|
import { createOverride } from '../../../common/override.mjs';
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@ function array(element, definition) {
|
|
|
15
15
|
}, {
|
|
16
16
|
sync: (data, error, self) => {
|
|
17
17
|
if (!(data instanceof Array)) {
|
|
18
|
-
return
|
|
18
|
+
return addIssue(error, "array", data, self.definition.errorMessage);
|
|
19
19
|
}
|
|
20
20
|
let output = [];
|
|
21
21
|
const currentIndexPath = error.currentPath.length;
|
|
@@ -37,7 +37,7 @@ function array(element, definition) {
|
|
|
37
37
|
},
|
|
38
38
|
async: async (data, error, self) => {
|
|
39
39
|
if (!(data instanceof Array)) {
|
|
40
|
-
return
|
|
40
|
+
return addIssue(error, "array", data, self.definition.errorMessage);
|
|
41
41
|
}
|
|
42
42
|
let output = [];
|
|
43
43
|
const currentIndexPath = error.currentPath.length;
|
|
@@ -11,9 +11,9 @@ function checkerBigIntMax(max, definition = {}) {
|
|
|
11
11
|
...definition,
|
|
12
12
|
max,
|
|
13
13
|
},
|
|
14
|
-
}, (value, self) => {
|
|
14
|
+
}, (value, error$1, self) => {
|
|
15
15
|
if (value > self.definition.max) {
|
|
16
|
-
return error.
|
|
16
|
+
return error.addIssue(error$1, `bigint <= ${self.definition.max}n`, value, self.definition.errorMessage);
|
|
17
17
|
}
|
|
18
18
|
return value;
|
|
19
19
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dataParserCheckerInit } from '../../../base.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { addIssue } from '../../../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../../../kind.mjs';
|
|
4
4
|
|
|
5
5
|
const checkerBigIntMaxKind = createDataParserKind("checker-bigint-max");
|
|
@@ -9,9 +9,9 @@ function checkerBigIntMax(max, definition = {}) {
|
|
|
9
9
|
...definition,
|
|
10
10
|
max,
|
|
11
11
|
},
|
|
12
|
-
}, (value, self) => {
|
|
12
|
+
}, (value, error, self) => {
|
|
13
13
|
if (value > self.definition.max) {
|
|
14
|
-
return
|
|
14
|
+
return addIssue(error, `bigint <= ${self.definition.max}n`, value, self.definition.errorMessage);
|
|
15
15
|
}
|
|
16
16
|
return value;
|
|
17
17
|
});
|
|
@@ -11,9 +11,9 @@ function checkerBigIntMin(min, definition = {}) {
|
|
|
11
11
|
...definition,
|
|
12
12
|
min,
|
|
13
13
|
},
|
|
14
|
-
}, (value, self) => {
|
|
14
|
+
}, (value, error$1, self) => {
|
|
15
15
|
if (value < self.definition.min) {
|
|
16
|
-
return error.
|
|
16
|
+
return error.addIssue(error$1, `bigint >= ${self.definition.min}n`, value, self.definition.errorMessage);
|
|
17
17
|
}
|
|
18
18
|
return value;
|
|
19
19
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dataParserCheckerInit } from '../../../base.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { addIssue } from '../../../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../../../kind.mjs';
|
|
4
4
|
|
|
5
5
|
const checkerBigIntMinKind = createDataParserKind("checker-bigint-min");
|
|
@@ -9,9 +9,9 @@ function checkerBigIntMin(min, definition = {}) {
|
|
|
9
9
|
...definition,
|
|
10
10
|
min,
|
|
11
11
|
},
|
|
12
|
-
}, (value, self) => {
|
|
12
|
+
}, (value, error, self) => {
|
|
13
13
|
if (value < self.definition.min) {
|
|
14
|
-
return
|
|
14
|
+
return addIssue(error, `bigint >= ${self.definition.min}n`, value, self.definition.errorMessage);
|
|
15
15
|
}
|
|
16
16
|
return value;
|
|
17
17
|
});
|
|
@@ -14,7 +14,7 @@ function bigint(definition) {
|
|
|
14
14
|
errorMessage: definition?.errorMessage,
|
|
15
15
|
checkers: definition?.checkers ?? [],
|
|
16
16
|
coerce: definition?.coerce ?? false,
|
|
17
|
-
}, (data,
|
|
17
|
+
}, (data, error$1, self) => {
|
|
18
18
|
if (self.definition.coerce) {
|
|
19
19
|
try {
|
|
20
20
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -25,7 +25,7 @@ function bigint(definition) {
|
|
|
25
25
|
if (typeof data === "bigint") {
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
-
return error.
|
|
28
|
+
return error.addIssue(error$1, "bigint", data, self.definition.errorMessage);
|
|
29
29
|
}, bigint.overrideHandler);
|
|
30
30
|
return self;
|
|
31
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dataParserInit } from '../../base.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { addIssue } from '../../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../../kind.mjs';
|
|
4
4
|
import { createOverride } from '../../../common/override.mjs';
|
|
5
5
|
|
|
@@ -12,7 +12,7 @@ function bigint(definition) {
|
|
|
12
12
|
errorMessage: definition?.errorMessage,
|
|
13
13
|
checkers: definition?.checkers ?? [],
|
|
14
14
|
coerce: definition?.coerce ?? false,
|
|
15
|
-
}, (data,
|
|
15
|
+
}, (data, error, self) => {
|
|
16
16
|
if (self.definition.coerce) {
|
|
17
17
|
try {
|
|
18
18
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -23,7 +23,7 @@ function bigint(definition) {
|
|
|
23
23
|
if (typeof data === "bigint") {
|
|
24
24
|
return data;
|
|
25
25
|
}
|
|
26
|
-
return
|
|
26
|
+
return addIssue(error, "bigint", data, self.definition.errorMessage);
|
|
27
27
|
}, bigint.overrideHandler);
|
|
28
28
|
return self;
|
|
29
29
|
}
|
|
@@ -14,7 +14,7 @@ function boolean(definition) {
|
|
|
14
14
|
errorMessage: definition?.errorMessage,
|
|
15
15
|
checkers: definition?.checkers ?? [],
|
|
16
16
|
coerce: definition?.coerce ?? false,
|
|
17
|
-
}, (data,
|
|
17
|
+
}, (data, error$1, self) => {
|
|
18
18
|
if (typeof data === "boolean") {
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
@@ -25,7 +25,7 @@ function boolean(definition) {
|
|
|
25
25
|
return lower === "true";
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
|
-
return error.
|
|
28
|
+
return error.addIssue(error$1, "boolean", data, self.definition.errorMessage);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
else if (typeof data === "number"
|
|
@@ -34,7 +34,7 @@ function boolean(definition) {
|
|
|
34
34
|
return data === 1;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
return error.
|
|
37
|
+
return error.addIssue(error$1, "boolean", data, self.definition.errorMessage);
|
|
38
38
|
}, boolean.overrideHandler);
|
|
39
39
|
return self;
|
|
40
40
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dataParserInit } from '../base.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { addIssue } from '../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../kind.mjs';
|
|
4
4
|
import { createOverride } from '../../common/override.mjs';
|
|
5
5
|
|
|
@@ -12,7 +12,7 @@ function boolean(definition) {
|
|
|
12
12
|
errorMessage: definition?.errorMessage,
|
|
13
13
|
checkers: definition?.checkers ?? [],
|
|
14
14
|
coerce: definition?.coerce ?? false,
|
|
15
|
-
}, (data,
|
|
15
|
+
}, (data, error, self) => {
|
|
16
16
|
if (typeof data === "boolean") {
|
|
17
17
|
return data;
|
|
18
18
|
}
|
|
@@ -23,7 +23,7 @@ function boolean(definition) {
|
|
|
23
23
|
return lower === "true";
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
|
-
return
|
|
26
|
+
return addIssue(error, "boolean", data, self.definition.errorMessage);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
else if (typeof data === "number"
|
|
@@ -32,7 +32,7 @@ function boolean(definition) {
|
|
|
32
32
|
return data === 1;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
return
|
|
35
|
+
return addIssue(error, "boolean", data, self.definition.errorMessage);
|
|
36
36
|
}, boolean.overrideHandler);
|
|
37
37
|
return self;
|
|
38
38
|
}
|
|
@@ -18,11 +18,11 @@ function date(definition) {
|
|
|
18
18
|
errorMessage: definition?.errorMessage,
|
|
19
19
|
checkers: definition?.checkers ?? [],
|
|
20
20
|
coerce: definition?.coerce ?? false,
|
|
21
|
-
}, (data,
|
|
21
|
+
}, (data, error$1, self) => {
|
|
22
22
|
if (self.definition.coerce) {
|
|
23
23
|
if (typeof data === "number") {
|
|
24
24
|
if (!isSafeTimestamp.isSafeTimestamp(data)) {
|
|
25
|
-
return error.
|
|
25
|
+
return error.addIssue(error$1, "date", data, self.definition.errorMessage);
|
|
26
26
|
}
|
|
27
27
|
return theDate.TheDate.new(data);
|
|
28
28
|
}
|
|
@@ -43,11 +43,11 @@ function date(definition) {
|
|
|
43
43
|
else if (data instanceof Date) {
|
|
44
44
|
const timestamp = data.getTime();
|
|
45
45
|
if (!isSafeTimestamp.isSafeTimestamp(timestamp)) {
|
|
46
|
-
return error.
|
|
46
|
+
return error.addIssue(error$1, "date", data, self.definition.errorMessage);
|
|
47
47
|
}
|
|
48
48
|
return theDate.TheDate.new(timestamp);
|
|
49
49
|
}
|
|
50
|
-
return error.
|
|
50
|
+
return error.addIssue(error$1, "date", data, self.definition.errorMessage);
|
|
51
51
|
}, date.overrideHandler);
|
|
52
52
|
return self;
|
|
53
53
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dataParserInit } from '../base.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { addIssue } from '../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../kind.mjs';
|
|
4
4
|
import { isSafeTimestamp } from '../../date/isSafeTimestamp.mjs';
|
|
5
5
|
import { TheDate } from '../../date/theDate.mjs';
|
|
@@ -16,11 +16,11 @@ function date(definition) {
|
|
|
16
16
|
errorMessage: definition?.errorMessage,
|
|
17
17
|
checkers: definition?.checkers ?? [],
|
|
18
18
|
coerce: definition?.coerce ?? false,
|
|
19
|
-
}, (data,
|
|
19
|
+
}, (data, error, self) => {
|
|
20
20
|
if (self.definition.coerce) {
|
|
21
21
|
if (typeof data === "number") {
|
|
22
22
|
if (!isSafeTimestamp(data)) {
|
|
23
|
-
return
|
|
23
|
+
return addIssue(error, "date", data, self.definition.errorMessage);
|
|
24
24
|
}
|
|
25
25
|
return TheDate.new(data);
|
|
26
26
|
}
|
|
@@ -41,11 +41,11 @@ function date(definition) {
|
|
|
41
41
|
else if (data instanceof Date) {
|
|
42
42
|
const timestamp = data.getTime();
|
|
43
43
|
if (!isSafeTimestamp(timestamp)) {
|
|
44
|
-
return
|
|
44
|
+
return addIssue(error, "date", data, self.definition.errorMessage);
|
|
45
45
|
}
|
|
46
46
|
return TheDate.new(timestamp);
|
|
47
47
|
}
|
|
48
|
-
return
|
|
48
|
+
return addIssue(error, "date", data, self.definition.errorMessage);
|
|
49
49
|
}, date.overrideHandler);
|
|
50
50
|
return self;
|
|
51
51
|
}
|
|
@@ -14,14 +14,14 @@ function empty(definition) {
|
|
|
14
14
|
errorMessage: definition?.errorMessage,
|
|
15
15
|
checkers: definition?.checkers ?? [],
|
|
16
16
|
coerce: definition?.coerce ?? false,
|
|
17
|
-
}, (data,
|
|
17
|
+
}, (data, error$1, self) => {
|
|
18
18
|
if (data === undefined) {
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
21
|
else if (self.definition.coerce && data === "undefined") {
|
|
22
22
|
return undefined;
|
|
23
23
|
}
|
|
24
|
-
return error.
|
|
24
|
+
return error.addIssue(error$1, "undefined", data, self.definition.errorMessage);
|
|
25
25
|
}, empty.overrideHandler);
|
|
26
26
|
return self;
|
|
27
27
|
}
|