MaxLength
extends LengthRule
in package
Maximum length validation rule on the code points of the canonical text.
The canonical text of a scalar has no more than the specified number of code points. An array or object value fails.
Tags
Table of Contents
Methods
- validate() : bool
- Validate a value against the checked parameter of the rule.
- accepts() : bool
- Whether the measure is accepted under the parameter.
- holds() : bool
- Whether the value holds under the checked parameter.
- measure() : int|null
- The measure of the value, or null for a value without one.
- parameter() : P
- The checked parameter of the rule.
- within() : bool
- Whether the measure lies within the inclusive range.
Methods
validate()
Validate a value against the checked parameter of the rule.
public
final validate(mixed $value, mixed $param, array<string|int, mixed> $allData, FieldPath $path) : bool
Parameters
- $value : mixed
-
The value to validate
- $param : mixed
-
The rule parameter (e.g., min length, pattern, etc.)
- $allData : array<string|int, mixed>
-
All form data (for cross-field validation)
- $path : FieldPath
-
The data path of the value with the positions of its row keys
Tags
Return values
bool —True if valid, false otherwise
accepts()
Whether the measure is accepted under the parameter.
protected
accepts(int|float $measure, mixed $parameter) : bool
Parameters
- $measure : int|float
- $parameter : mixed
Return values
boolholds()
Whether the value holds under the checked parameter.
protected
final holds(mixed $value, P $parameter) : bool
Parameters
- $value : mixed
- $parameter : P
Return values
boolmeasure()
The measure of the value, or null for a value without one.
protected
final measure(mixed $value) : int|null
Parameters
- $value : mixed
Return values
int|nullparameter()
The checked parameter of the rule.
protected
parameter(mixed $param) : P
Parameters
- $param : mixed
Return values
Pwithin()
Whether the measure lies within the inclusive range.
protected
final static within(int|float $measure, array{int|float, int|float} $range) : bool
Parameters
- $measure : int|float
- $range : array{int|float, int|float}
-
the minimum and the maximum