@duplojs/lang 0.0.1-beta.10 → 0.0.1-beta.11
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/dataStructure/common/error/defaultInterpreter.cjs +56 -53
- package/dist/dataStructure/common/error/defaultInterpreter.d.ts +56 -53
- package/dist/dataStructure/common/error/defaultInterpreter.mjs +56 -53
- package/dist/dataStructure/common/error/interpreter.cjs +1 -2
- package/dist/dataStructure/common/error/interpreter.d.ts +2 -6
- package/dist/dataStructure/common/error/interpreter.mjs +1 -2
- package/package.json +1 -1
|
@@ -7,59 +7,62 @@ const require_string = require("../codec/defaults/string.cjs");
|
|
|
7
7
|
const require_base = require("./base.cjs");
|
|
8
8
|
//#region scripts/dataStructure/common/error/defaultInterpreter.ts
|
|
9
9
|
const defaultErrorInterpreterDataStructureDictionary = {
|
|
10
|
-
"array-structure": () => "Expected an array.",
|
|
11
|
-
"lazy-structure": () => "Expected a value matching the resolved structure.",
|
|
12
|
-
"non-encodable-string-structure": (source) => `Expected ${require_stringify.stringify(source.definition.value)}.`,
|
|
13
|
-
"object-structure": () => "Expected a plain object containing only the defined properties.",
|
|
14
|
-
"record-structure": () => "Expected a plain object matching the record definition.",
|
|
15
|
-
"type-structure": () => "Expected a value matching the configured type.",
|
|
16
|
-
"union-structure": () => "Expected a value matching at least one union member.",
|
|
17
|
-
"bigint-type": () => "Expected a bigint.",
|
|
18
|
-
"bigint-literal-type": (source) => `Expected ${require_to.to(source.definition.value)}n.`,
|
|
19
|
-
"boolean-type": () => "Expected a boolean.",
|
|
20
|
-
"boolean-literal-type": (source) => `Expected ${source.definition.value}.`,
|
|
21
|
-
"date-type": () => "Expected a DuploJS date.",
|
|
22
|
-
"null-type": () => "Expected null.",
|
|
23
|
-
"number-type": () => "Expected a finite number.",
|
|
24
|
-
"number-literal-type": (source) => `Expected ${source.definition.value}.`,
|
|
25
|
-
"string-type": () => "Expected a string.",
|
|
26
|
-
"string-literal-type": (source) => `Expected ${require_stringify.stringify(source.definition.value)}.`,
|
|
27
|
-
"time-type": () => "Expected a DuploJS time.",
|
|
28
|
-
"undefined-type": () => "Expected undefined.",
|
|
29
|
-
"absolute-path-constraint": () => "Expected an absolute path.",
|
|
30
|
-
"allowed-characters-constraint": (source) => `Expected a string containing only characters from ${require_join.join(require_coalescing.coalescing(source.definition.charactersRange), ", ")}.`,
|
|
31
|
-
"array-length-equal-constraint": (source) => `Expected an array containing exactly ${source.definition.length} elements.`,
|
|
32
|
-
"between-than-constraint": (source) => `Expected a number greater than ${source.definition.greater} and less than ${source.definition.less}.`,
|
|
33
|
-
"between-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.greater} and less than or equal to ${source.definition.less}.`,
|
|
34
|
-
"email-constraint": () => "Expected a valid email address.",
|
|
35
|
-
"even-constraint": () => "Expected an even number.",
|
|
36
|
-
"greater-than-constraint": (source) => `Expected a number greater than ${source.definition.threshold}.`,
|
|
37
|
-
"greater-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.threshold}.`,
|
|
38
|
-
"integer-constraint": () => "Expected an integer.",
|
|
39
|
-
"less-than-constraint": (source) => `Expected a number less than ${source.definition.threshold}.`,
|
|
40
|
-
"less-than-or-equal-constraint": (source) => `Expected a number less than or equal to ${source.definition.threshold}.`,
|
|
41
|
-
"max-characters-constraint": (source) => `Expected a string containing at most ${source.definition.max} characters.`,
|
|
42
|
-
"max-elements-constraint": (source) => `Expected an array containing at most ${source.definition.max} elements.`,
|
|
43
|
-
"min-characters-constraint": (source) => `Expected a string containing at least ${source.definition.min} characters.`,
|
|
44
|
-
"min-elements-constraint": (source) => `Expected an array containing at least ${source.definition.min} elements.`,
|
|
45
|
-
"multiple-of-constraint": (source) => `Expected a multiple of ${source.definition.multiple}.`,
|
|
46
|
-
"negative-constraint": () => "Expected a number less than or equal to zero.",
|
|
47
|
-
"not-empty-constraint": () => "Expected a non-empty string.",
|
|
48
|
-
"not-zero-constraint": () => "Expected a non-zero number.",
|
|
49
|
-
"number-in-string-constraint": () => "Expected a string representing a number.",
|
|
50
|
-
"odd-constraint": () => "Expected an odd number.",
|
|
51
|
-
"path-constraint": () => "Expected a valid path.",
|
|
52
|
-
"positive-constraint": () => "Expected a number greater than or equal to zero.",
|
|
53
|
-
"refine-constraint": () => "Expected a value satisfying the custom refinement.",
|
|
54
|
-
"regex-constraint": (source) => `Expected a string matching ${source.definition.regex.toString()}.`,
|
|
55
|
-
"safe-constraint": () => "Expected a number strictly between Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER.",
|
|
56
|
-
"segment-path-constraint": () => "Expected a valid path segment.",
|
|
57
|
-
"strict-negative-constraint": () => "Expected a number less than zero.",
|
|
58
|
-
"strict-positive-constraint": () => "Expected a number greater than zero.",
|
|
59
|
-
"string-length-equal-constraint": (source) => `Expected a string containing exactly ${source.definition.length} characters.`,
|
|
60
|
-
"trimmed-constraint": () => "Expected a string without leading or trailing whitespace.",
|
|
61
|
-
"url-constraint": () => "Expected a valid URL.",
|
|
62
|
-
"uuid-constraint": () => "Expected a valid UUID."
|
|
10
|
+
"@DuplojsLangDataStructure/array-structure": () => "Expected an array.",
|
|
11
|
+
"@DuplojsLangDataStructure/lazy-structure": () => "Expected a value matching the resolved structure.",
|
|
12
|
+
"@DuplojsLangDataStructure/non-encodable-string-structure": (source) => `Expected ${require_stringify.stringify(source.definition.value)}.`,
|
|
13
|
+
"@DuplojsLangDataStructure/object-structure": () => "Expected a plain object containing only the defined properties.",
|
|
14
|
+
"@DuplojsLangDataStructure/record-structure": () => "Expected a plain object matching the record definition.",
|
|
15
|
+
"@DuplojsLangDataStructure/type-structure": () => "Expected a value matching the configured type.",
|
|
16
|
+
"@DuplojsLangDataStructure/union-structure": () => "Expected a value matching at least one union member.",
|
|
17
|
+
"@DuplojsLangDataStructure/bigint-type": () => "Expected a bigint.",
|
|
18
|
+
"@DuplojsLangDataStructure/bigint-literal-type": (source) => `Expected ${require_to.to(source.definition.value)}n.`,
|
|
19
|
+
"@DuplojsLangDataStructure/boolean-type": () => "Expected a boolean.",
|
|
20
|
+
"@DuplojsLangDataStructure/boolean-literal-type": (source) => `Expected ${source.definition.value}.`,
|
|
21
|
+
"@DuplojsLangDataStructure/date-type": () => "Expected a DuploJS date.",
|
|
22
|
+
"@DuplojsLangDataStructure/null-type": () => "Expected null.",
|
|
23
|
+
"@DuplojsLangDataStructure/number-type": () => "Expected a finite number.",
|
|
24
|
+
"@DuplojsLangDataStructure/number-literal-type": (source) => `Expected ${source.definition.value}.`,
|
|
25
|
+
"@DuplojsLangDataStructure/string-type": () => "Expected a string.",
|
|
26
|
+
"@DuplojsLangDataStructure/string-literal-type": (source) => `Expected ${require_stringify.stringify(source.definition.value)}.`,
|
|
27
|
+
"@DuplojsLangDataStructure/time-type": () => "Expected a DuploJS time.",
|
|
28
|
+
"@DuplojsLangDataStructure/undefined-type": () => "Expected undefined.",
|
|
29
|
+
"@DuplojsLangDataStructure/absolute-path-constraint": () => "Expected an absolute path.",
|
|
30
|
+
"@DuplojsLangDataStructure/allowed-characters-constraint": (source) => `Expected a string containing only characters from ${require_join.join(require_coalescing.coalescing(source.definition.charactersRange), ", ")}.`,
|
|
31
|
+
"@DuplojsLangDataStructure/array-length-equal-constraint": (source) => `Expected an array containing exactly ${source.definition.length} elements.`,
|
|
32
|
+
"@DuplojsLangDataStructure/between-than-constraint": (source) => `Expected a number greater than ${source.definition.greater} and less than ${source.definition.less}.`,
|
|
33
|
+
"@DuplojsLangDataStructure/between-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.greater} and less than or equal to ${source.definition.less}.`,
|
|
34
|
+
"@DuplojsLangDataStructure/email-constraint": () => "Expected a valid email address.",
|
|
35
|
+
"@DuplojsLangDataStructure/even-constraint": () => "Expected an even number.",
|
|
36
|
+
"@DuplojsLangDataStructure/greater-than-constraint": (source) => `Expected a number greater than ${source.definition.threshold}.`,
|
|
37
|
+
"@DuplojsLangDataStructure/greater-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.threshold}.`,
|
|
38
|
+
"@DuplojsLangDataStructure/integer-constraint": () => "Expected an integer.",
|
|
39
|
+
"@DuplojsLangDataStructure/less-than-constraint": (source) => `Expected a number less than ${source.definition.threshold}.`,
|
|
40
|
+
"@DuplojsLangDataStructure/less-than-or-equal-constraint": (source) => `Expected a number less than or equal to ${source.definition.threshold}.`,
|
|
41
|
+
"@DuplojsLangDataStructure/max-characters-constraint": (source) => `Expected a string containing at most ${source.definition.max} characters.`,
|
|
42
|
+
"@DuplojsLangDataStructure/max-elements-constraint": (source) => `Expected an array containing at most ${source.definition.max} elements.`,
|
|
43
|
+
"@DuplojsLangDataStructure/min-characters-constraint": (source) => `Expected a string containing at least ${source.definition.min} characters.`,
|
|
44
|
+
"@DuplojsLangDataStructure/min-elements-constraint": (source) => `Expected an array containing at least ${source.definition.min} elements.`,
|
|
45
|
+
"@DuplojsLangDataStructure/multiple-of-constraint": (source) => `Expected a multiple of ${source.definition.multiple}.`,
|
|
46
|
+
"@DuplojsLangDataStructure/negative-constraint": () => "Expected a number less than or equal to zero.",
|
|
47
|
+
"@DuplojsLangDataStructure/not-empty-constraint": () => "Expected a non-empty string.",
|
|
48
|
+
"@DuplojsLangDataStructure/not-zero-constraint": () => "Expected a non-zero number.",
|
|
49
|
+
"@DuplojsLangDataStructure/number-in-string-constraint": () => "Expected a string representing a number.",
|
|
50
|
+
"@DuplojsLangDataStructure/odd-constraint": () => "Expected an odd number.",
|
|
51
|
+
"@DuplojsLangDataStructure/path-constraint": () => "Expected a valid path.",
|
|
52
|
+
"@DuplojsLangDataStructure/positive-constraint": () => "Expected a number greater than or equal to zero.",
|
|
53
|
+
"@DuplojsLangDataStructure/refine-constraint": () => "Expected a value satisfying the custom refinement.",
|
|
54
|
+
"@DuplojsLangDataStructure/regex-constraint": (source) => `Expected a string matching ${source.definition.regex.toString()}.`,
|
|
55
|
+
"@DuplojsLangDataStructure/safe-constraint": () => "Expected a number strictly between Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER.",
|
|
56
|
+
"@DuplojsLangDataStructure/segment-path-constraint": () => "Expected a valid path segment.",
|
|
57
|
+
"@DuplojsLangDataStructure/strict-negative-constraint": () => "Expected a number less than zero.",
|
|
58
|
+
"@DuplojsLangDataStructure/strict-positive-constraint": () => "Expected a number greater than zero.",
|
|
59
|
+
"@DuplojsLangDataStructure/string-length-equal-constraint": (source) => `Expected a string containing exactly ${source.definition.length} characters.`,
|
|
60
|
+
"@DuplojsLangDataStructure/trimmed-constraint": () => "Expected a string without leading or trailing whitespace.",
|
|
61
|
+
"@DuplojsLangDataStructure/url-constraint": () => "Expected a valid URL.",
|
|
62
|
+
"@DuplojsLangDataStructure/uuid-constraint": () => "Expected a valid UUID.",
|
|
63
|
+
"@DuplojsLangModeling/entity-structure": () => "Expected a valid entity object.",
|
|
64
|
+
"@DuplojsLangModeling/new-type-structure": () => "Expected a value matching the branded type.",
|
|
65
|
+
"@DuplojsLangModeling/tagged-object-structure": (source) => `Expected a plain object matching one of the tagged variants of ${source.name}.`
|
|
63
66
|
};
|
|
64
67
|
const createDefaultCodecErrorMessage = (codecName, encodedValueDescription, decodedValueDescription) => (_codec, issue) => {
|
|
65
68
|
if (issue.from === "predicate") return require_base.encodeIssueKind.has(issue) ? `The ${codecName} codec must produce ${encodedValueDescription}.` : `Expected ${encodedValueDescription} for the ${codecName} codec.`;
|
|
@@ -1,57 +1,60 @@
|
|
|
1
1
|
import * as DString from '../../../string';
|
|
2
2
|
export declare const defaultErrorInterpreterDataStructureDictionary: {
|
|
3
|
-
readonly "array-structure": () => string;
|
|
4
|
-
readonly "lazy-structure": () => string;
|
|
5
|
-
readonly "non-encodable-string-structure": (source: import('../..').NonEncodableStringStructure) => string;
|
|
6
|
-
readonly "object-structure": () => string;
|
|
7
|
-
readonly "record-structure": () => string;
|
|
8
|
-
readonly "type-structure": () => string;
|
|
9
|
-
readonly "union-structure": () => string;
|
|
10
|
-
readonly "bigint-type": () => string;
|
|
11
|
-
readonly "bigint-literal-type": (source: import('../..').BigintLiteralType<bigint>) => string;
|
|
12
|
-
readonly "boolean-type": () => string;
|
|
13
|
-
readonly "boolean-literal-type": (source: import('../..').BooleanLiteralType<boolean>) => string;
|
|
14
|
-
readonly "date-type": () => string;
|
|
15
|
-
readonly "null-type": () => string;
|
|
16
|
-
readonly "number-type": () => string;
|
|
17
|
-
readonly "number-literal-type": (source: import('../..').NumberLiteralType<number>) => string;
|
|
18
|
-
readonly "string-type": () => string;
|
|
19
|
-
readonly "string-literal-type": (source: import('../..').StringLiteralType<string>) => string;
|
|
20
|
-
readonly "time-type": () => string;
|
|
21
|
-
readonly "undefined-type": () => string;
|
|
22
|
-
readonly "absolute-path-constraint": () => string;
|
|
23
|
-
readonly "allowed-characters-constraint": (source: import('../..').AllowedCharactersConstraint<DString.CharactersRange>) => string;
|
|
24
|
-
readonly "array-length-equal-constraint": (source: import('../..').ArrayLengthEqualConstraint<number>) => string;
|
|
25
|
-
readonly "between-than-constraint": (source: import('../..').BetweenThanConstraint<number, number>) => string;
|
|
26
|
-
readonly "between-than-or-equal-constraint": (source: import('../..').BetweenThanOrEqualConstraint<number, number>) => string;
|
|
27
|
-
readonly "email-constraint": () => string;
|
|
28
|
-
readonly "even-constraint": () => string;
|
|
29
|
-
readonly "greater-than-constraint": (source: import('../..').GreaterThanConstraint<number>) => string;
|
|
30
|
-
readonly "greater-than-or-equal-constraint": (source: import('../..').GreaterThanOrEqualConstraint<number>) => string;
|
|
31
|
-
readonly "integer-constraint": () => string;
|
|
32
|
-
readonly "less-than-constraint": (source: import('../..').LessThanConstraint<number>) => string;
|
|
33
|
-
readonly "less-than-or-equal-constraint": (source: import('../..').LessThanOrEqualConstraint<number>) => string;
|
|
34
|
-
readonly "max-characters-constraint": (source: import('../..').MaxCharactersConstraint<number>) => string;
|
|
35
|
-
readonly "max-elements-constraint": (source: import('../..').MaxElementsConstraint<number>) => string;
|
|
36
|
-
readonly "min-characters-constraint": (source: import('../..').MinCharactersConstraint<number>) => string;
|
|
37
|
-
readonly "min-elements-constraint": (source: import('../..').MinElementsConstraint<number>) => string;
|
|
38
|
-
readonly "multiple-of-constraint": (source: import('../..').MultipleOfConstraint<number>) => string;
|
|
39
|
-
readonly "negative-constraint": () => string;
|
|
40
|
-
readonly "not-empty-constraint": () => string;
|
|
41
|
-
readonly "not-zero-constraint": () => string;
|
|
42
|
-
readonly "number-in-string-constraint": () => string;
|
|
43
|
-
readonly "odd-constraint": () => string;
|
|
44
|
-
readonly "path-constraint": () => string;
|
|
45
|
-
readonly "positive-constraint": () => string;
|
|
46
|
-
readonly "refine-constraint": () => string;
|
|
47
|
-
readonly "regex-constraint": (source: import('../..').RegexConstraint) => string;
|
|
48
|
-
readonly "safe-constraint": () => string;
|
|
49
|
-
readonly "segment-path-constraint": () => string;
|
|
50
|
-
readonly "strict-negative-constraint": () => string;
|
|
51
|
-
readonly "strict-positive-constraint": () => string;
|
|
52
|
-
readonly "string-length-equal-constraint": (source: import('../..').StringLengthEqualConstraint<number>) => string;
|
|
53
|
-
readonly "trimmed-constraint": () => string;
|
|
54
|
-
readonly "url-constraint": () => string;
|
|
55
|
-
readonly "uuid-constraint": () => string;
|
|
3
|
+
readonly "@DuplojsLangDataStructure/array-structure": () => string;
|
|
4
|
+
readonly "@DuplojsLangDataStructure/lazy-structure": () => string;
|
|
5
|
+
readonly "@DuplojsLangDataStructure/non-encodable-string-structure": (source: import('../..').NonEncodableStringStructure) => string;
|
|
6
|
+
readonly "@DuplojsLangDataStructure/object-structure": () => string;
|
|
7
|
+
readonly "@DuplojsLangDataStructure/record-structure": () => string;
|
|
8
|
+
readonly "@DuplojsLangDataStructure/type-structure": () => string;
|
|
9
|
+
readonly "@DuplojsLangDataStructure/union-structure": () => string;
|
|
10
|
+
readonly "@DuplojsLangDataStructure/bigint-type": () => string;
|
|
11
|
+
readonly "@DuplojsLangDataStructure/bigint-literal-type": (source: import('../..').BigintLiteralType<bigint>) => string;
|
|
12
|
+
readonly "@DuplojsLangDataStructure/boolean-type": () => string;
|
|
13
|
+
readonly "@DuplojsLangDataStructure/boolean-literal-type": (source: import('../..').BooleanLiteralType<boolean>) => string;
|
|
14
|
+
readonly "@DuplojsLangDataStructure/date-type": () => string;
|
|
15
|
+
readonly "@DuplojsLangDataStructure/null-type": () => string;
|
|
16
|
+
readonly "@DuplojsLangDataStructure/number-type": () => string;
|
|
17
|
+
readonly "@DuplojsLangDataStructure/number-literal-type": (source: import('../..').NumberLiteralType<number>) => string;
|
|
18
|
+
readonly "@DuplojsLangDataStructure/string-type": () => string;
|
|
19
|
+
readonly "@DuplojsLangDataStructure/string-literal-type": (source: import('../..').StringLiteralType<string>) => string;
|
|
20
|
+
readonly "@DuplojsLangDataStructure/time-type": () => string;
|
|
21
|
+
readonly "@DuplojsLangDataStructure/undefined-type": () => string;
|
|
22
|
+
readonly "@DuplojsLangDataStructure/absolute-path-constraint": () => string;
|
|
23
|
+
readonly "@DuplojsLangDataStructure/allowed-characters-constraint": (source: import('../..').AllowedCharactersConstraint<DString.CharactersRange>) => string;
|
|
24
|
+
readonly "@DuplojsLangDataStructure/array-length-equal-constraint": (source: import('../..').ArrayLengthEqualConstraint<number>) => string;
|
|
25
|
+
readonly "@DuplojsLangDataStructure/between-than-constraint": (source: import('../..').BetweenThanConstraint<number, number>) => string;
|
|
26
|
+
readonly "@DuplojsLangDataStructure/between-than-or-equal-constraint": (source: import('../..').BetweenThanOrEqualConstraint<number, number>) => string;
|
|
27
|
+
readonly "@DuplojsLangDataStructure/email-constraint": () => string;
|
|
28
|
+
readonly "@DuplojsLangDataStructure/even-constraint": () => string;
|
|
29
|
+
readonly "@DuplojsLangDataStructure/greater-than-constraint": (source: import('../..').GreaterThanConstraint<number>) => string;
|
|
30
|
+
readonly "@DuplojsLangDataStructure/greater-than-or-equal-constraint": (source: import('../..').GreaterThanOrEqualConstraint<number>) => string;
|
|
31
|
+
readonly "@DuplojsLangDataStructure/integer-constraint": () => string;
|
|
32
|
+
readonly "@DuplojsLangDataStructure/less-than-constraint": (source: import('../..').LessThanConstraint<number>) => string;
|
|
33
|
+
readonly "@DuplojsLangDataStructure/less-than-or-equal-constraint": (source: import('../..').LessThanOrEqualConstraint<number>) => string;
|
|
34
|
+
readonly "@DuplojsLangDataStructure/max-characters-constraint": (source: import('../..').MaxCharactersConstraint<number>) => string;
|
|
35
|
+
readonly "@DuplojsLangDataStructure/max-elements-constraint": (source: import('../..').MaxElementsConstraint<number>) => string;
|
|
36
|
+
readonly "@DuplojsLangDataStructure/min-characters-constraint": (source: import('../..').MinCharactersConstraint<number>) => string;
|
|
37
|
+
readonly "@DuplojsLangDataStructure/min-elements-constraint": (source: import('../..').MinElementsConstraint<number>) => string;
|
|
38
|
+
readonly "@DuplojsLangDataStructure/multiple-of-constraint": (source: import('../..').MultipleOfConstraint<number>) => string;
|
|
39
|
+
readonly "@DuplojsLangDataStructure/negative-constraint": () => string;
|
|
40
|
+
readonly "@DuplojsLangDataStructure/not-empty-constraint": () => string;
|
|
41
|
+
readonly "@DuplojsLangDataStructure/not-zero-constraint": () => string;
|
|
42
|
+
readonly "@DuplojsLangDataStructure/number-in-string-constraint": () => string;
|
|
43
|
+
readonly "@DuplojsLangDataStructure/odd-constraint": () => string;
|
|
44
|
+
readonly "@DuplojsLangDataStructure/path-constraint": () => string;
|
|
45
|
+
readonly "@DuplojsLangDataStructure/positive-constraint": () => string;
|
|
46
|
+
readonly "@DuplojsLangDataStructure/refine-constraint": () => string;
|
|
47
|
+
readonly "@DuplojsLangDataStructure/regex-constraint": (source: import('../..').RegexConstraint) => string;
|
|
48
|
+
readonly "@DuplojsLangDataStructure/safe-constraint": () => string;
|
|
49
|
+
readonly "@DuplojsLangDataStructure/segment-path-constraint": () => string;
|
|
50
|
+
readonly "@DuplojsLangDataStructure/strict-negative-constraint": () => string;
|
|
51
|
+
readonly "@DuplojsLangDataStructure/strict-positive-constraint": () => string;
|
|
52
|
+
readonly "@DuplojsLangDataStructure/string-length-equal-constraint": (source: import('../..').StringLengthEqualConstraint<number>) => string;
|
|
53
|
+
readonly "@DuplojsLangDataStructure/trimmed-constraint": () => string;
|
|
54
|
+
readonly "@DuplojsLangDataStructure/url-constraint": () => string;
|
|
55
|
+
readonly "@DuplojsLangDataStructure/uuid-constraint": () => string;
|
|
56
|
+
readonly "@DuplojsLangModeling/entity-structure": () => string;
|
|
57
|
+
readonly "@DuplojsLangModeling/new-type-structure": () => string;
|
|
58
|
+
readonly "@DuplojsLangModeling/tagged-object-structure": (source: import('../../../modeling').TaggedObjectStructure<import('../../../modeling').ObjectTag<string>>) => string;
|
|
56
59
|
};
|
|
57
60
|
export declare const defaultErrorInterpreterCodecDictionary: [[import('../..').Codec<import('../..').TheBigint, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheDate, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheTime, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheBigint, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheBoolean, "true" | "false">, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheDate, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheNull, "null">, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheNumber, string & DString.Number>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheTime, string>, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string], [import('../..').Codec<import('../..').TheUndefined, "undefined">, (codec: import('../..').Codec, issue: import('../..').EncodeIssue | import('../..').DecodeIssue) => string]];
|
|
@@ -7,59 +7,62 @@ import { codecsString } from "../codec/defaults/string.mjs";
|
|
|
7
7
|
import { encodeIssueKind } from "./base.mjs";
|
|
8
8
|
//#region scripts/dataStructure/common/error/defaultInterpreter.ts
|
|
9
9
|
const defaultErrorInterpreterDataStructureDictionary = {
|
|
10
|
-
"array-structure": () => "Expected an array.",
|
|
11
|
-
"lazy-structure": () => "Expected a value matching the resolved structure.",
|
|
12
|
-
"non-encodable-string-structure": (source) => `Expected ${stringify(source.definition.value)}.`,
|
|
13
|
-
"object-structure": () => "Expected a plain object containing only the defined properties.",
|
|
14
|
-
"record-structure": () => "Expected a plain object matching the record definition.",
|
|
15
|
-
"type-structure": () => "Expected a value matching the configured type.",
|
|
16
|
-
"union-structure": () => "Expected a value matching at least one union member.",
|
|
17
|
-
"bigint-type": () => "Expected a bigint.",
|
|
18
|
-
"bigint-literal-type": (source) => `Expected ${to(source.definition.value)}n.`,
|
|
19
|
-
"boolean-type": () => "Expected a boolean.",
|
|
20
|
-
"boolean-literal-type": (source) => `Expected ${source.definition.value}.`,
|
|
21
|
-
"date-type": () => "Expected a DuploJS date.",
|
|
22
|
-
"null-type": () => "Expected null.",
|
|
23
|
-
"number-type": () => "Expected a finite number.",
|
|
24
|
-
"number-literal-type": (source) => `Expected ${source.definition.value}.`,
|
|
25
|
-
"string-type": () => "Expected a string.",
|
|
26
|
-
"string-literal-type": (source) => `Expected ${stringify(source.definition.value)}.`,
|
|
27
|
-
"time-type": () => "Expected a DuploJS time.",
|
|
28
|
-
"undefined-type": () => "Expected undefined.",
|
|
29
|
-
"absolute-path-constraint": () => "Expected an absolute path.",
|
|
30
|
-
"allowed-characters-constraint": (source) => `Expected a string containing only characters from ${join(coalescing(source.definition.charactersRange), ", ")}.`,
|
|
31
|
-
"array-length-equal-constraint": (source) => `Expected an array containing exactly ${source.definition.length} elements.`,
|
|
32
|
-
"between-than-constraint": (source) => `Expected a number greater than ${source.definition.greater} and less than ${source.definition.less}.`,
|
|
33
|
-
"between-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.greater} and less than or equal to ${source.definition.less}.`,
|
|
34
|
-
"email-constraint": () => "Expected a valid email address.",
|
|
35
|
-
"even-constraint": () => "Expected an even number.",
|
|
36
|
-
"greater-than-constraint": (source) => `Expected a number greater than ${source.definition.threshold}.`,
|
|
37
|
-
"greater-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.threshold}.`,
|
|
38
|
-
"integer-constraint": () => "Expected an integer.",
|
|
39
|
-
"less-than-constraint": (source) => `Expected a number less than ${source.definition.threshold}.`,
|
|
40
|
-
"less-than-or-equal-constraint": (source) => `Expected a number less than or equal to ${source.definition.threshold}.`,
|
|
41
|
-
"max-characters-constraint": (source) => `Expected a string containing at most ${source.definition.max} characters.`,
|
|
42
|
-
"max-elements-constraint": (source) => `Expected an array containing at most ${source.definition.max} elements.`,
|
|
43
|
-
"min-characters-constraint": (source) => `Expected a string containing at least ${source.definition.min} characters.`,
|
|
44
|
-
"min-elements-constraint": (source) => `Expected an array containing at least ${source.definition.min} elements.`,
|
|
45
|
-
"multiple-of-constraint": (source) => `Expected a multiple of ${source.definition.multiple}.`,
|
|
46
|
-
"negative-constraint": () => "Expected a number less than or equal to zero.",
|
|
47
|
-
"not-empty-constraint": () => "Expected a non-empty string.",
|
|
48
|
-
"not-zero-constraint": () => "Expected a non-zero number.",
|
|
49
|
-
"number-in-string-constraint": () => "Expected a string representing a number.",
|
|
50
|
-
"odd-constraint": () => "Expected an odd number.",
|
|
51
|
-
"path-constraint": () => "Expected a valid path.",
|
|
52
|
-
"positive-constraint": () => "Expected a number greater than or equal to zero.",
|
|
53
|
-
"refine-constraint": () => "Expected a value satisfying the custom refinement.",
|
|
54
|
-
"regex-constraint": (source) => `Expected a string matching ${source.definition.regex.toString()}.`,
|
|
55
|
-
"safe-constraint": () => "Expected a number strictly between Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER.",
|
|
56
|
-
"segment-path-constraint": () => "Expected a valid path segment.",
|
|
57
|
-
"strict-negative-constraint": () => "Expected a number less than zero.",
|
|
58
|
-
"strict-positive-constraint": () => "Expected a number greater than zero.",
|
|
59
|
-
"string-length-equal-constraint": (source) => `Expected a string containing exactly ${source.definition.length} characters.`,
|
|
60
|
-
"trimmed-constraint": () => "Expected a string without leading or trailing whitespace.",
|
|
61
|
-
"url-constraint": () => "Expected a valid URL.",
|
|
62
|
-
"uuid-constraint": () => "Expected a valid UUID."
|
|
10
|
+
"@DuplojsLangDataStructure/array-structure": () => "Expected an array.",
|
|
11
|
+
"@DuplojsLangDataStructure/lazy-structure": () => "Expected a value matching the resolved structure.",
|
|
12
|
+
"@DuplojsLangDataStructure/non-encodable-string-structure": (source) => `Expected ${stringify(source.definition.value)}.`,
|
|
13
|
+
"@DuplojsLangDataStructure/object-structure": () => "Expected a plain object containing only the defined properties.",
|
|
14
|
+
"@DuplojsLangDataStructure/record-structure": () => "Expected a plain object matching the record definition.",
|
|
15
|
+
"@DuplojsLangDataStructure/type-structure": () => "Expected a value matching the configured type.",
|
|
16
|
+
"@DuplojsLangDataStructure/union-structure": () => "Expected a value matching at least one union member.",
|
|
17
|
+
"@DuplojsLangDataStructure/bigint-type": () => "Expected a bigint.",
|
|
18
|
+
"@DuplojsLangDataStructure/bigint-literal-type": (source) => `Expected ${to(source.definition.value)}n.`,
|
|
19
|
+
"@DuplojsLangDataStructure/boolean-type": () => "Expected a boolean.",
|
|
20
|
+
"@DuplojsLangDataStructure/boolean-literal-type": (source) => `Expected ${source.definition.value}.`,
|
|
21
|
+
"@DuplojsLangDataStructure/date-type": () => "Expected a DuploJS date.",
|
|
22
|
+
"@DuplojsLangDataStructure/null-type": () => "Expected null.",
|
|
23
|
+
"@DuplojsLangDataStructure/number-type": () => "Expected a finite number.",
|
|
24
|
+
"@DuplojsLangDataStructure/number-literal-type": (source) => `Expected ${source.definition.value}.`,
|
|
25
|
+
"@DuplojsLangDataStructure/string-type": () => "Expected a string.",
|
|
26
|
+
"@DuplojsLangDataStructure/string-literal-type": (source) => `Expected ${stringify(source.definition.value)}.`,
|
|
27
|
+
"@DuplojsLangDataStructure/time-type": () => "Expected a DuploJS time.",
|
|
28
|
+
"@DuplojsLangDataStructure/undefined-type": () => "Expected undefined.",
|
|
29
|
+
"@DuplojsLangDataStructure/absolute-path-constraint": () => "Expected an absolute path.",
|
|
30
|
+
"@DuplojsLangDataStructure/allowed-characters-constraint": (source) => `Expected a string containing only characters from ${join(coalescing(source.definition.charactersRange), ", ")}.`,
|
|
31
|
+
"@DuplojsLangDataStructure/array-length-equal-constraint": (source) => `Expected an array containing exactly ${source.definition.length} elements.`,
|
|
32
|
+
"@DuplojsLangDataStructure/between-than-constraint": (source) => `Expected a number greater than ${source.definition.greater} and less than ${source.definition.less}.`,
|
|
33
|
+
"@DuplojsLangDataStructure/between-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.greater} and less than or equal to ${source.definition.less}.`,
|
|
34
|
+
"@DuplojsLangDataStructure/email-constraint": () => "Expected a valid email address.",
|
|
35
|
+
"@DuplojsLangDataStructure/even-constraint": () => "Expected an even number.",
|
|
36
|
+
"@DuplojsLangDataStructure/greater-than-constraint": (source) => `Expected a number greater than ${source.definition.threshold}.`,
|
|
37
|
+
"@DuplojsLangDataStructure/greater-than-or-equal-constraint": (source) => `Expected a number greater than or equal to ${source.definition.threshold}.`,
|
|
38
|
+
"@DuplojsLangDataStructure/integer-constraint": () => "Expected an integer.",
|
|
39
|
+
"@DuplojsLangDataStructure/less-than-constraint": (source) => `Expected a number less than ${source.definition.threshold}.`,
|
|
40
|
+
"@DuplojsLangDataStructure/less-than-or-equal-constraint": (source) => `Expected a number less than or equal to ${source.definition.threshold}.`,
|
|
41
|
+
"@DuplojsLangDataStructure/max-characters-constraint": (source) => `Expected a string containing at most ${source.definition.max} characters.`,
|
|
42
|
+
"@DuplojsLangDataStructure/max-elements-constraint": (source) => `Expected an array containing at most ${source.definition.max} elements.`,
|
|
43
|
+
"@DuplojsLangDataStructure/min-characters-constraint": (source) => `Expected a string containing at least ${source.definition.min} characters.`,
|
|
44
|
+
"@DuplojsLangDataStructure/min-elements-constraint": (source) => `Expected an array containing at least ${source.definition.min} elements.`,
|
|
45
|
+
"@DuplojsLangDataStructure/multiple-of-constraint": (source) => `Expected a multiple of ${source.definition.multiple}.`,
|
|
46
|
+
"@DuplojsLangDataStructure/negative-constraint": () => "Expected a number less than or equal to zero.",
|
|
47
|
+
"@DuplojsLangDataStructure/not-empty-constraint": () => "Expected a non-empty string.",
|
|
48
|
+
"@DuplojsLangDataStructure/not-zero-constraint": () => "Expected a non-zero number.",
|
|
49
|
+
"@DuplojsLangDataStructure/number-in-string-constraint": () => "Expected a string representing a number.",
|
|
50
|
+
"@DuplojsLangDataStructure/odd-constraint": () => "Expected an odd number.",
|
|
51
|
+
"@DuplojsLangDataStructure/path-constraint": () => "Expected a valid path.",
|
|
52
|
+
"@DuplojsLangDataStructure/positive-constraint": () => "Expected a number greater than or equal to zero.",
|
|
53
|
+
"@DuplojsLangDataStructure/refine-constraint": () => "Expected a value satisfying the custom refinement.",
|
|
54
|
+
"@DuplojsLangDataStructure/regex-constraint": (source) => `Expected a string matching ${source.definition.regex.toString()}.`,
|
|
55
|
+
"@DuplojsLangDataStructure/safe-constraint": () => "Expected a number strictly between Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER.",
|
|
56
|
+
"@DuplojsLangDataStructure/segment-path-constraint": () => "Expected a valid path segment.",
|
|
57
|
+
"@DuplojsLangDataStructure/strict-negative-constraint": () => "Expected a number less than zero.",
|
|
58
|
+
"@DuplojsLangDataStructure/strict-positive-constraint": () => "Expected a number greater than zero.",
|
|
59
|
+
"@DuplojsLangDataStructure/string-length-equal-constraint": (source) => `Expected a string containing exactly ${source.definition.length} characters.`,
|
|
60
|
+
"@DuplojsLangDataStructure/trimmed-constraint": () => "Expected a string without leading or trailing whitespace.",
|
|
61
|
+
"@DuplojsLangDataStructure/url-constraint": () => "Expected a valid URL.",
|
|
62
|
+
"@DuplojsLangDataStructure/uuid-constraint": () => "Expected a valid UUID.",
|
|
63
|
+
"@DuplojsLangModeling/entity-structure": () => "Expected a valid entity object.",
|
|
64
|
+
"@DuplojsLangModeling/new-type-structure": () => "Expected a value matching the branded type.",
|
|
65
|
+
"@DuplojsLangModeling/tagged-object-structure": (source) => `Expected a plain object matching one of the tagged variants of ${source.name}.`
|
|
63
66
|
};
|
|
64
67
|
const createDefaultCodecErrorMessage = (codecName, encodedValueDescription, decodedValueDescription) => (_codec, issue) => {
|
|
65
68
|
if (issue.from === "predicate") return encodeIssueKind.has(issue) ? `The ${codecName} codec must produce ${encodedValueDescription}.` : `Expected ${encodedValueDescription} for the ${codecName} codec.`;
|
|
@@ -6,9 +6,8 @@ const require_reduce = require("../../../array/reduce.cjs");
|
|
|
6
6
|
const require_pipe = require("../../../common/pipe.cjs");
|
|
7
7
|
const require_base$1 = require("./base.cjs");
|
|
8
8
|
//#region scripts/dataStructure/common/error/interpreter.ts
|
|
9
|
-
const kindNamespaceName = "DuplojsLangDataStructure";
|
|
10
9
|
function createErrorInterpreter(structureDictionary = {}, codecDictionary = []) {
|
|
11
|
-
const formattedStructureDictionary = require_pipe.pipe(structureDictionary, require_entries.entries, require_map.map(([key, value]) => require_entry.entry(`${require_base.keyKindPrefix}
|
|
10
|
+
const formattedStructureDictionary = require_pipe.pipe(structureDictionary, require_entries.entries, require_map.map(([key, value]) => require_entry.entry(`${require_base.keyKindPrefix}${key}`, value)));
|
|
12
11
|
const getInterpretedMessageStructure = (structure, issue) => require_reduce.reduce(formattedStructureDictionary, require_reduce.reduceFrom(void 0), ({ element: [key, getMessage], next, exit }) => getMessage && key in structure ? exit(getMessage(structure, issue)) : next(void 0));
|
|
13
12
|
const getInterpretedMessageCodec = (codec, issue) => require_reduce.reduce(codecDictionary, require_reduce.reduceFrom(void 0), ({ element: [currentCodec, message], next, exit }) => currentCodec === codec ? exit(message(codec, issue)) : next(void 0));
|
|
14
13
|
return (error) => require_map.map(error.issues, (issue) => {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { Structure, Structures } from '../../structure';
|
|
2
|
-
import { createKind } from '../../kind';
|
|
3
2
|
import { Type, Types } from '../../type';
|
|
4
3
|
import { Constraint, Constraints } from '../../constraint';
|
|
5
4
|
import { Error, DecodeIssue, EncodeIssue, Issue } from './base';
|
|
6
5
|
import { Codec } from '../codec';
|
|
7
6
|
import * as DKind from '../../../kind';
|
|
8
7
|
import * as DCommon from '../../../common';
|
|
9
|
-
declare const kindNamespaceName: DKind.GetNamespaceName<typeof createKind>;
|
|
10
|
-
type RemoveNamespace<GenericString> = GenericString extends `@${typeof kindNamespaceName}/${infer InferredKindName}` ? InferredKindName : never;
|
|
11
8
|
export interface InterpretedMessage {
|
|
12
9
|
source?: string;
|
|
13
10
|
interpretedSource?: string;
|
|
@@ -25,12 +22,11 @@ export interface InterpretedDecodedIssue extends DecodeIssue {
|
|
|
25
22
|
}
|
|
26
23
|
export type InterpretedIssues = (InterpretedIssue | InterpretedEncodedIssue | InterpretedDecodedIssue);
|
|
27
24
|
export type StructureDictionaryParams = DCommon.SimplifyTopLevel<Omit<{
|
|
28
|
-
[DataStructure in (Types | Structures | Constraints) as
|
|
29
|
-
},
|
|
25
|
+
[DataStructure in (Types | Structures | Constraints) as DKind.GetName<DataStructure>]?: (structure: DataStructure, issue: Issue) => string;
|
|
26
|
+
}, DKind.GetName<Type> | DKind.GetName<Structure> | DKind.GetName<Constraint>>>;
|
|
30
27
|
export type CodecDictionaryParams = [
|
|
31
28
|
Codec,
|
|
32
29
|
(codec: Codec, issue: EncodeIssue | DecodeIssue) => string
|
|
33
30
|
][];
|
|
34
31
|
export declare function createErrorInterpreter(structureDictionary?: StructureDictionaryParams, codecDictionary?: CodecDictionaryParams): (error: Error) => readonly InterpretedIssues[];
|
|
35
32
|
export type ErrorInterpreter = ReturnType<typeof createErrorInterpreter>;
|
|
36
|
-
export {};
|
|
@@ -6,9 +6,8 @@ import { reduce, reduceFrom } from "../../../array/reduce.mjs";
|
|
|
6
6
|
import { pipe } from "../../../common/pipe.mjs";
|
|
7
7
|
import { encodeIssueKind, issueKind } from "./base.mjs";
|
|
8
8
|
//#region scripts/dataStructure/common/error/interpreter.ts
|
|
9
|
-
const kindNamespaceName = "DuplojsLangDataStructure";
|
|
10
9
|
function createErrorInterpreter(structureDictionary = {}, codecDictionary = []) {
|
|
11
|
-
const formattedStructureDictionary = pipe(structureDictionary, entries, map(([key, value]) => entry(`${keyKindPrefix}
|
|
10
|
+
const formattedStructureDictionary = pipe(structureDictionary, entries, map(([key, value]) => entry(`${keyKindPrefix}${key}`, value)));
|
|
12
11
|
const getInterpretedMessageStructure = (structure, issue) => reduce(formattedStructureDictionary, reduceFrom(void 0), ({ element: [key, getMessage], next, exit }) => getMessage && key in structure ? exit(getMessage(structure, issue)) : next(void 0));
|
|
13
12
|
const getInterpretedMessageCodec = (codec, issue) => reduce(codecDictionary, reduceFrom(void 0), ({ element: [currentCodec, message], next, exit }) => currentCodec === codec ? exit(message(codec, issue)) : next(void 0));
|
|
14
13
|
return (error) => map(error.issues, (issue) => {
|