StringSchemaDefinition extends AbstractSchemaDefinition
FinalYes
Schema definition for string fields in elicitation requests.
Supports optional format validation (date, date-time, email, uri) and length constraints.
Tags
Table of Contents
Constants
- VALID_FORMATS = ['date', 'date-time', 'email', 'uri']
Properties
- $default : string|null
- $description : string|null
- $format : string|null
- $maxLength : int|null
- $minLength : int|null
- $title : string
Methods
- __construct() : mixed
- fromArray() : self
- jsonSerialize() : array{type: string, title: string, description?: string, default?: string, format?: string, minLength?: int, maxLength?: int}
- buildBaseJson() : array<string, mixed>
- Build the base JSON structure with type, title, and optional description.
- validateTitle() : void
- Validate that title exists and is a string in the data array.
Constants
VALID_FORMATS
private
mixed
VALID_FORMATS
= ['date', 'date-time', 'email', 'uri']
Properties
$default read-only
public
string|null
$default
= null
$description read-only
public
string|null
$description
= null
$format read-only
public
string|null
$format
= null
$maxLength read-only
public
int|null
$maxLength
= null
$minLength read-only
public
int|null
$minLength
= null
$title read-only
public
string
$title
Methods
__construct()
public
__construct(string $title[, string|null $description = null ][, string|null $default = null ][, string|null $format = null ][, int|null $minLength = null ][, int|null $maxLength = null ]) : mixed
Parameters
- $title : string
-
Human-readable title for the field
- $description : string|null = null
-
Optional description/help text
- $default : string|null = null
-
Optional default value
- $format : string|null = null
-
Optional format constraint (date, date-time, email, uri)
- $minLength : int|null = null
-
Optional minimum string length
- $maxLength : int|null = null
-
Optional maximum string length
fromArray()
public
static fromArray(array{title: string, description?: string, default?: string, format?: string, minLength?: int, maxLength?: int} $data) : self
Parameters
- $data : array{title: string, description?: string, default?: string, format?: string, minLength?: int, maxLength?: int}
Return values
selfjsonSerialize()
public
jsonSerialize() : array{type: string, title: string, description?: string, default?: string, format?: string, minLength?: int, maxLength?: int}
Return values
array{type: string, title: string, description?: string, default?: string, format?: string, minLength?: int, maxLength?: int}buildBaseJson()
Build the base JSON structure with type, title, and optional description.
protected
buildBaseJson(string $type) : array<string, mixed>
Parameters
- $type : string
Return values
array<string, mixed>validateTitle()
Validate that title exists and is a string in the data array.
protected
static validateTitle(array<string, mixed> $data, string $schemaType) : void
Parameters
- $data : array<string, mixed>
- $schemaType : string