isObjectSchema
Determines whether a given JSON schema represents an object type (nullable or non-nullable).
This is a combined filter that matches both { type: 'object' } and
{ type: ['object', 'null'] } schemas.
Signature
const isObjectSchema: (schema: UnknownSchema) => schema is ObjectSchema
Parameters
| Name | Type | Description |
|---|---|---|
schema | - | The JSON schema object to inspect |
Returns
Type-safe boolean indicating whether the schema is an object schema (nullable or not)
Examples
Example 1
isObjectSchema({ type: 'object', properties: { name: { type: 'string' } } }); // true
isObjectSchema({ type: ['object', 'null'] }); // true
isObjectSchema({ type: 'array' }); // false
Playground
isObjectSchema({ type: 'object', properties: { name: { type: 'string' } } }); // true isObjectSchema({ type: ['object', 'null'] }); // true isObjectSchema({ type: 'array' }); // false