@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.
@@ -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(`new RegExp(/${patternKey}/)`);
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}]`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.28.21",
3
+ "version": "0.28.22",
4
4
  "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",