NumberSchemaDefinition extends AbstractSchemaDefinition
FinalYes
Schema definition for number/integer fields in elicitation requests.
Supports minimum and maximum value constraints.
Tags
Table of Contents
Properties
- $default : int|float|null
- $description : string|null
- $integerOnly : bool
- $maximum : int|float|null
- $minimum : int|float|null
- $title : string
Methods
- __construct() : mixed
- fromArray() : self
- jsonSerialize() : array{type: string, title: string, description?: string, default?: int|float, minimum?: int|float, maximum?: int|float}
- 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.
Properties
$default read-only
public
int|float|null
$default
= null
$description read-only
public
string|null
$description
= null
$integerOnly read-only
public
bool
$integerOnly
= false
$maximum read-only
public
int|float|null
$maximum
= null
$minimum read-only
public
int|float|null
$minimum
= null
$title read-only
public
string
$title
Methods
__construct()
public
__construct(string $title[, bool $integerOnly = false ][, string|null $description = null ][, int|float|null $default = null ][, int|float|null $minimum = null ][, int|float|null $maximum = null ]) : mixed
Parameters
- $title : string
-
Human-readable title for the field
- $integerOnly : bool = false
-
Whether to restrict to integer values only
- $description : string|null = null
-
Optional description/help text
- $default : int|float|null = null
-
Optional default value
- $minimum : int|float|null = null
-
Optional minimum value (inclusive)
- $maximum : int|float|null = null
-
Optional maximum value (inclusive)
fromArray()
public
static fromArray(array{type: string, title: string, description?: string, default?: int|float, minimum?: int|float, maximum?: int|float} $data) : self
Parameters
- $data : array{type: string, title: string, description?: string, default?: int|float, minimum?: int|float, maximum?: int|float}
Return values
selfjsonSerialize()
public
jsonSerialize() : array{type: string, title: string, description?: string, default?: int|float, minimum?: int|float, maximum?: int|float}
Return values
array{type: string, title: string, description?: string, default?: int|float, minimum?: int|float, maximum?: int|float}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