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