@sinclair/typebox 0.30.3 → 0.31.0-dev-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/compiler.d.ts +22 -14
- package/compiler/compiler.js +135 -107
- package/compiler/index.d.ts +1 -1
- package/compiler/index.js +2 -1
- package/errors/errors.d.ts +56 -61
- package/errors/errors.js +222 -279
- package/package.json +5 -3
- package/readme.md +592 -511
- package/system/system.d.ts +34 -8
- package/system/system.js +214 -11
- package/typebox.d.ts +180 -106
- package/typebox.js +794 -907
- package/value/cast.d.ts +6 -12
- package/value/cast.js +81 -163
- package/value/check.d.ts +1 -5
- package/value/check.js +59 -103
- package/value/clone.js +6 -29
- package/value/convert.d.ts +2 -5
- package/value/convert.js +55 -106
- package/value/create.d.ts +6 -10
- package/value/create.js +54 -68
- package/value/delta.js +22 -22
- package/value/deref.d.ts +7 -0
- package/value/deref.js +46 -0
- package/value/equal.js +10 -10
- package/value/guard.js +1 -1
- package/value/hash.js +14 -14
- package/value/mutate.js +17 -17
- package/value/pointer.js +2 -2
- package/value/transform.d.ts +42 -0
- package/value/transform.js +512 -0
- package/value/value.d.ts +8 -0
- package/value/value.js +18 -0
package/errors/errors.js
CHANGED
|
@@ -27,82 +27,98 @@ THE SOFTWARE.
|
|
|
27
27
|
|
|
28
28
|
---------------------------------------------------------------------------*/
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.Errors = exports.
|
|
31
|
-
const
|
|
30
|
+
exports.Errors = exports.ValueErrorIterator = exports.ValueErrorsUnknownTypeError = exports.ValueErrorType = void 0;
|
|
31
|
+
const guard_1 = require("../value/guard");
|
|
32
|
+
const system_1 = require("../system/system");
|
|
33
|
+
const deref_1 = require("../value/deref");
|
|
34
|
+
const hash_1 = require("../value/hash");
|
|
32
35
|
const Types = require("../typebox");
|
|
33
|
-
const ValueHash = require("../value/hash");
|
|
34
|
-
const ValueGuard = require("../value/guard");
|
|
35
36
|
// --------------------------------------------------------------------------
|
|
36
37
|
// ValueErrorType
|
|
37
38
|
// --------------------------------------------------------------------------
|
|
38
39
|
var ValueErrorType;
|
|
39
40
|
(function (ValueErrorType) {
|
|
40
|
-
ValueErrorType[ValueErrorType["
|
|
41
|
-
ValueErrorType[ValueErrorType["
|
|
41
|
+
ValueErrorType[ValueErrorType["ArrayContains"] = 0] = "ArrayContains";
|
|
42
|
+
ValueErrorType[ValueErrorType["ArrayMaxContains"] = 1] = "ArrayMaxContains";
|
|
42
43
|
ValueErrorType[ValueErrorType["ArrayMaxItems"] = 2] = "ArrayMaxItems";
|
|
43
|
-
ValueErrorType[ValueErrorType["
|
|
44
|
-
ValueErrorType[ValueErrorType["
|
|
45
|
-
ValueErrorType[ValueErrorType["
|
|
46
|
-
ValueErrorType[ValueErrorType["
|
|
44
|
+
ValueErrorType[ValueErrorType["ArrayMinContains"] = 3] = "ArrayMinContains";
|
|
45
|
+
ValueErrorType[ValueErrorType["ArrayMinItems"] = 4] = "ArrayMinItems";
|
|
46
|
+
ValueErrorType[ValueErrorType["ArrayUniqueItems"] = 5] = "ArrayUniqueItems";
|
|
47
|
+
ValueErrorType[ValueErrorType["Array"] = 6] = "Array";
|
|
47
48
|
ValueErrorType[ValueErrorType["AsyncIterator"] = 7] = "AsyncIterator";
|
|
48
|
-
ValueErrorType[ValueErrorType["
|
|
49
|
-
ValueErrorType[ValueErrorType["
|
|
50
|
-
ValueErrorType[ValueErrorType["
|
|
51
|
-
ValueErrorType[ValueErrorType["
|
|
52
|
-
ValueErrorType[ValueErrorType["
|
|
53
|
-
ValueErrorType[ValueErrorType["
|
|
49
|
+
ValueErrorType[ValueErrorType["BigIntExclusiveMaximum"] = 8] = "BigIntExclusiveMaximum";
|
|
50
|
+
ValueErrorType[ValueErrorType["BigIntExclusiveMinimum"] = 9] = "BigIntExclusiveMinimum";
|
|
51
|
+
ValueErrorType[ValueErrorType["BigIntMaximum"] = 10] = "BigIntMaximum";
|
|
52
|
+
ValueErrorType[ValueErrorType["BigIntMinimum"] = 11] = "BigIntMinimum";
|
|
53
|
+
ValueErrorType[ValueErrorType["BigIntMultipleOf"] = 12] = "BigIntMultipleOf";
|
|
54
|
+
ValueErrorType[ValueErrorType["BigInt"] = 13] = "BigInt";
|
|
54
55
|
ValueErrorType[ValueErrorType["Boolean"] = 14] = "Boolean";
|
|
55
|
-
ValueErrorType[ValueErrorType["
|
|
56
|
+
ValueErrorType[ValueErrorType["DateExclusiveMaximumTimestamp"] = 15] = "DateExclusiveMaximumTimestamp";
|
|
56
57
|
ValueErrorType[ValueErrorType["DateExclusiveMinimumTimestamp"] = 16] = "DateExclusiveMinimumTimestamp";
|
|
57
|
-
ValueErrorType[ValueErrorType["
|
|
58
|
+
ValueErrorType[ValueErrorType["DateMaximumTimestamp"] = 17] = "DateMaximumTimestamp";
|
|
58
59
|
ValueErrorType[ValueErrorType["DateMinimumTimestamp"] = 18] = "DateMinimumTimestamp";
|
|
59
|
-
ValueErrorType[ValueErrorType["
|
|
60
|
-
ValueErrorType[ValueErrorType["
|
|
61
|
-
ValueErrorType[ValueErrorType["
|
|
62
|
-
ValueErrorType[ValueErrorType["
|
|
60
|
+
ValueErrorType[ValueErrorType["DateMultipleOfTimestamp"] = 19] = "DateMultipleOfTimestamp";
|
|
61
|
+
ValueErrorType[ValueErrorType["Date"] = 20] = "Date";
|
|
62
|
+
ValueErrorType[ValueErrorType["Function"] = 21] = "Function";
|
|
63
|
+
ValueErrorType[ValueErrorType["IntegerExclusiveMaximum"] = 22] = "IntegerExclusiveMaximum";
|
|
63
64
|
ValueErrorType[ValueErrorType["IntegerExclusiveMinimum"] = 23] = "IntegerExclusiveMinimum";
|
|
64
|
-
ValueErrorType[ValueErrorType["
|
|
65
|
+
ValueErrorType[ValueErrorType["IntegerMaximum"] = 24] = "IntegerMaximum";
|
|
65
66
|
ValueErrorType[ValueErrorType["IntegerMinimum"] = 25] = "IntegerMinimum";
|
|
66
|
-
ValueErrorType[ValueErrorType["
|
|
67
|
-
ValueErrorType[ValueErrorType["
|
|
67
|
+
ValueErrorType[ValueErrorType["IntegerMultipleOf"] = 26] = "IntegerMultipleOf";
|
|
68
|
+
ValueErrorType[ValueErrorType["Integer"] = 27] = "Integer";
|
|
68
69
|
ValueErrorType[ValueErrorType["IntersectUnevaluatedProperties"] = 28] = "IntersectUnevaluatedProperties";
|
|
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["
|
|
80
|
-
ValueErrorType[ValueErrorType["
|
|
81
|
-
ValueErrorType[ValueErrorType["
|
|
82
|
-
ValueErrorType[ValueErrorType["
|
|
83
|
-
ValueErrorType[ValueErrorType["
|
|
84
|
-
ValueErrorType[ValueErrorType["
|
|
85
|
-
ValueErrorType[ValueErrorType["
|
|
86
|
-
ValueErrorType[ValueErrorType["
|
|
87
|
-
ValueErrorType[ValueErrorType["
|
|
88
|
-
ValueErrorType[ValueErrorType["
|
|
89
|
-
ValueErrorType[ValueErrorType["
|
|
70
|
+
ValueErrorType[ValueErrorType["Intersect"] = 29] = "Intersect";
|
|
71
|
+
ValueErrorType[ValueErrorType["Iterator"] = 30] = "Iterator";
|
|
72
|
+
ValueErrorType[ValueErrorType["Kind"] = 31] = "Kind";
|
|
73
|
+
ValueErrorType[ValueErrorType["Literal"] = 32] = "Literal";
|
|
74
|
+
ValueErrorType[ValueErrorType["Never"] = 33] = "Never";
|
|
75
|
+
ValueErrorType[ValueErrorType["Not"] = 34] = "Not";
|
|
76
|
+
ValueErrorType[ValueErrorType["Null"] = 35] = "Null";
|
|
77
|
+
ValueErrorType[ValueErrorType["NumberExclusiveMaximum"] = 36] = "NumberExclusiveMaximum";
|
|
78
|
+
ValueErrorType[ValueErrorType["NumberExclusiveMinimum"] = 37] = "NumberExclusiveMinimum";
|
|
79
|
+
ValueErrorType[ValueErrorType["NumberMaximum"] = 38] = "NumberMaximum";
|
|
80
|
+
ValueErrorType[ValueErrorType["NumberMinimum"] = 39] = "NumberMinimum";
|
|
81
|
+
ValueErrorType[ValueErrorType["NumberMultipleOf"] = 40] = "NumberMultipleOf";
|
|
82
|
+
ValueErrorType[ValueErrorType["Number"] = 41] = "Number";
|
|
83
|
+
ValueErrorType[ValueErrorType["ObjectAdditionalProperties"] = 42] = "ObjectAdditionalProperties";
|
|
84
|
+
ValueErrorType[ValueErrorType["ObjectMaxProperties"] = 43] = "ObjectMaxProperties";
|
|
85
|
+
ValueErrorType[ValueErrorType["ObjectMinProperties"] = 44] = "ObjectMinProperties";
|
|
86
|
+
ValueErrorType[ValueErrorType["ObjectRequiredProperty"] = 45] = "ObjectRequiredProperty";
|
|
87
|
+
ValueErrorType[ValueErrorType["Object"] = 46] = "Object";
|
|
88
|
+
ValueErrorType[ValueErrorType["Promise"] = 47] = "Promise";
|
|
89
|
+
ValueErrorType[ValueErrorType["StringFormatUnknown"] = 48] = "StringFormatUnknown";
|
|
90
|
+
ValueErrorType[ValueErrorType["StringFormat"] = 49] = "StringFormat";
|
|
90
91
|
ValueErrorType[ValueErrorType["StringMaxLength"] = 50] = "StringMaxLength";
|
|
91
|
-
ValueErrorType[ValueErrorType["
|
|
92
|
-
ValueErrorType[ValueErrorType["
|
|
93
|
-
ValueErrorType[ValueErrorType["
|
|
92
|
+
ValueErrorType[ValueErrorType["StringMinLength"] = 51] = "StringMinLength";
|
|
93
|
+
ValueErrorType[ValueErrorType["StringPattern"] = 52] = "StringPattern";
|
|
94
|
+
ValueErrorType[ValueErrorType["String"] = 53] = "String";
|
|
94
95
|
ValueErrorType[ValueErrorType["Symbol"] = 54] = "Symbol";
|
|
95
|
-
ValueErrorType[ValueErrorType["
|
|
96
|
-
ValueErrorType[ValueErrorType["
|
|
97
|
-
ValueErrorType[ValueErrorType["
|
|
98
|
-
ValueErrorType[ValueErrorType["
|
|
96
|
+
ValueErrorType[ValueErrorType["TupleLength"] = 55] = "TupleLength";
|
|
97
|
+
ValueErrorType[ValueErrorType["Tuple"] = 56] = "Tuple";
|
|
98
|
+
ValueErrorType[ValueErrorType["Uint8ArrayMaxByteLength"] = 57] = "Uint8ArrayMaxByteLength";
|
|
99
|
+
ValueErrorType[ValueErrorType["Uint8ArrayMinByteLength"] = 58] = "Uint8ArrayMinByteLength";
|
|
99
100
|
ValueErrorType[ValueErrorType["Uint8Array"] = 59] = "Uint8Array";
|
|
100
|
-
ValueErrorType[ValueErrorType["
|
|
101
|
-
ValueErrorType[ValueErrorType["
|
|
101
|
+
ValueErrorType[ValueErrorType["Undefined"] = 60] = "Undefined";
|
|
102
|
+
ValueErrorType[ValueErrorType["Union"] = 61] = "Union";
|
|
102
103
|
ValueErrorType[ValueErrorType["Void"] = 62] = "Void";
|
|
103
|
-
ValueErrorType[ValueErrorType["Kind"] = 63] = "Kind";
|
|
104
104
|
})(ValueErrorType || (exports.ValueErrorType = ValueErrorType = {}));
|
|
105
105
|
// --------------------------------------------------------------------------
|
|
106
|
+
// ValueErrors
|
|
107
|
+
// --------------------------------------------------------------------------
|
|
108
|
+
class ValueErrorsUnknownTypeError extends Types.TypeBoxError {
|
|
109
|
+
constructor(schema) {
|
|
110
|
+
super('Unknown type');
|
|
111
|
+
this.schema = schema;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.ValueErrorsUnknownTypeError = ValueErrorsUnknownTypeError;
|
|
115
|
+
// --------------------------------------------------------------------------
|
|
116
|
+
// Guards
|
|
117
|
+
// --------------------------------------------------------------------------
|
|
118
|
+
function IsDefined(value) {
|
|
119
|
+
return value !== undefined;
|
|
120
|
+
}
|
|
121
|
+
// --------------------------------------------------------------------------
|
|
106
122
|
// ValueErrorIterator
|
|
107
123
|
// --------------------------------------------------------------------------
|
|
108
124
|
class ValueErrorIterator {
|
|
@@ -120,69 +136,31 @@ class ValueErrorIterator {
|
|
|
120
136
|
}
|
|
121
137
|
exports.ValueErrorIterator = ValueErrorIterator;
|
|
122
138
|
// --------------------------------------------------------------------------
|
|
123
|
-
//
|
|
124
|
-
// --------------------------------------------------------------------------
|
|
125
|
-
class ValueErrorsUnknownTypeError extends Error {
|
|
126
|
-
constructor(schema) {
|
|
127
|
-
super('ValueErrors: Unknown type');
|
|
128
|
-
this.schema = schema;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.ValueErrorsUnknownTypeError = ValueErrorsUnknownTypeError;
|
|
132
|
-
class ValueErrorsDereferenceError extends Error {
|
|
133
|
-
constructor(schema) {
|
|
134
|
-
super(`ValueErrors: Unable to dereference type with $id '${schema.$ref}'`);
|
|
135
|
-
this.schema = schema;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
exports.ValueErrorsDereferenceError = ValueErrorsDereferenceError;
|
|
139
|
-
// --------------------------------------------------------------------------
|
|
140
|
-
// Guards
|
|
141
|
-
// --------------------------------------------------------------------------
|
|
142
|
-
function IsDefined(value) {
|
|
143
|
-
return value !== undefined;
|
|
144
|
-
}
|
|
145
|
-
// --------------------------------------------------------------------------
|
|
146
|
-
// Policies
|
|
139
|
+
// Create
|
|
147
140
|
// --------------------------------------------------------------------------
|
|
148
|
-
function
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
function IsObject(value) {
|
|
152
|
-
const isObject = ValueGuard.IsObject(value);
|
|
153
|
-
return index_1.TypeSystem.AllowArrayObjects ? isObject : isObject && !ValueGuard.IsArray(value);
|
|
154
|
-
}
|
|
155
|
-
function IsRecordObject(value) {
|
|
156
|
-
return IsObject(value) && !(value instanceof Date) && !(value instanceof Uint8Array);
|
|
157
|
-
}
|
|
158
|
-
function IsNumber(value) {
|
|
159
|
-
const isNumber = ValueGuard.IsNumber(value);
|
|
160
|
-
return index_1.TypeSystem.AllowNaN ? isNumber : isNumber && Number.isFinite(value);
|
|
161
|
-
}
|
|
162
|
-
function IsVoid(value) {
|
|
163
|
-
const isUndefined = ValueGuard.IsUndefined(value);
|
|
164
|
-
return index_1.TypeSystem.AllowVoidNull ? isUndefined || value === null : isUndefined;
|
|
141
|
+
function Create(type, schema, path, value) {
|
|
142
|
+
return { type, schema, path, value, message: system_1.TypeSystemErrorFunction.Get()(schema, type) };
|
|
165
143
|
}
|
|
166
144
|
// --------------------------------------------------------------------------
|
|
167
145
|
// Types
|
|
168
146
|
// --------------------------------------------------------------------------
|
|
169
147
|
function* TAny(schema, references, path, value) { }
|
|
170
148
|
function* TArray(schema, references, path, value) {
|
|
171
|
-
if (!
|
|
172
|
-
return yield
|
|
149
|
+
if (!(0, guard_1.IsArray)(value)) {
|
|
150
|
+
return yield Create(ValueErrorType.Array, schema, path, value);
|
|
173
151
|
}
|
|
174
152
|
if (IsDefined(schema.minItems) && !(value.length >= schema.minItems)) {
|
|
175
|
-
yield
|
|
153
|
+
yield Create(ValueErrorType.ArrayMinItems, schema, path, value);
|
|
176
154
|
}
|
|
177
155
|
if (IsDefined(schema.maxItems) && !(value.length <= schema.maxItems)) {
|
|
178
|
-
yield
|
|
156
|
+
yield Create(ValueErrorType.ArrayMaxItems, schema, path, value);
|
|
179
157
|
}
|
|
180
158
|
for (let i = 0; i < value.length; i++) {
|
|
181
159
|
yield* Visit(schema.items, references, `${path}/${i}`, value[i]);
|
|
182
160
|
}
|
|
183
161
|
// prettier-ignore
|
|
184
162
|
if (schema.uniqueItems === true && !((function () { const set = new Set(); for (const element of value) {
|
|
185
|
-
const hashed =
|
|
163
|
+
const hashed = (0, hash_1.Hash)(element);
|
|
186
164
|
if (set.has(hashed)) {
|
|
187
165
|
return false;
|
|
188
166
|
}
|
|
@@ -190,116 +168,109 @@ function* TArray(schema, references, path, value) {
|
|
|
190
168
|
set.add(hashed);
|
|
191
169
|
}
|
|
192
170
|
} return true; })())) {
|
|
193
|
-
yield
|
|
171
|
+
yield Create(ValueErrorType.ArrayUniqueItems, schema, path, value);
|
|
194
172
|
}
|
|
195
173
|
// contains
|
|
196
|
-
if (!(IsDefined(schema.contains) ||
|
|
174
|
+
if (!(IsDefined(schema.contains) || IsDefined(schema.minContains) || IsDefined(schema.maxContains))) {
|
|
197
175
|
return;
|
|
198
176
|
}
|
|
199
177
|
const containsSchema = IsDefined(schema.contains) ? schema.contains : Types.Type.Never();
|
|
200
178
|
const containsCount = value.reduce((acc, value, index) => (Visit(containsSchema, references, `${path}${index}`, value).next().done === true ? acc + 1 : acc), 0);
|
|
201
179
|
if (containsCount === 0) {
|
|
202
|
-
yield
|
|
180
|
+
yield Create(ValueErrorType.ArrayContains, schema, path, value);
|
|
203
181
|
}
|
|
204
|
-
if (
|
|
205
|
-
yield
|
|
182
|
+
if ((0, guard_1.IsNumber)(schema.minContains) && containsCount < schema.minContains) {
|
|
183
|
+
yield Create(ValueErrorType.ArrayMinContains, schema, path, value);
|
|
206
184
|
}
|
|
207
|
-
if (
|
|
208
|
-
yield
|
|
185
|
+
if ((0, guard_1.IsNumber)(schema.maxContains) && containsCount > schema.maxContains) {
|
|
186
|
+
yield Create(ValueErrorType.ArrayMaxContains, schema, path, value);
|
|
209
187
|
}
|
|
210
188
|
}
|
|
211
189
|
function* TAsyncIterator(schema, references, path, value) {
|
|
212
|
-
if (!
|
|
213
|
-
yield
|
|
214
|
-
}
|
|
190
|
+
if (!(0, guard_1.IsAsyncIterator)(value))
|
|
191
|
+
yield Create(ValueErrorType.AsyncIterator, schema, path, value);
|
|
215
192
|
}
|
|
216
193
|
function* TBigInt(schema, references, path, value) {
|
|
217
|
-
if (!
|
|
218
|
-
return yield
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
yield { type: ValueErrorType.BigIntMultipleOf, schema, path, value, message: `Expected bigint to be a multiple of ${schema.multipleOf}` };
|
|
194
|
+
if (!(0, guard_1.IsBigInt)(value))
|
|
195
|
+
return yield Create(ValueErrorType.BigInt, schema, path, value);
|
|
196
|
+
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
197
|
+
yield Create(ValueErrorType.BigIntExclusiveMaximum, schema, path, value);
|
|
222
198
|
}
|
|
223
199
|
if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
224
|
-
yield
|
|
200
|
+
yield Create(ValueErrorType.BigIntExclusiveMinimum, schema, path, value);
|
|
225
201
|
}
|
|
226
|
-
if (IsDefined(schema.
|
|
227
|
-
yield
|
|
202
|
+
if (IsDefined(schema.maximum) && !(value <= schema.maximum)) {
|
|
203
|
+
yield Create(ValueErrorType.BigIntMaximum, schema, path, value);
|
|
228
204
|
}
|
|
229
205
|
if (IsDefined(schema.minimum) && !(value >= schema.minimum)) {
|
|
230
|
-
yield
|
|
206
|
+
yield Create(ValueErrorType.BigIntMinimum, schema, path, value);
|
|
231
207
|
}
|
|
232
|
-
if (IsDefined(schema.
|
|
233
|
-
yield
|
|
208
|
+
if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === BigInt(0))) {
|
|
209
|
+
yield Create(ValueErrorType.BigIntMultipleOf, schema, path, value);
|
|
234
210
|
}
|
|
235
211
|
}
|
|
236
212
|
function* TBoolean(schema, references, path, value) {
|
|
237
|
-
if (!
|
|
238
|
-
|
|
239
|
-
}
|
|
213
|
+
if (!(0, guard_1.IsBoolean)(value))
|
|
214
|
+
yield Create(ValueErrorType.Boolean, schema, path, value);
|
|
240
215
|
}
|
|
241
216
|
function* TConstructor(schema, references, path, value) {
|
|
242
217
|
yield* Visit(schema.returns, references, path, value.prototype);
|
|
243
218
|
}
|
|
244
219
|
function* TDate(schema, references, path, value) {
|
|
245
|
-
if (!
|
|
246
|
-
return yield
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return yield { type: ValueErrorType.Date, schema, path, value, message: `Invalid Date` };
|
|
220
|
+
if (!(0, guard_1.IsDate)(value))
|
|
221
|
+
return yield Create(ValueErrorType.Date, schema, path, value);
|
|
222
|
+
if (IsDefined(schema.exclusiveMaximumTimestamp) && !(value.getTime() < schema.exclusiveMaximumTimestamp)) {
|
|
223
|
+
yield Create(ValueErrorType.DateExclusiveMaximumTimestamp, schema, path, value);
|
|
250
224
|
}
|
|
251
225
|
if (IsDefined(schema.exclusiveMinimumTimestamp) && !(value.getTime() > schema.exclusiveMinimumTimestamp)) {
|
|
252
|
-
yield
|
|
226
|
+
yield Create(ValueErrorType.DateExclusiveMinimumTimestamp, schema, path, value);
|
|
253
227
|
}
|
|
254
|
-
if (IsDefined(schema.
|
|
255
|
-
yield
|
|
228
|
+
if (IsDefined(schema.maximumTimestamp) && !(value.getTime() <= schema.maximumTimestamp)) {
|
|
229
|
+
yield Create(ValueErrorType.DateMaximumTimestamp, schema, path, value);
|
|
256
230
|
}
|
|
257
231
|
if (IsDefined(schema.minimumTimestamp) && !(value.getTime() >= schema.minimumTimestamp)) {
|
|
258
|
-
yield
|
|
232
|
+
yield Create(ValueErrorType.DateMinimumTimestamp, schema, path, value);
|
|
259
233
|
}
|
|
260
|
-
if (IsDefined(schema.
|
|
261
|
-
yield
|
|
234
|
+
if (IsDefined(schema.multipleOfTimestamp) && !(value.getTime() % schema.multipleOfTimestamp === 0)) {
|
|
235
|
+
yield Create(ValueErrorType.DateMultipleOfTimestamp, schema, path, value);
|
|
262
236
|
}
|
|
263
237
|
}
|
|
264
238
|
function* TFunction(schema, references, path, value) {
|
|
265
|
-
if (!
|
|
266
|
-
|
|
267
|
-
}
|
|
239
|
+
if (!(0, guard_1.IsFunction)(value))
|
|
240
|
+
yield Create(ValueErrorType.Function, schema, path, value);
|
|
268
241
|
}
|
|
269
242
|
function* TInteger(schema, references, path, value) {
|
|
270
|
-
if (!
|
|
271
|
-
return yield
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
yield { type: ValueErrorType.IntegerMultipleOf, schema, path, value, message: `Expected integer to be a multiple of ${schema.multipleOf}` };
|
|
243
|
+
if (!(0, guard_1.IsInteger)(value))
|
|
244
|
+
return yield Create(ValueErrorType.Integer, schema, path, value);
|
|
245
|
+
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
246
|
+
yield Create(ValueErrorType.IntegerExclusiveMaximum, schema, path, value);
|
|
275
247
|
}
|
|
276
248
|
if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
277
|
-
yield
|
|
249
|
+
yield Create(ValueErrorType.IntegerExclusiveMinimum, schema, path, value);
|
|
278
250
|
}
|
|
279
|
-
if (IsDefined(schema.
|
|
280
|
-
yield
|
|
251
|
+
if (IsDefined(schema.maximum) && !(value <= schema.maximum)) {
|
|
252
|
+
yield Create(ValueErrorType.IntegerMaximum, schema, path, value);
|
|
281
253
|
}
|
|
282
254
|
if (IsDefined(schema.minimum) && !(value >= schema.minimum)) {
|
|
283
|
-
yield
|
|
255
|
+
yield Create(ValueErrorType.IntegerMinimum, schema, path, value);
|
|
284
256
|
}
|
|
285
|
-
if (IsDefined(schema.
|
|
286
|
-
yield
|
|
257
|
+
if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
|
|
258
|
+
yield Create(ValueErrorType.IntegerMultipleOf, schema, path, value);
|
|
287
259
|
}
|
|
288
260
|
}
|
|
289
261
|
function* TIntersect(schema, references, path, value) {
|
|
290
262
|
for (const inner of schema.allOf) {
|
|
291
263
|
const next = Visit(inner, references, path, value).next();
|
|
292
264
|
if (!next.done) {
|
|
265
|
+
yield Create(ValueErrorType.Intersect, schema, path, value);
|
|
293
266
|
yield next.value;
|
|
294
|
-
yield { type: ValueErrorType.Intersect, schema, path, value, message: `Expected all sub schemas to be valid` };
|
|
295
|
-
return;
|
|
296
267
|
}
|
|
297
268
|
}
|
|
298
269
|
if (schema.unevaluatedProperties === false) {
|
|
299
270
|
const keyCheck = new RegExp(Types.KeyResolver.ResolvePattern(schema));
|
|
300
271
|
for (const valueKey of Object.getOwnPropertyNames(value)) {
|
|
301
272
|
if (!keyCheck.test(valueKey)) {
|
|
302
|
-
yield
|
|
273
|
+
yield Create(ValueErrorType.IntersectUnevaluatedProperties, schema, `${path}/${valueKey}`, value);
|
|
303
274
|
}
|
|
304
275
|
}
|
|
305
276
|
}
|
|
@@ -308,95 +279,71 @@ function* TIntersect(schema, references, path, value) {
|
|
|
308
279
|
for (const valueKey of Object.getOwnPropertyNames(value)) {
|
|
309
280
|
if (!keyCheck.test(valueKey)) {
|
|
310
281
|
const next = Visit(schema.unevaluatedProperties, references, `${path}/${valueKey}`, value[valueKey]).next();
|
|
311
|
-
if (!next.done)
|
|
312
|
-
yield next.value;
|
|
313
|
-
yield { type: ValueErrorType.IntersectUnevaluatedProperties, schema, path: `${path}/${valueKey}`, value, message: `Invalid additional property` };
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
282
|
+
if (!next.done)
|
|
283
|
+
yield next.value; // yield interior
|
|
316
284
|
}
|
|
317
285
|
}
|
|
318
286
|
}
|
|
319
287
|
}
|
|
320
288
|
function* TIterator(schema, references, path, value) {
|
|
321
|
-
if (!(
|
|
322
|
-
yield
|
|
323
|
-
}
|
|
289
|
+
if (!(0, guard_1.IsIterator)(value))
|
|
290
|
+
yield Create(ValueErrorType.Iterator, schema, path, value);
|
|
324
291
|
}
|
|
325
292
|
function* TLiteral(schema, references, path, value) {
|
|
326
|
-
if (!(value === schema.const))
|
|
327
|
-
|
|
328
|
-
return yield { type: ValueErrorType.Literal, schema, path, value, message: `Expected ${error}` };
|
|
329
|
-
}
|
|
293
|
+
if (!(value === schema.const))
|
|
294
|
+
yield Create(ValueErrorType.Literal, schema, path, value);
|
|
330
295
|
}
|
|
331
296
|
function* TNever(schema, references, path, value) {
|
|
332
|
-
yield
|
|
297
|
+
yield Create(ValueErrorType.Never, schema, path, value);
|
|
333
298
|
}
|
|
334
299
|
function* TNot(schema, references, path, value) {
|
|
335
|
-
if (Visit(schema.not, references, path, value).next().done === true)
|
|
336
|
-
yield
|
|
337
|
-
}
|
|
300
|
+
if (Visit(schema.not, references, path, value).next().done === true)
|
|
301
|
+
yield Create(ValueErrorType.Not, schema, path, value);
|
|
338
302
|
}
|
|
339
303
|
function* TNull(schema, references, path, value) {
|
|
340
|
-
if (!
|
|
341
|
-
|
|
342
|
-
}
|
|
304
|
+
if (!(0, guard_1.IsNull)(value))
|
|
305
|
+
yield Create(ValueErrorType.Null, schema, path, value);
|
|
343
306
|
}
|
|
344
307
|
function* TNumber(schema, references, path, value) {
|
|
345
|
-
if (!
|
|
346
|
-
return yield
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
yield { type: ValueErrorType.NumberMultipleOf, schema, path, value, message: `Expected number to be a multiple of ${schema.multipleOf}` };
|
|
308
|
+
if (!system_1.TypeSystemPolicy.IsNumberLike(value))
|
|
309
|
+
return yield Create(ValueErrorType.Number, schema, path, value);
|
|
310
|
+
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
311
|
+
yield Create(ValueErrorType.NumberExclusiveMaximum, schema, path, value);
|
|
350
312
|
}
|
|
351
313
|
if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
352
|
-
yield
|
|
314
|
+
yield Create(ValueErrorType.NumberExclusiveMinimum, schema, path, value);
|
|
353
315
|
}
|
|
354
|
-
if (IsDefined(schema.
|
|
355
|
-
yield
|
|
316
|
+
if (IsDefined(schema.maximum) && !(value <= schema.maximum)) {
|
|
317
|
+
yield Create(ValueErrorType.NumberMaximum, schema, path, value);
|
|
356
318
|
}
|
|
357
319
|
if (IsDefined(schema.minimum) && !(value >= schema.minimum)) {
|
|
358
|
-
yield
|
|
320
|
+
yield Create(ValueErrorType.NumberMinimum, schema, path, value);
|
|
359
321
|
}
|
|
360
|
-
if (IsDefined(schema.
|
|
361
|
-
yield
|
|
322
|
+
if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
|
|
323
|
+
yield Create(ValueErrorType.NumberMultipleOf, schema, path, value);
|
|
362
324
|
}
|
|
363
325
|
}
|
|
364
326
|
function* TObject(schema, references, path, value) {
|
|
365
|
-
if (!
|
|
366
|
-
return yield
|
|
367
|
-
}
|
|
327
|
+
if (!system_1.TypeSystemPolicy.IsObjectLike(value))
|
|
328
|
+
return yield Create(ValueErrorType.Object, schema, path, value);
|
|
368
329
|
if (IsDefined(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
369
|
-
yield
|
|
330
|
+
yield Create(ValueErrorType.ObjectMinProperties, schema, path, value);
|
|
370
331
|
}
|
|
371
332
|
if (IsDefined(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
|
|
372
|
-
yield
|
|
333
|
+
yield Create(ValueErrorType.ObjectMaxProperties, schema, path, value);
|
|
373
334
|
}
|
|
374
335
|
const requiredKeys = Array.isArray(schema.required) ? schema.required : [];
|
|
375
336
|
const knownKeys = Object.getOwnPropertyNames(schema.properties);
|
|
376
337
|
const unknownKeys = Object.getOwnPropertyNames(value);
|
|
377
|
-
for (const knownKey of knownKeys) {
|
|
378
|
-
const property = schema.properties[knownKey];
|
|
379
|
-
if (schema.required && schema.required.includes(knownKey)) {
|
|
380
|
-
yield* Visit(property, references, `${path}/${knownKey}`, value[knownKey]);
|
|
381
|
-
if (Types.ExtendsUndefined.Check(schema) && !(knownKey in value)) {
|
|
382
|
-
yield { type: ValueErrorType.ObjectRequiredProperties, schema: property, path: `${path}/${knownKey}`, value: undefined, message: `Expected required property` };
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
else {
|
|
386
|
-
if (IsExactOptionalProperty(value, knownKey)) {
|
|
387
|
-
yield* Visit(property, references, `${path}/${knownKey}`, value[knownKey]);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
338
|
for (const requiredKey of requiredKeys) {
|
|
392
339
|
if (unknownKeys.includes(requiredKey))
|
|
393
340
|
continue;
|
|
394
|
-
yield
|
|
341
|
+
yield Create(ValueErrorType.ObjectRequiredProperty, schema.properties[requiredKey], `${path}/${requiredKey}`, undefined);
|
|
395
342
|
}
|
|
396
343
|
if (schema.additionalProperties === false) {
|
|
397
344
|
for (const valueKey of unknownKeys) {
|
|
398
345
|
if (!knownKeys.includes(valueKey)) {
|
|
399
|
-
yield
|
|
346
|
+
yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path}/${valueKey}`, value[valueKey]);
|
|
400
347
|
}
|
|
401
348
|
}
|
|
402
349
|
}
|
|
@@ -407,104 +354,107 @@ function* TObject(schema, references, path, value) {
|
|
|
407
354
|
yield* Visit(schema.additionalProperties, references, `${path}/${valueKey}`, value[valueKey]);
|
|
408
355
|
}
|
|
409
356
|
}
|
|
357
|
+
for (const knownKey of knownKeys) {
|
|
358
|
+
const property = schema.properties[knownKey];
|
|
359
|
+
if (schema.required && schema.required.includes(knownKey)) {
|
|
360
|
+
yield* Visit(property, references, `${path}/${knownKey}`, value[knownKey]);
|
|
361
|
+
if (Types.ExtendsUndefined.Check(schema) && !(knownKey in value)) {
|
|
362
|
+
yield Create(ValueErrorType.ObjectRequiredProperty, property, `${path}/${knownKey}`, undefined);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
if (system_1.TypeSystemPolicy.IsExactOptionalProperty(value, knownKey)) {
|
|
367
|
+
yield* Visit(property, references, `${path}/${knownKey}`, value[knownKey]);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
410
371
|
}
|
|
411
372
|
function* TPromise(schema, references, path, value) {
|
|
412
|
-
if (!
|
|
413
|
-
yield
|
|
414
|
-
}
|
|
373
|
+
if (!(0, guard_1.IsPromise)(value))
|
|
374
|
+
yield Create(ValueErrorType.Promise, schema, path, value);
|
|
415
375
|
}
|
|
416
376
|
function* TRecord(schema, references, path, value) {
|
|
417
|
-
if (!
|
|
418
|
-
return yield
|
|
419
|
-
}
|
|
377
|
+
if (!system_1.TypeSystemPolicy.IsRecordLike(value))
|
|
378
|
+
return yield Create(ValueErrorType.Object, schema, path, value);
|
|
420
379
|
if (IsDefined(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
421
|
-
yield
|
|
380
|
+
yield Create(ValueErrorType.ObjectMinProperties, schema, path, value);
|
|
422
381
|
}
|
|
423
382
|
if (IsDefined(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
|
|
424
|
-
yield
|
|
383
|
+
yield Create(ValueErrorType.ObjectMaxProperties, schema, path, value);
|
|
425
384
|
}
|
|
426
385
|
const [patternKey, patternSchema] = Object.entries(schema.patternProperties)[0];
|
|
427
386
|
const regex = new RegExp(patternKey);
|
|
428
387
|
for (const [propertyKey, propertyValue] of Object.entries(value)) {
|
|
429
|
-
if (regex.test(propertyKey))
|
|
388
|
+
if (regex.test(propertyKey))
|
|
430
389
|
yield* Visit(patternSchema, references, `${path}/${propertyKey}`, propertyValue);
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
390
|
+
}
|
|
391
|
+
if (typeof schema.additionalProperties === 'object') {
|
|
392
|
+
for (const [propertyKey, propertyValue] of Object.entries(value)) {
|
|
393
|
+
if (!regex.test(propertyKey))
|
|
394
|
+
yield* Visit(schema.additionalProperties, references, `${path}/${propertyKey}`, propertyValue);
|
|
435
395
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
396
|
+
}
|
|
397
|
+
if (schema.additionalProperties === false) {
|
|
398
|
+
for (const [propertyKey, propertyValue] of Object.entries(value)) {
|
|
399
|
+
if (regex.test(propertyKey))
|
|
400
|
+
continue;
|
|
401
|
+
return yield Create(ValueErrorType.ObjectAdditionalProperties, schema, `${path}/${propertyKey}`, propertyValue);
|
|
440
402
|
}
|
|
441
403
|
}
|
|
442
404
|
}
|
|
443
405
|
function* TRef(schema, references, path, value) {
|
|
444
|
-
|
|
445
|
-
if (index === -1)
|
|
446
|
-
throw new ValueErrorsDereferenceError(schema);
|
|
447
|
-
const target = references[index];
|
|
448
|
-
yield* Visit(target, references, path, value);
|
|
406
|
+
yield* Visit((0, deref_1.Deref)(schema, references), references, path, value);
|
|
449
407
|
}
|
|
450
408
|
function* TString(schema, references, path, value) {
|
|
451
|
-
if (!
|
|
452
|
-
return yield
|
|
453
|
-
}
|
|
409
|
+
if (!(0, guard_1.IsString)(value))
|
|
410
|
+
return yield Create(ValueErrorType.String, schema, path, value);
|
|
454
411
|
if (IsDefined(schema.minLength) && !(value.length >= schema.minLength)) {
|
|
455
|
-
yield
|
|
412
|
+
yield Create(ValueErrorType.StringMinLength, schema, path, value);
|
|
456
413
|
}
|
|
457
414
|
if (IsDefined(schema.maxLength) && !(value.length <= schema.maxLength)) {
|
|
458
|
-
yield
|
|
415
|
+
yield Create(ValueErrorType.StringMaxLength, schema, path, value);
|
|
459
416
|
}
|
|
460
|
-
if (
|
|
417
|
+
if ((0, guard_1.IsString)(schema.pattern)) {
|
|
461
418
|
const regex = new RegExp(schema.pattern);
|
|
462
419
|
if (!regex.test(value)) {
|
|
463
|
-
yield
|
|
420
|
+
yield Create(ValueErrorType.StringPattern, schema, path, value);
|
|
464
421
|
}
|
|
465
422
|
}
|
|
466
|
-
if (
|
|
423
|
+
if ((0, guard_1.IsString)(schema.format)) {
|
|
467
424
|
if (!Types.FormatRegistry.Has(schema.format)) {
|
|
468
|
-
yield
|
|
425
|
+
yield Create(ValueErrorType.StringFormatUnknown, schema, path, value);
|
|
469
426
|
}
|
|
470
427
|
else {
|
|
471
428
|
const format = Types.FormatRegistry.Get(schema.format);
|
|
472
429
|
if (!format(value)) {
|
|
473
|
-
yield
|
|
430
|
+
yield Create(ValueErrorType.StringFormat, schema, path, value);
|
|
474
431
|
}
|
|
475
432
|
}
|
|
476
433
|
}
|
|
477
434
|
}
|
|
478
435
|
function* TSymbol(schema, references, path, value) {
|
|
479
|
-
if (!
|
|
480
|
-
|
|
481
|
-
}
|
|
436
|
+
if (!(0, guard_1.IsSymbol)(value))
|
|
437
|
+
yield Create(ValueErrorType.Symbol, schema, path, value);
|
|
482
438
|
}
|
|
483
439
|
function* TTemplateLiteral(schema, references, path, value) {
|
|
484
|
-
if (!
|
|
485
|
-
return yield
|
|
486
|
-
}
|
|
440
|
+
if (!(0, guard_1.IsString)(value))
|
|
441
|
+
return yield Create(ValueErrorType.String, schema, path, value);
|
|
487
442
|
const regex = new RegExp(schema.pattern);
|
|
488
443
|
if (!regex.test(value)) {
|
|
489
|
-
yield
|
|
444
|
+
yield Create(ValueErrorType.StringPattern, schema, path, value);
|
|
490
445
|
}
|
|
491
446
|
}
|
|
492
447
|
function* TThis(schema, references, path, value) {
|
|
493
|
-
|
|
494
|
-
if (index === -1)
|
|
495
|
-
throw new ValueErrorsDereferenceError(schema);
|
|
496
|
-
const target = references[index];
|
|
497
|
-
yield* Visit(target, references, path, value);
|
|
448
|
+
yield* Visit((0, deref_1.Deref)(schema, references), references, path, value);
|
|
498
449
|
}
|
|
499
450
|
function* TTuple(schema, references, path, value) {
|
|
500
|
-
if (!
|
|
501
|
-
return yield
|
|
502
|
-
}
|
|
451
|
+
if (!(0, guard_1.IsArray)(value))
|
|
452
|
+
return yield Create(ValueErrorType.Tuple, schema, path, value);
|
|
503
453
|
if (schema.items === undefined && !(value.length === 0)) {
|
|
504
|
-
return yield
|
|
454
|
+
return yield Create(ValueErrorType.TupleLength, schema, path, value);
|
|
505
455
|
}
|
|
506
456
|
if (!(value.length === schema.maxItems)) {
|
|
507
|
-
yield
|
|
457
|
+
return yield Create(ValueErrorType.TupleLength, schema, path, value);
|
|
508
458
|
}
|
|
509
459
|
if (!schema.items) {
|
|
510
460
|
return;
|
|
@@ -514,47 +464,40 @@ function* TTuple(schema, references, path, value) {
|
|
|
514
464
|
}
|
|
515
465
|
}
|
|
516
466
|
function* TUndefined(schema, references, path, value) {
|
|
517
|
-
if (!(
|
|
518
|
-
yield
|
|
519
|
-
}
|
|
467
|
+
if (!(0, guard_1.IsUndefined)(value))
|
|
468
|
+
yield Create(ValueErrorType.Undefined, schema, path, value);
|
|
520
469
|
}
|
|
521
470
|
function* TUnion(schema, references, path, value) {
|
|
522
|
-
|
|
523
|
-
for (const
|
|
524
|
-
const
|
|
525
|
-
if (
|
|
526
|
-
return;
|
|
527
|
-
errors.
|
|
528
|
-
}
|
|
529
|
-
if (errors.length > 0) {
|
|
530
|
-
yield { type: ValueErrorType.Union, schema, path, value, message: 'Expected value of union' };
|
|
471
|
+
let count = 0;
|
|
472
|
+
for (const subschema of schema.anyOf) {
|
|
473
|
+
const errors = [...Visit(subschema, references, path, value)];
|
|
474
|
+
if (errors.length === 0)
|
|
475
|
+
return; // matched
|
|
476
|
+
count += errors.length;
|
|
531
477
|
}
|
|
532
|
-
|
|
533
|
-
yield
|
|
478
|
+
if (count > 0) {
|
|
479
|
+
yield Create(ValueErrorType.Union, schema, path, value);
|
|
534
480
|
}
|
|
535
481
|
}
|
|
536
482
|
function* TUint8Array(schema, references, path, value) {
|
|
537
|
-
if (!
|
|
538
|
-
return yield
|
|
539
|
-
}
|
|
483
|
+
if (!(0, guard_1.IsUint8Array)(value))
|
|
484
|
+
return yield Create(ValueErrorType.Uint8Array, schema, path, value);
|
|
540
485
|
if (IsDefined(schema.maxByteLength) && !(value.length <= schema.maxByteLength)) {
|
|
541
|
-
yield
|
|
486
|
+
yield Create(ValueErrorType.Uint8ArrayMaxByteLength, schema, path, value);
|
|
542
487
|
}
|
|
543
488
|
if (IsDefined(schema.minByteLength) && !(value.length >= schema.minByteLength)) {
|
|
544
|
-
yield
|
|
489
|
+
yield Create(ValueErrorType.Uint8ArrayMinByteLength, schema, path, value);
|
|
545
490
|
}
|
|
546
491
|
}
|
|
547
492
|
function* TUnknown(schema, references, path, value) { }
|
|
548
493
|
function* TVoid(schema, references, path, value) {
|
|
549
|
-
if (!
|
|
550
|
-
|
|
551
|
-
}
|
|
494
|
+
if (!system_1.TypeSystemPolicy.IsVoidLike(value))
|
|
495
|
+
yield Create(ValueErrorType.Void, schema, path, value);
|
|
552
496
|
}
|
|
553
497
|
function* TKind(schema, references, path, value) {
|
|
554
498
|
const check = Types.TypeRegistry.Get(schema[Types.Kind]);
|
|
555
|
-
if (!check(schema, value))
|
|
556
|
-
|
|
557
|
-
}
|
|
499
|
+
if (!check(schema, value))
|
|
500
|
+
yield Create(ValueErrorType.Kind, schema, path, value);
|
|
558
501
|
}
|
|
559
502
|
function* Visit(schema, references, path, value) {
|
|
560
503
|
const references_ = IsDefined(schema.$id) ? [...references, schema] : references;
|