Skip to content

Commit

Permalink
Remove Unused Object Array Check (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 authored Mar 22, 2023
1 parent 5df81a9 commit 5289038
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sinclair/typebox",
"version": "0.26.0",
"version": "0.26.1",
"description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
"keywords": [
"typescript",
Expand Down
1 change: 0 additions & 1 deletion src/compiler/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ export namespace TypeCompiler {

function* Object(schema: Types.TObject, references: Types.TSchema[], value: string): IterableIterator<string> {
yield IsObjectCheck(value)
if (!TypeSystem.AllowArrayObjects) yield `!Array.isArray(${value})`
if (IsNumber(schema.minProperties)) yield `Object.getOwnPropertyNames(${value}).length >= ${schema.minProperties}`
if (IsNumber(schema.maxProperties)) yield `Object.getOwnPropertyNames(${value}).length <= ${schema.maxProperties}`
const schemaKeys = globalThis.Object.getOwnPropertyNames(schema.properties)
Expand Down
4 changes: 2 additions & 2 deletions src/value/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ export namespace ValueCheck {
if (!IsObject(value)) {
return false
}
if (IsNumber(schema.minProperties) && !(globalThis.Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
if (IsDefined<number>(schema.minProperties) && !(globalThis.Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
return false
}
if (IsNumber(schema.maxProperties) && !(globalThis.Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
if (IsDefined<number>(schema.maxProperties) && !(globalThis.Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
return false
}
const knownKeys = globalThis.Object.getOwnPropertyNames(schema.properties)
Expand Down

0 comments on commit 5289038

Please sign in to comment.