FlagRule
extends ParameterRule
in package
AbstractYes
A rule whose parameter is a boolean flag: the flag false switches the rule off, and with the flag on the rule accepts or rejects the value.
Tags
Table of Contents
Methods
- validate() : bool
- Validate a value against the checked parameter of the rule.
- accepts() : bool
- Whether the rule accepts the value while it is on.
- holds() : bool
- Whether the value holds under the checked parameter.
- name() : string
- The name of the rule in the validation rules, which names the parameter in its error.
- parameter() : P
- The checked parameter of the rule.
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 rule accepts the value while it is on.
protected
abstract accepts(mixed $value) : bool
Parameters
- $value : mixed
Return values
boolholds()
Whether the value holds under the checked parameter.
protected
final holds(mixed $value, bool $parameter) : bool
Parameters
- $value : mixed
- $parameter : bool
Return values
boolname()
The name of the rule in the validation rules, which names the parameter in its error.
protected
abstract name() : string
Return values
stringparameter()
The checked parameter of the rule.
protected
final parameter(mixed $param) : P
Parameters
- $param : mixed