isNullableNumberSchema
Determines whether a given JSON schema represents a nullable number type.
Validates that the schema's type property is an array containing both
'number' (or 'integer') and 'null', indicating it describes nullable numeric values.
Signature
const isNullableNumberSchema: (schema: UnknownSchema) => schema is NullableNumberSchema
Parameters
| Name | Type | Description |
|---|---|---|
schema | - | The JSON schema object to inspect |
Returns
Type-safe boolean indicating whether the schema is a NullableNumberSchema
Examples
Example 1
isNullableNumberSchema({ type: ['number', 'null'] }); // true
isNullableNumberSchema({ type: ['integer', 'null'] }); // true
isNullableNumberSchema({ type: 'number' }); // false
isNullableNumberSchema({ type: ['string', 'null'] }); // false
Playground
isNullableNumberSchema({ type: ['number', 'null'] }); // true isNullableNumberSchema({ type: ['integer', 'null'] }); // true isNullableNumberSchema({ type: 'number' }); // false isNullableNumberSchema({ type: ['string', 'null'] }); // false