ts-fortress 6.0.0 → 6.1.0
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/README.md +14 -12
- package/dist/utils/validation-error.d.mts.map +1 -1
- package/dist/utils/validation-error.mjs +30 -26
- package/dist/utils/validation-error.mjs.map +1 -1
- package/package.json +9 -8
- package/src/array/array-at-least-length.test.mts +3 -3
- package/src/array/array-of-length.test.mts +3 -3
- package/src/array/array.test.mts +2 -2
- package/src/array/non-empty-array.test.mts +3 -3
- package/src/array/tuple.test.mts +2 -2
- package/src/brand/branded-number.test.mts +3 -3
- package/src/brand/branded-string.test.mts +3 -3
- package/src/compose/intersection.test.mts +11 -11
- package/src/compose/merge-records.test.mts +3 -3
- package/src/compose/union.test.mts +1 -1
- package/src/enum/enum.test.mts +1 -1
- package/src/enum/int-range.test.mts +1 -1
- package/src/enum/uint-range.test.mts +1 -1
- package/src/other-types/literal.test.mts +8 -8
- package/src/other-types/map.test.mts +6 -6
- package/src/other-types/set.test.mts +8 -8
- package/src/predefined/brand/number/finite-number.test.mts +3 -3
- package/src/predefined/brand/number/int.test.mts +4 -4
- package/src/predefined/brand/number/int16.test.mts +2 -2
- package/src/predefined/brand/number/int32.test.mts +2 -2
- package/src/predefined/brand/number/non-negative-finite-number.test.mts +2 -2
- package/src/predefined/brand/number/non-zero-finite-number.test.mts +2 -2
- package/src/predefined/brand/number/non-zero-int.test.mts +2 -2
- package/src/predefined/brand/number/non-zero-safe-int.test.mts +2 -2
- package/src/predefined/brand/number/positive-finite-number.test.mts +2 -2
- package/src/predefined/brand/number/positive-int.test.mts +4 -4
- package/src/predefined/brand/number/positive-safe-int.test.mts +2 -2
- package/src/predefined/brand/number/safe-int.test.mts +2 -2
- package/src/predefined/brand/number/safe-uint.test.mts +2 -2
- package/src/predefined/brand/number/uint.test.mts +4 -4
- package/src/predefined/brand/number/uint16.test.mts +2 -2
- package/src/predefined/brand/number/uint32.test.mts +2 -2
- package/src/predefined/brand/string/iso-8601.test.mts +1 -1
- package/src/predefined/brand/string/json-string.test.mts +2 -2
- package/src/predefined/brand/string/uuid.test.mts +1 -1
- package/src/primitives/bigint.test.mts +3 -3
- package/src/primitives/boolean.test.mts +3 -3
- package/src/primitives/null.test.mts +5 -3
- package/src/primitives/number.test.mts +3 -3
- package/src/primitives/string.test.mts +3 -3
- package/src/primitives/symbol.test.mts +3 -3
- package/src/primitives/undefined.test.mts +9 -3
- package/src/record/key-value-record.test.mts +4 -4
- package/src/record/keyof.test.mts +1 -1
- package/src/record/omit.test.mts +1 -1
- package/src/record/partial.test.mts +5 -5
- package/src/record/pick.test.mts +1 -1
- package/src/record/record-allow-excess-properties.test.mts +1 -1
- package/src/record/record-strict-composition.test.mts +7 -7
- package/src/record/record.test.mts +6 -6
- package/src/record/required.test.mts +7 -7
- package/src/record/strict-record.test.mts +1 -1
- package/src/utils/validation-error.formatting.test.mts +7 -3
- package/src/utils/validation-error.mts +40 -27
- package/src/utils/validation-error.test.mts +4 -4
package/README.md
CHANGED
|
@@ -153,9 +153,9 @@ assert.deepStrictEqual(
|
|
|
153
153
|
result.value satisfies readonly t.ValidationError[],
|
|
154
154
|
),
|
|
155
155
|
[
|
|
156
|
-
`
|
|
157
|
-
`
|
|
158
|
-
`
|
|
156
|
+
`Error at age: missing required key "age".`,
|
|
157
|
+
`Error at preferences.notifications: missing required key "notifications".`,
|
|
158
|
+
`Error at tags: missing required key "tags".`,
|
|
159
159
|
],
|
|
160
160
|
);
|
|
161
161
|
```
|
|
@@ -421,7 +421,7 @@ assert.deepStrictEqual(errorResult.value, [
|
|
|
421
421
|
]);
|
|
422
422
|
|
|
423
423
|
assert.deepStrictEqual(t.validationErrorsToMessages(errorResult.value), [
|
|
424
|
-
'
|
|
424
|
+
'Error at age: expected <number> value but <string> type value "thirty" was passed.',
|
|
425
425
|
]);
|
|
426
426
|
```
|
|
427
427
|
|
|
@@ -451,7 +451,7 @@ try {
|
|
|
451
451
|
assert.deepStrictEqual(
|
|
452
452
|
error,
|
|
453
453
|
new Error(
|
|
454
|
-
`\
|
|
454
|
+
`\nError: expected <number> value but <string> type value "not a number" was passed.`,
|
|
455
455
|
),
|
|
456
456
|
);
|
|
457
457
|
}
|
|
@@ -491,7 +491,9 @@ try {
|
|
|
491
491
|
} catch (error) {
|
|
492
492
|
assert.deepStrictEqual(
|
|
493
493
|
error,
|
|
494
|
-
new Error(
|
|
494
|
+
new Error(
|
|
495
|
+
'Error: expected <number> value but <string> type value "invalid" was passed.',
|
|
496
|
+
),
|
|
495
497
|
);
|
|
496
498
|
}
|
|
497
499
|
```
|
|
@@ -736,9 +738,9 @@ assert.deepStrictEqual(
|
|
|
736
738
|
result.value satisfies readonly t.ValidationError[],
|
|
737
739
|
),
|
|
738
740
|
[
|
|
739
|
-
'
|
|
740
|
-
'
|
|
741
|
-
'
|
|
741
|
+
'Error at id: expected <Uuid> value but <string> type value "user123" was passed.',
|
|
742
|
+
'Error at score: expected <PositiveNumber> value but <number> type value `-10` was passed.',
|
|
743
|
+
'Error at level: expected <EvenNumber> value but <number> type value `3` was passed.',
|
|
742
744
|
],
|
|
743
745
|
);
|
|
744
746
|
```
|
|
@@ -915,8 +917,8 @@ assert.deepStrictEqual(result.value, [
|
|
|
915
917
|
const messages = t.validationErrorsToMessages(result.value);
|
|
916
918
|
|
|
917
919
|
assert.deepStrictEqual(messages, [
|
|
918
|
-
'
|
|
919
|
-
'
|
|
920
|
+
'Error at name: expected <string> value but <number> type value `123` was passed.',
|
|
921
|
+
'Error at age: expected <number> value but <string> type value "not a number" was passed.',
|
|
920
922
|
]);
|
|
921
923
|
|
|
922
924
|
const assertIsUser: (a: unknown) => asserts a is User = User.assertIs;
|
|
@@ -928,7 +930,7 @@ try {
|
|
|
928
930
|
assert.deepStrictEqual(
|
|
929
931
|
error,
|
|
930
932
|
new Error(
|
|
931
|
-
'\
|
|
933
|
+
'\nError at name: expected <string> value but <number> type value `123` was passed.,\nError at age: expected <number> value but <string> type value "not a number" was passed.',
|
|
932
934
|
),
|
|
933
935
|
);
|
|
934
936
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-error.d.mts","sourceRoot":"","sources":["../../src/utils/validation-error.mts"],"names":[],"mappings":"AAEA,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CACzC;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,iBAAiB,CAAC;CACzB,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CACJ,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,iFAAiF;IACjF,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,8CAA8C;IAC9C,WAAW,EAAE,OAAO,CAAC;IACrB,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;CAC9C,CAAC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,eAAe,EACtB,8BAA6B,MAAW,KACvC,
|
|
1
|
+
{"version":3,"file":"validation-error.d.mts","sourceRoot":"","sources":["../../src/utils/validation-error.mts"],"names":[],"mappings":"AAEA,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CACzC;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GACD;I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AwBF,CAAC;AAyDF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,GACrC,QAAQ,SAAS,eAAe,EAAE,EAClC,8BAA6B,MAAW,KACvC,SAAS,MAAM,EAC2D,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,6BAA6B,GACxC,QAAQ,SAAS,eAAe,EAAE,EAClC,aAAa,MAAM,KAClB,SAAS,eAAe,EAItB,CAAC;AAEN;;GAEG;AACH,eAAO,MAAM,8BAA8B,GACzC,QAAQ,SAAS,eAAe,EAAE,EAClC,OAAO,MAAM,KACZ,SAAS,eAAe,EAC8B,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,8BAA8B,GAAI,mDAK5C,QAAQ,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAAC;CAC7C,CAAC,KAAG,eAMH,CAAC"}
|
|
@@ -4,10 +4,10 @@ import { isString, pipe, unknownToString } from 'ts-data-forge';
|
|
|
4
4
|
* Converts a validation error to a human-readable string message
|
|
5
5
|
*/
|
|
6
6
|
const validationErrorToMessage = (error, maxLengthToPrintActualValue = 20) => {
|
|
7
|
-
const
|
|
8
|
-
const detailsMessage = createDetailsMessage(error);
|
|
7
|
+
const pathPrefix = error.path.length > 0 ? `Error at ${error.path.join('.')}: ` : 'Error: ';
|
|
8
|
+
const detailsMessage = createDetailsMessage(error, maxLengthToPrintActualValue);
|
|
9
9
|
if (detailsMessage !== undefined) {
|
|
10
|
-
return `${
|
|
10
|
+
return `${pathPrefix}${detailsMessage}`;
|
|
11
11
|
}
|
|
12
12
|
const actualTypeStr = typeof error.actualValue;
|
|
13
13
|
const actualValueStr = isString(error.actualValue)
|
|
@@ -15,50 +15,54 @@ const validationErrorToMessage = (error, maxLengthToPrintActualValue = 20) => {
|
|
|
15
15
|
? ` "${error.actualValue}"`
|
|
16
16
|
: ''
|
|
17
17
|
: pipe(unknownToString(error.actualValue)).map((s) => s.length <= maxLengthToPrintActualValue ? ` \`${s}\`` : '').value;
|
|
18
|
-
return
|
|
18
|
+
return `${pathPrefix}expected <${error.expectedType}> value but <${actualTypeStr}> type value${actualValueStr} was passed.`;
|
|
19
19
|
};
|
|
20
|
-
const createDetailsMessage = (error) => {
|
|
20
|
+
const createDetailsMessage = (error, maxLengthToPrintActualValue) => {
|
|
21
|
+
const actualTypeStr = typeof error.actualValue;
|
|
22
|
+
const actualValueStr = isString(error.actualValue)
|
|
23
|
+
? error.actualValue.length <= maxLengthToPrintActualValue
|
|
24
|
+
? ` "${error.actualValue}"`
|
|
25
|
+
: ''
|
|
26
|
+
: pipe(unknownToString(error.actualValue)).map((s) => s.length <= maxLengthToPrintActualValue ? ` \`${s}\`` : '').value;
|
|
21
27
|
switch (error.details?.kind) {
|
|
22
28
|
case undefined:
|
|
23
29
|
return undefined;
|
|
24
30
|
case 'custom':
|
|
25
31
|
return error.details.message;
|
|
26
32
|
case 'enum':
|
|
27
|
-
return `
|
|
33
|
+
return `expected one of { ${error.details.values
|
|
28
34
|
.map((value) => String(value))
|
|
29
|
-
.join(', ')} }
|
|
35
|
+
.join(', ')} } but${actualValueStr} was passed.`;
|
|
30
36
|
case 'integer-range':
|
|
31
|
-
return `
|
|
37
|
+
return `expected an integer between ${error.details.start} and ${error.details.endExclusive - 1} but${actualValueStr} was passed.`;
|
|
32
38
|
case 'tuple-length':
|
|
33
|
-
return `
|
|
39
|
+
return `expected tuple of length ${error.details.expectedLength} but length ${error.details.actualLength} was passed.`;
|
|
34
40
|
case 'array-length':
|
|
35
|
-
return `
|
|
41
|
+
return `expected array of length ${error.details.expectedLength} but length ${error.details.actualLength} was passed.`;
|
|
36
42
|
case 'array-min-length':
|
|
37
|
-
return `
|
|
43
|
+
return `expected array of length ${error.details.minLength} or more but length ${error.details.actualLength} was passed.`;
|
|
38
44
|
case 'non-empty-array':
|
|
39
|
-
return '
|
|
45
|
+
return 'expected non-empty array but empty array was passed.';
|
|
40
46
|
case 'missing-key':
|
|
41
|
-
return `
|
|
47
|
+
return `missing required key "${error.details.key}".`;
|
|
42
48
|
case 'excess-key':
|
|
43
|
-
return `
|
|
49
|
+
return `excess property "${error.details.key}" is not allowed.`;
|
|
44
50
|
case 'intersection':
|
|
45
|
-
return `
|
|
51
|
+
return `expected value to match all types of { ${error.details.typeNames.join(', ')} } but <${actualTypeStr}> type value${actualValueStr} was passed.`;
|
|
46
52
|
case 'union':
|
|
47
|
-
return `
|
|
53
|
+
return `expected one of { ${error.details.typeNames.join(', ')} } but <${actualTypeStr}> type value${actualValueStr} was passed.`;
|
|
48
54
|
case 'record-entry':
|
|
49
55
|
return error.details.entry === 'key'
|
|
50
|
-
? `
|
|
51
|
-
: `
|
|
52
|
-
case 'map-entry':
|
|
53
|
-
|
|
54
|
-
? `
|
|
55
|
-
: `
|
|
56
|
-
return `${base}, but got <${typeof error.actualValue}> type value \`${unknownToString(error.actualValue)}\``;
|
|
57
|
-
}
|
|
56
|
+
? `expected record key to be <${error.details.expectedType}> but <${actualTypeStr}> type value${actualValueStr} was passed.`
|
|
57
|
+
: `expected record value to be <${error.details.expectedType}> but <${actualTypeStr}> type value${actualValueStr} was passed.`;
|
|
58
|
+
case 'map-entry':
|
|
59
|
+
return error.details.entry === 'key'
|
|
60
|
+
? `expected Map key to be <${error.details.expectedType}> but <${actualTypeStr}> type value${actualValueStr} was passed.`
|
|
61
|
+
: `expected Map value to be <${error.details.expectedType}> but <${actualTypeStr}> type value${actualValueStr} was passed.`;
|
|
58
62
|
case 'set-element':
|
|
59
|
-
return `
|
|
63
|
+
return `expected Set element to be <${error.details.expectedType}> but <${actualTypeStr}> type value${actualValueStr} was passed.`;
|
|
60
64
|
case 'brand':
|
|
61
|
-
return `
|
|
65
|
+
return `expected value to satisfy constraint: <${error.details.description}>.`;
|
|
62
66
|
}
|
|
63
67
|
};
|
|
64
68
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation-error.mjs","sources":["../../src/utils/validation-error.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAsFA;;AAEG;AACI,MAAM,wBAAwB,GAAG,CACtC,KAAsB,EACtB,2BAAA,GAAsC,EAAE,KAC9B;IACV,MAAM,
|
|
1
|
+
{"version":3,"file":"validation-error.mjs","sources":["../../src/utils/validation-error.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAsFA;;AAEG;AACI,MAAM,wBAAwB,GAAG,CACtC,KAAsB,EACtB,2BAAA,GAAsC,EAAE,KAC9B;IACV,MAAM,UAAU,GACd,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAA,SAAA,EAAY,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA,EAAA,CAAI,GAAG,SAAS;IAE1E,MAAM,cAAc,GAAG,oBAAoB,CACzC,KAAK,EACL,2BAA2B,CAC5B;AAED,IAAA,IAAI,cAAc,KAAK,SAAS,EAAE;AAChC,QAAA,OAAO,CAAA,EAAG,UAAU,CAAA,EAAG,cAAc,EAAE;IACzC;AAEA,IAAA,MAAM,aAAa,GAAG,OAAO,KAAK,CAAC,WAAW;AAE9C,IAAA,MAAM,cAAc,GAAW,QAAQ,CAAC,KAAK,CAAC,WAAW;AACvD,UAAE,KAAK,CAAC,WAAW,CAAC,MAAM,IAAI;AAC5B,cAAE,CAAA,EAAA,EAAK,KAAK,CAAC,WAAW,CAAA,CAAA;AACxB,cAAE;AACJ,UAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAC7C,CAAC,CAAC,MAAM,IAAI,2BAA2B,GAAG,CAAA,GAAA,EAAM,CAAC,CAAA,EAAA,CAAI,GAAG,EAAE,CAC3D,CAAC,KAAK;IAEX,OAAO,CAAA,EAAG,UAAU,CAAA,UAAA,EAAa,KAAK,CAAC,YAAY,CAAA,aAAA,EAAgB,aAAa,CAA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,QAAQ;IACR,OAAO;AACR,CAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-fortress",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript"
|
|
@@ -65,7 +65,8 @@
|
|
|
65
65
|
"z:vitest": "vitest --config ./configs/vitest.config.ts"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"
|
|
68
|
+
"@sindresorhus/is": "^7.1.1",
|
|
69
|
+
"ts-data-forge": "^5.0.1",
|
|
69
70
|
"ts-type-forge": "^2.3.0"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
@@ -80,27 +81,27 @@
|
|
|
80
81
|
"@semantic-release/github": "^12.0.2",
|
|
81
82
|
"@semantic-release/npm": "^13.1.1",
|
|
82
83
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
83
|
-
"@types/node": "^24.10.
|
|
84
|
+
"@types/node": "^24.10.1",
|
|
84
85
|
"@vitest/coverage-v8": "^4.0.8",
|
|
85
86
|
"@vitest/ui": "^4.0.8",
|
|
86
87
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
87
|
-
"cspell": "^9.3.
|
|
88
|
+
"cspell": "^9.3.1",
|
|
88
89
|
"eslint": "9.39.1",
|
|
89
|
-
"eslint-config-typed": "^3.5.
|
|
90
|
+
"eslint-config-typed": "^3.5.2",
|
|
90
91
|
"fast-glob": "^3.3.3",
|
|
91
92
|
"fp-ts": "^2.16.11",
|
|
92
93
|
"io-ts": "^2.2.22",
|
|
93
94
|
"jiti": "^2.6.1",
|
|
94
95
|
"markdownlint": "^0.39.0",
|
|
95
|
-
"markdownlint-cli2": "^0.
|
|
96
|
+
"markdownlint-cli2": "^0.19.0",
|
|
96
97
|
"npm-run-all2": "^8.0.4",
|
|
97
|
-
"octokit-safe-types": "^1.
|
|
98
|
+
"octokit-safe-types": "^1.2.0",
|
|
98
99
|
"prettier": "^3.6.2",
|
|
99
100
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
100
101
|
"prettier-plugin-packagejson": "^2.5.19",
|
|
101
102
|
"rollup": "^4.53.2",
|
|
102
103
|
"semantic-release": "^25.0.2",
|
|
103
|
-
"ts-repo-utils": "^7.8.
|
|
104
|
+
"ts-repo-utils": "^7.8.2",
|
|
104
105
|
"tslib": "^2.8.1",
|
|
105
106
|
"tsx": "^4.20.6",
|
|
106
107
|
"typedoc": "^0.28.14",
|
|
@@ -141,7 +141,7 @@ describe(arrayAtLeastLength, () => {
|
|
|
141
141
|
]);
|
|
142
142
|
|
|
143
143
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
144
|
-
'
|
|
144
|
+
'Error: expected <array> value but <string> type value "foo" was passed.',
|
|
145
145
|
]);
|
|
146
146
|
});
|
|
147
147
|
|
|
@@ -169,7 +169,7 @@ describe(arrayAtLeastLength, () => {
|
|
|
169
169
|
]);
|
|
170
170
|
|
|
171
171
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
172
|
-
'
|
|
172
|
+
'Error: expected array of length 3 or more but length 2 was passed.',
|
|
173
173
|
]);
|
|
174
174
|
});
|
|
175
175
|
|
|
@@ -193,7 +193,7 @@ describe(arrayAtLeastLength, () => {
|
|
|
193
193
|
]);
|
|
194
194
|
|
|
195
195
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
196
|
-
'
|
|
196
|
+
'Error at 1: expected <number> value but <string> type value "2" was passed.',
|
|
197
197
|
]);
|
|
198
198
|
});
|
|
199
199
|
});
|
|
@@ -133,7 +133,7 @@ describe(arrayOfLength, () => {
|
|
|
133
133
|
]);
|
|
134
134
|
|
|
135
135
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
136
|
-
'
|
|
136
|
+
'Error: expected array of length 4 but length 0 was passed.',
|
|
137
137
|
]);
|
|
138
138
|
});
|
|
139
139
|
|
|
@@ -164,8 +164,8 @@ describe(arrayOfLength, () => {
|
|
|
164
164
|
]);
|
|
165
165
|
|
|
166
166
|
assert.deepStrictEqual(validationErrorsToMessages(resultError1), [
|
|
167
|
-
'
|
|
168
|
-
'
|
|
167
|
+
'Error at 1: expected <number> value but <string> type value "1" was passed.',
|
|
168
|
+
'Error at 2: expected <number> value but <string> type value "" was passed.',
|
|
169
169
|
]);
|
|
170
170
|
});
|
|
171
171
|
});
|
package/src/array/array.test.mts
CHANGED
|
@@ -109,8 +109,8 @@ describe(array, () => {
|
|
|
109
109
|
// Test that we can convert to legacy string format for backward compatibility
|
|
110
110
|
|
|
111
111
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
112
|
-
'
|
|
113
|
-
'
|
|
112
|
+
'Error at 0: expected <number> value but <string> type value "1" was passed.',
|
|
113
|
+
'Error at 1: expected <number> value but <string> type value "" was passed.',
|
|
114
114
|
]);
|
|
115
115
|
});
|
|
116
116
|
|
|
@@ -125,7 +125,7 @@ describe(nonEmptyArray, () => {
|
|
|
125
125
|
]);
|
|
126
126
|
|
|
127
127
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
128
|
-
'
|
|
128
|
+
'Error: expected non-empty array but empty array was passed.',
|
|
129
129
|
]);
|
|
130
130
|
});
|
|
131
131
|
|
|
@@ -156,8 +156,8 @@ describe(nonEmptyArray, () => {
|
|
|
156
156
|
]);
|
|
157
157
|
|
|
158
158
|
assert.deepStrictEqual(validationErrorsToMessages(resultError1), [
|
|
159
|
-
'
|
|
160
|
-
'
|
|
159
|
+
'Error at 0: expected <number> value but <string> type value "1" was passed.',
|
|
160
|
+
'Error at 1: expected <number> value but <string> type value "" was passed.',
|
|
161
161
|
]);
|
|
162
162
|
});
|
|
163
163
|
});
|
package/src/array/tuple.test.mts
CHANGED
|
@@ -163,8 +163,8 @@ describe(tuple, () => {
|
|
|
163
163
|
]);
|
|
164
164
|
|
|
165
165
|
assert.deepStrictEqual(validationErrorsToMessages(resultError2), [
|
|
166
|
-
'
|
|
167
|
-
'
|
|
166
|
+
'Error at 0.x: expected <number> value but <string> type value "str" was passed.',
|
|
167
|
+
'Error at 0.y: expected <number> value but <string> type value "str" was passed.',
|
|
168
168
|
]);
|
|
169
169
|
});
|
|
170
170
|
|
|
@@ -86,7 +86,7 @@ describe('simpleBrandedNumber', () => {
|
|
|
86
86
|
]);
|
|
87
87
|
|
|
88
88
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
89
|
-
'
|
|
89
|
+
'Error: expected <number> value but <string> type value "not a number" was passed.',
|
|
90
90
|
]);
|
|
91
91
|
});
|
|
92
92
|
});
|
|
@@ -97,7 +97,7 @@ describe('simpleBrandedNumber', () => {
|
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
test('throws for invalid values', () => {
|
|
100
|
-
expect(() => userIdType.cast('invalid')).toThrow('
|
|
100
|
+
expect(() => userIdType.cast('invalid')).toThrow('Error');
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
103
|
|
|
@@ -168,7 +168,7 @@ describe('simpleBrandedNumber', () => {
|
|
|
168
168
|
]);
|
|
169
169
|
|
|
170
170
|
assert.deepStrictEqual(validationErrorsToMessages(resultError1), [
|
|
171
|
-
'
|
|
171
|
+
'Error: expected <number> value but <string> type value "invalid" was passed.',
|
|
172
172
|
]);
|
|
173
173
|
});
|
|
174
174
|
});
|
|
@@ -88,7 +88,7 @@ describe('simpleBrandedString', () => {
|
|
|
88
88
|
]);
|
|
89
89
|
|
|
90
90
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
91
|
-
'
|
|
91
|
+
'Error: expected <string> value but <number> type value `42` was passed.',
|
|
92
92
|
]);
|
|
93
93
|
});
|
|
94
94
|
});
|
|
@@ -99,7 +99,7 @@ describe('simpleBrandedString', () => {
|
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
test('throws for invalid values', () => {
|
|
102
|
-
expect(() => userNameType.cast(123)).toThrow('
|
|
102
|
+
expect(() => userNameType.cast(123)).toThrow('Error');
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
105
|
|
|
@@ -170,7 +170,7 @@ describe('simpleBrandedString', () => {
|
|
|
170
170
|
]);
|
|
171
171
|
|
|
172
172
|
assert.deepStrictEqual(validationErrorsToMessages(resultError1), [
|
|
173
|
-
'
|
|
173
|
+
'Error: expected <string> value but <object> type value `null` was passed.',
|
|
174
174
|
]);
|
|
175
175
|
});
|
|
176
176
|
});
|
|
@@ -148,9 +148,9 @@ describe(intersection, () => {
|
|
|
148
148
|
]);
|
|
149
149
|
|
|
150
150
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
151
|
-
'
|
|
152
|
-
'
|
|
153
|
-
'
|
|
151
|
+
'Error: expected value to match all types of { { x: number, y: number }, { z: number, w: number } } but <object> type value `{"x":0,"y":1}` was passed.',
|
|
152
|
+
'Error at z: missing required key "z".',
|
|
153
|
+
'Error at w: missing required key "w".',
|
|
154
154
|
]);
|
|
155
155
|
});
|
|
156
156
|
});
|
|
@@ -277,10 +277,10 @@ describe(intersection, () => {
|
|
|
277
277
|
]);
|
|
278
278
|
|
|
279
279
|
assert.deepStrictEqual(validationErrorsToMessages(resultError1), [
|
|
280
|
-
'
|
|
281
|
-
'
|
|
282
|
-
'
|
|
283
|
-
'
|
|
280
|
+
'Error: expected value to match all types of { number, number } but <string> type value "aaa" was passed.',
|
|
281
|
+
'Error: expected <number> value but <string> type value "aaa" was passed.',
|
|
282
|
+
'Error: expected value to match all types of { number, number } but <string> type value "aaa" was passed.',
|
|
283
|
+
'Error: expected <number> value but <string> type value "aaa" was passed.',
|
|
284
284
|
]);
|
|
285
285
|
});
|
|
286
286
|
});
|
|
@@ -430,10 +430,10 @@ describe(intersection, () => {
|
|
|
430
430
|
]);
|
|
431
431
|
|
|
432
432
|
assert.deepStrictEqual(validationErrorsToMessages(resultError2), [
|
|
433
|
-
'
|
|
434
|
-
'
|
|
435
|
-
'
|
|
436
|
-
'
|
|
433
|
+
'Error: expected value to match all types of { uintRange(0, 5), uintRange(1, 7) } but <number> type value `7` was passed.',
|
|
434
|
+
'Error: expected an integer between 0 and 4 but `7` was passed.',
|
|
435
|
+
'Error: expected value to match all types of { uintRange(0, 5), uintRange(1, 7) } but <number> type value `7` was passed.',
|
|
436
|
+
'Error: expected an integer between 1 and 6 but `7` was passed.',
|
|
437
437
|
]);
|
|
438
438
|
});
|
|
439
439
|
});
|
|
@@ -136,9 +136,9 @@ describe(mergeRecords, () => {
|
|
|
136
136
|
]);
|
|
137
137
|
|
|
138
138
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
139
|
-
'
|
|
140
|
-
'
|
|
141
|
-
'
|
|
139
|
+
'Error: expected value to match all types of { { x: number, y: number }, { z: number, w: number } } but <object> type value `{"x":0,"y":1}` was passed.',
|
|
140
|
+
'Error at z: missing required key "z".',
|
|
141
|
+
'Error at w: missing required key "w".',
|
|
142
142
|
]);
|
|
143
143
|
});
|
|
144
144
|
});
|
|
@@ -103,7 +103,7 @@ describe(union, () => {
|
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
106
|
-
'
|
|
106
|
+
'Error: expected one of { { x: number, y: number }, literal(3), literal("2") } but <number> type value `5` was passed.',
|
|
107
107
|
]);
|
|
108
108
|
});
|
|
109
109
|
|
package/src/enum/enum.test.mts
CHANGED
|
@@ -77,7 +77,7 @@ describe(enumType, () => {
|
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
80
|
-
'
|
|
80
|
+
'Error: expected one of { 3, 2, a } but `5` was passed.',
|
|
81
81
|
]);
|
|
82
82
|
});
|
|
83
83
|
|
|
@@ -90,7 +90,7 @@ describe(uintRange, () => {
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
93
|
-
'
|
|
93
|
+
'Error: expected an integer between 1 and 12 but `13` was passed.',
|
|
94
94
|
]);
|
|
95
95
|
});
|
|
96
96
|
});
|
|
@@ -153,7 +153,7 @@ describe(literal, () => {
|
|
|
153
153
|
const value: unknown = 'world';
|
|
154
154
|
|
|
155
155
|
expect(() => hello.cast(value)).toThrow(
|
|
156
|
-
'
|
|
156
|
+
'Error: expected <literal("hello")> value but <string> type value "world" was passed.',
|
|
157
157
|
);
|
|
158
158
|
});
|
|
159
159
|
});
|
|
@@ -383,7 +383,7 @@ describe(literal, () => {
|
|
|
383
383
|
]);
|
|
384
384
|
|
|
385
385
|
assert.deepStrictEqual(validationErrorsToMessages(resultError2), [
|
|
386
|
-
'
|
|
386
|
+
'Error: expected <literal(42n)> value but <bigint> type value `99n` was passed.',
|
|
387
387
|
]);
|
|
388
388
|
});
|
|
389
389
|
|
|
@@ -405,7 +405,7 @@ describe(literal, () => {
|
|
|
405
405
|
]);
|
|
406
406
|
|
|
407
407
|
assert.deepStrictEqual(validationErrorsToMessages(resultError3), [
|
|
408
|
-
'
|
|
408
|
+
'Error: expected <literal(42n)> value but <string> type value "not a bigint" was passed.',
|
|
409
409
|
]);
|
|
410
410
|
});
|
|
411
411
|
|
|
@@ -431,7 +431,7 @@ describe(literal, () => {
|
|
|
431
431
|
test('falsy case', () => {
|
|
432
432
|
const x: unknown = 123n;
|
|
433
433
|
|
|
434
|
-
expect(() => targetType.cast(x)).toThrow('
|
|
434
|
+
expect(() => targetType.cast(x)).toThrow('Error');
|
|
435
435
|
});
|
|
436
436
|
});
|
|
437
437
|
|
|
@@ -525,7 +525,7 @@ describe(literal, () => {
|
|
|
525
525
|
]);
|
|
526
526
|
|
|
527
527
|
assert.deepStrictEqual(validationErrorsToMessages(resultError4), [
|
|
528
|
-
'
|
|
528
|
+
'Error: expected <literal(true)> value but <boolean> type value `false` was passed.',
|
|
529
529
|
]);
|
|
530
530
|
});
|
|
531
531
|
|
|
@@ -547,7 +547,7 @@ describe(literal, () => {
|
|
|
547
547
|
]);
|
|
548
548
|
|
|
549
549
|
assert.deepStrictEqual(validationErrorsToMessages(resultError5), [
|
|
550
|
-
'
|
|
550
|
+
'Error: expected <literal(true)> value but <string> type value "not a boolean" was passed.',
|
|
551
551
|
]);
|
|
552
552
|
});
|
|
553
553
|
|
|
@@ -573,7 +573,7 @@ describe(literal, () => {
|
|
|
573
573
|
test('falsy case', () => {
|
|
574
574
|
const x: unknown = false;
|
|
575
575
|
|
|
576
|
-
expect(() => targetType.cast(x)).toThrow('
|
|
576
|
+
expect(() => targetType.cast(x)).toThrow('Error');
|
|
577
577
|
});
|
|
578
578
|
});
|
|
579
579
|
|
|
@@ -646,7 +646,7 @@ describe(literal, () => {
|
|
|
646
646
|
]);
|
|
647
647
|
|
|
648
648
|
assert.deepStrictEqual(validationErrorsToMessages(resultError6), [
|
|
649
|
-
'
|
|
649
|
+
'Error: expected <literal(false)> value but <boolean> type value `true` was passed.',
|
|
650
650
|
]);
|
|
651
651
|
});
|
|
652
652
|
|
|
@@ -66,8 +66,8 @@ test('MapType with invalid key types', () => {
|
|
|
66
66
|
expect(resultError.length).toBeGreaterThan(0);
|
|
67
67
|
|
|
68
68
|
assert.deepStrictEqual(validationErrorsToMessages(resultError), [
|
|
69
|
-
'
|
|
70
|
-
'
|
|
69
|
+
'Error: expected Map key to be <string> but <number> type value `123` was passed.',
|
|
70
|
+
'Error: expected <string> value but <number> type value `123` was passed.',
|
|
71
71
|
]);
|
|
72
72
|
});
|
|
73
73
|
|
|
@@ -94,8 +94,8 @@ test('MapType with invalid value types', () => {
|
|
|
94
94
|
expect(resultError1.length).toBeGreaterThan(0);
|
|
95
95
|
|
|
96
96
|
assert.deepStrictEqual(validationErrorsToMessages(resultError1), [
|
|
97
|
-
'
|
|
98
|
-
'
|
|
97
|
+
'Error: expected Map value to be <number> but <string> type value "not a number" was passed.',
|
|
98
|
+
'Error at b: expected <number> value but <string> type value "not a number" was passed.',
|
|
99
99
|
]);
|
|
100
100
|
});
|
|
101
101
|
|
|
@@ -150,7 +150,7 @@ test('MapType cast() method', () => {
|
|
|
150
150
|
// Invalid input - should throw
|
|
151
151
|
|
|
152
152
|
expect(() => StringNumberMap.cast('not a map')).toThrow(
|
|
153
|
-
'
|
|
153
|
+
'Error: expected <Map> value but <string> type value',
|
|
154
154
|
);
|
|
155
155
|
});
|
|
156
156
|
|
|
@@ -172,7 +172,7 @@ test('MapType assertIs() method', () => {
|
|
|
172
172
|
|
|
173
173
|
expect(() => {
|
|
174
174
|
assertIsStringNumberMap('not a map');
|
|
175
|
-
}).toThrow('
|
|
175
|
+
}).toThrow('Error: expected <Map> value but <string> type value');
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
test('MapType with custom typeName', () => {
|