Skip to main content

isNonNullableObjectSchema

Determines whether a given JSON schema represents a non-nullable object type. Validates that the schema's type property is set to 'object' (not an array of types), indicating it describes non-nullable object values.

Signature

const isNonNullableObjectSchema: (schema: UnknownSchema) => schema is NonNullableObjectSchema

Parameters

NameTypeDescription
schema-The JSON schema object to inspect

Returns

Type-safe boolean indicating whether the schema is a non-nullable ObjectSchema

Examples

Example 1

isNonNullableObjectSchema({ type: 'object', properties: { name: { type: 'string' } } }); // true
isNonNullableObjectSchema({ type: ['object', 'null'] }); // false
isNonNullableObjectSchema({ type: 'array' }); // false

Playground

isNonNullableObjectSchema({ type: 'object', properties: { name: { type: 'string' } } }); // true
isNonNullableObjectSchema({ type: ['object', 'null'] }); // false
isNonNullableObjectSchema({ type: 'array' }); // false