@sinclair/typebox 0.28.21 → 0.28.22
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
|
@@ -342,7 +342,7 @@ var TypeCompiler;
|
|
|
342
342
|
if (IsNumber(schema.maxProperties))
|
|
343
343
|
yield `Object.getOwnPropertyNames(${value}).length <= ${schema.maxProperties}`;
|
|
344
344
|
const [patternKey, patternSchema] = globalThis.Object.entries(schema.patternProperties)[0];
|
|
345
|
-
const local = PushLocal(
|
|
345
|
+
const local = PushLocal(`${new RegExp(patternKey)}`);
|
|
346
346
|
const check1 = CreateExpression(patternSchema, references, 'value');
|
|
347
347
|
const check2 = Types.TypeGuard.TSchema(schema.additionalProperties) ? CreateExpression(schema.additionalProperties, references, value) : schema.additionalProperties === false ? 'false' : 'true';
|
|
348
348
|
const expression = `(${local}.test(key) ? ${check1} : ${check2})`;
|
|
@@ -390,6 +390,8 @@ var TypeCompiler;
|
|
|
390
390
|
yield `Array.isArray(${value})`;
|
|
391
391
|
if (schema.items === undefined)
|
|
392
392
|
return yield `${value}.length === 0`;
|
|
393
|
+
if (!IsNumber(schema.maxItems))
|
|
394
|
+
throw Error('MaxItems: Not a Number');
|
|
393
395
|
yield `(${value}.length === ${schema.maxItems})`;
|
|
394
396
|
for (let i = 0; i < schema.items.length; i++) {
|
|
395
397
|
const expression = CreateExpression(schema.items[i], references, `${value}[${i}]`);
|