@sinclair/typebox 0.27.11 → 0.27.12
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.js +3 -1
- package/package.json +1 -1
package/compiler/compiler.js
CHANGED
|
@@ -339,7 +339,7 @@ var TypeCompiler;
|
|
|
339
339
|
if (IsNumber(schema.maxProperties))
|
|
340
340
|
yield `Object.getOwnPropertyNames(${value}).length <= ${schema.maxProperties}`;
|
|
341
341
|
const [keyPattern, valueSchema] = globalThis.Object.entries(schema.patternProperties)[0];
|
|
342
|
-
const local = PushLocal(
|
|
342
|
+
const local = PushLocal(`${new RegExp(keyPattern)}`);
|
|
343
343
|
yield `(Object.getOwnPropertyNames(${value}).every(key => ${local}.test(key)))`;
|
|
344
344
|
const expression = CreateExpression(valueSchema, references, 'value');
|
|
345
345
|
yield `Object.values(${value}).every(value => ${expression})`;
|
|
@@ -386,6 +386,8 @@ var TypeCompiler;
|
|
|
386
386
|
yield `(Array.isArray(${value}))`;
|
|
387
387
|
if (schema.items === undefined)
|
|
388
388
|
return yield `${value}.length === 0`;
|
|
389
|
+
if (!IsNumber(schema.maxItems))
|
|
390
|
+
throw Error('MaxItems: Not a Number');
|
|
389
391
|
yield `(${value}.length === ${schema.maxItems})`;
|
|
390
392
|
for (let i = 0; i < schema.items.length; i++) {
|
|
391
393
|
const expression = CreateExpression(schema.items[i], references, `${value}[${i}]`);
|