본문으로 건너뛰기

isNullableBooleanSchema

Determines whether a given JSON schema represents a nullable boolean type. Validates that the schema's type property is an array containing both 'boolean' and 'null', indicating it describes nullable boolean values.

Signature

const isNullableBooleanSchema: (schema: UnknownSchema) => schema is NullableBooleanSchema

Parameters

NameTypeDescription
schema-The JSON schema object to inspect

Returns

Type-safe boolean indicating whether the schema is a NullableBooleanSchema

Examples

Example 1

isNullableBooleanSchema({ type: ['boolean', 'null'] }); // true
isNullableBooleanSchema({ type: 'boolean' }); // false
isNullableBooleanSchema({ type: ['string', 'null'] }); // false

Playground

isNullableBooleanSchema({ type: ['boolean', 'null'] }); // true
isNullableBooleanSchema({ type: 'boolean' }); // false
isNullableBooleanSchema({ type: ['string', 'null'] }); // false