LengthRule
extends MeasuredRule
in package
AbstractYes
A rule on the length of the canonical text of the value in code points, which is its measure: an array or object value has none.
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
abstract accepts(int|float $measure, P $parameter) : bool
Parameters
- $measure : int|float
- $parameter : P
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
abstract parameter(mixed $param) : P
Parameters
- $param : mixed
Tags
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