Skip to main content

isNonNullableStringSchema

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

Signature

const isNonNullableStringSchema: (schema: UnknownSchema) => schema is NonNullableStringSchema

Parameters

NameTypeDescription
schema-The JSON schema object to inspect

Returns

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

Examples

Example 1

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

Playground

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