Skip to main content

isArraySchema

Determines whether a given JSON schema represents an array type (nullable or non-nullable). This is a combined filter that matches both { type: 'array' } and { type: ['array', 'null'] } schemas.

Signature​

const isArraySchema: (schema: UnknownSchema) => schema is ArraySchema

Parameters​

NameTypeDescription
schema-The JSON schema object to inspect

Returns​

Type-safe boolean indicating whether the schema is an array schema (nullable or not)

Examples​

Example 1​

isArraySchema({ type: 'array', items: { type: 'string' } }); // true
isArraySchema({ type: ['array', 'null'] }); // true
isArraySchema({ type: 'object' }); // false

Playground​

isArraySchema({ type: 'array', items: { type: 'string' } }); // true
isArraySchema({ type: ['array', 'null'] }); // true
isArraySchema({ type: 'object' }); // false