@sinclair/typebox 0.24.47 → 0.24.48
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/errors/errors.d.ts +18 -17
- package/errors/errors.js +29 -20
- package/package.json +1 -1
package/errors/errors.d.ts
CHANGED
|
@@ -25,23 +25,24 @@ export declare enum ValueErrorType {
|
|
|
25
25
|
ObjectMinProperties = 22,
|
|
26
26
|
ObjectMaxProperties = 23,
|
|
27
27
|
ObjectAdditionalProperties = 24,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
ObjectRequiredProperties = 25,
|
|
29
|
+
Promise = 26,
|
|
30
|
+
RecordKeyNumeric = 27,
|
|
31
|
+
RecordKeyString = 28,
|
|
32
|
+
String = 29,
|
|
33
|
+
StringMinLength = 30,
|
|
34
|
+
StringMaxLength = 31,
|
|
35
|
+
StringPattern = 32,
|
|
36
|
+
StringFormatUnknown = 33,
|
|
37
|
+
StringFormat = 34,
|
|
38
|
+
TupleZeroLength = 35,
|
|
39
|
+
TupleLength = 36,
|
|
40
|
+
Undefined = 37,
|
|
41
|
+
Union = 38,
|
|
42
|
+
Uint8Array = 39,
|
|
43
|
+
Uint8ArrayMinByteLength = 40,
|
|
44
|
+
Uint8ArrayMaxByteLength = 41,
|
|
45
|
+
Void = 42
|
|
45
46
|
}
|
|
46
47
|
export interface ValueError {
|
|
47
48
|
type: ValueErrorType;
|
package/errors/errors.js
CHANGED
|
@@ -60,23 +60,24 @@ var ValueErrorType;
|
|
|
60
60
|
ValueErrorType[ValueErrorType["ObjectMinProperties"] = 22] = "ObjectMinProperties";
|
|
61
61
|
ValueErrorType[ValueErrorType["ObjectMaxProperties"] = 23] = "ObjectMaxProperties";
|
|
62
62
|
ValueErrorType[ValueErrorType["ObjectAdditionalProperties"] = 24] = "ObjectAdditionalProperties";
|
|
63
|
-
ValueErrorType[ValueErrorType["
|
|
64
|
-
ValueErrorType[ValueErrorType["
|
|
65
|
-
ValueErrorType[ValueErrorType["
|
|
66
|
-
ValueErrorType[ValueErrorType["
|
|
67
|
-
ValueErrorType[ValueErrorType["
|
|
68
|
-
ValueErrorType[ValueErrorType["
|
|
69
|
-
ValueErrorType[ValueErrorType["
|
|
70
|
-
ValueErrorType[ValueErrorType["
|
|
71
|
-
ValueErrorType[ValueErrorType["
|
|
72
|
-
ValueErrorType[ValueErrorType["
|
|
73
|
-
ValueErrorType[ValueErrorType["
|
|
74
|
-
ValueErrorType[ValueErrorType["
|
|
75
|
-
ValueErrorType[ValueErrorType["
|
|
76
|
-
ValueErrorType[ValueErrorType["
|
|
77
|
-
ValueErrorType[ValueErrorType["
|
|
78
|
-
ValueErrorType[ValueErrorType["
|
|
79
|
-
ValueErrorType[ValueErrorType["
|
|
63
|
+
ValueErrorType[ValueErrorType["ObjectRequiredProperties"] = 25] = "ObjectRequiredProperties";
|
|
64
|
+
ValueErrorType[ValueErrorType["Promise"] = 26] = "Promise";
|
|
65
|
+
ValueErrorType[ValueErrorType["RecordKeyNumeric"] = 27] = "RecordKeyNumeric";
|
|
66
|
+
ValueErrorType[ValueErrorType["RecordKeyString"] = 28] = "RecordKeyString";
|
|
67
|
+
ValueErrorType[ValueErrorType["String"] = 29] = "String";
|
|
68
|
+
ValueErrorType[ValueErrorType["StringMinLength"] = 30] = "StringMinLength";
|
|
69
|
+
ValueErrorType[ValueErrorType["StringMaxLength"] = 31] = "StringMaxLength";
|
|
70
|
+
ValueErrorType[ValueErrorType["StringPattern"] = 32] = "StringPattern";
|
|
71
|
+
ValueErrorType[ValueErrorType["StringFormatUnknown"] = 33] = "StringFormatUnknown";
|
|
72
|
+
ValueErrorType[ValueErrorType["StringFormat"] = 34] = "StringFormat";
|
|
73
|
+
ValueErrorType[ValueErrorType["TupleZeroLength"] = 35] = "TupleZeroLength";
|
|
74
|
+
ValueErrorType[ValueErrorType["TupleLength"] = 36] = "TupleLength";
|
|
75
|
+
ValueErrorType[ValueErrorType["Undefined"] = 37] = "Undefined";
|
|
76
|
+
ValueErrorType[ValueErrorType["Union"] = 38] = "Union";
|
|
77
|
+
ValueErrorType[ValueErrorType["Uint8Array"] = 39] = "Uint8Array";
|
|
78
|
+
ValueErrorType[ValueErrorType["Uint8ArrayMinByteLength"] = 40] = "Uint8ArrayMinByteLength";
|
|
79
|
+
ValueErrorType[ValueErrorType["Uint8ArrayMaxByteLength"] = 41] = "Uint8ArrayMaxByteLength";
|
|
80
|
+
ValueErrorType[ValueErrorType["Void"] = 42] = "Void";
|
|
80
81
|
})(ValueErrorType = exports.ValueErrorType || (exports.ValueErrorType = {}));
|
|
81
82
|
// -------------------------------------------------------------------
|
|
82
83
|
// ValueErrors
|
|
@@ -190,12 +191,20 @@ var ValueErrors;
|
|
|
190
191
|
}
|
|
191
192
|
const propertyKeys = globalThis.Object.keys(schema.properties);
|
|
192
193
|
if (schema.additionalProperties === false) {
|
|
193
|
-
for (const
|
|
194
|
-
if (!propertyKeys.includes(
|
|
195
|
-
yield { type: ValueErrorType.ObjectAdditionalProperties, schema, path: `${path}/${
|
|
194
|
+
for (const objectKey of globalThis.Object.keys(value)) {
|
|
195
|
+
if (!propertyKeys.includes(objectKey)) {
|
|
196
|
+
yield { type: ValueErrorType.ObjectAdditionalProperties, schema, path: `${path}/${objectKey}`, value: value[objectKey], message: `Unexpected property` };
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
199
|
}
|
|
200
|
+
if (schema.required && schema.required.length > 0) {
|
|
201
|
+
const objectKeys = globalThis.Object.keys(value);
|
|
202
|
+
for (const requiredKey of schema.required) {
|
|
203
|
+
if (objectKeys.includes(requiredKey))
|
|
204
|
+
continue;
|
|
205
|
+
yield { type: ValueErrorType.ObjectRequiredProperties, schema: schema.properties[requiredKey], path: `${path}/${requiredKey}`, value: undefined, message: `Expected required property` };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
199
208
|
for (const propertyKey of propertyKeys) {
|
|
200
209
|
const propertySchema = schema.properties[propertyKey];
|
|
201
210
|
if (schema.required && schema.required.includes(propertyKey)) {
|