@sinclair/typebox
Advanced tools
@@ -154,2 +154,5 @@ "use strict"; | ||
| } | ||
| function IsNumber(value) { | ||
| return typeof value === 'number' && globalThis.Number.isFinite(value); | ||
| } | ||
| // ------------------------------------------------------------------- | ||
@@ -352,3 +355,3 @@ // Polices | ||
| const [patternKey, patternSchema] = Object.entries(schema.patternProperties)[0]; | ||
| const variable = CreateVariable(`new RegExp(/${patternKey}/)`); | ||
| const variable = CreateVariable(`${new RegExp(patternKey)}`); | ||
| const check1 = CreateExpression(patternSchema, references, 'value'); | ||
@@ -400,2 +403,4 @@ const check2 = Types.TypeGuard.TSchema(schema.additionalProperties) ? CreateExpression(schema.additionalProperties, references, value) : schema.additionalProperties === false ? 'false' : 'true'; | ||
| return yield `${value}.length === 0`; | ||
| if (!IsNumber(schema.maxItems)) | ||
| throw Error('MaxItems: Not a Number'); | ||
| yield `(${value}.length === ${schema.maxItems})`; | ||
@@ -402,0 +407,0 @@ for (let i = 0; i < schema.items.length; i++) { |
+1
-1
| { | ||
| "name": "@sinclair/typebox", | ||
| "version": "0.30.5", | ||
| "version": "0.30.6", | ||
| "description": "JSONSchema Type Builder with Static Type Resolution for TypeScript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
486525
0.04%7941
0.06%