ComparisonRule extends Rule
AbstractYes
Base class for numeric comparison rules.
Provides common logic for comparing a field value against another field or a fixed numeric value.
Tags
Table of Contents
Constants
- COMPARISON_FIELD = 'comparison_field'
- The 'comparison_field' parameter.
Properties
- $fillableParams : array<string|int, mixed>
Methods
- check() : bool
- Performs the comparison between the attribute value and the comparison value.
- compare() : bool
- Must be implemented by subclasses to perform the actual comparison.
- getComparisonValue() : mixed
- Get the comparison value from either a field name or a direct value
Constants
COMPARISON_FIELD
The 'comparison_field' parameter.
public
mixed
COMPARISON_FIELD
= 'comparison_field'
Properties
$fillableParams
protected
array<string|int, mixed>
$fillableParams
= [self::COMPARISON_FIELD]
Methods
check()
Performs the comparison between the attribute value and the comparison value.
public
check(mixed $value) : bool
Parameters
- $value : mixed
-
The value of the current attribute being validated.
Tags
Return values
bool —True if the comparison succeeds, false otherwise.
compare()
Must be implemented by subclasses to perform the actual comparison.
protected
abstract compare(float|int $a, float|int $b) : bool
Parameters
- $a : float|int
-
The attribute value.
- $b : float|int
-
The comparison value.
Return values
bool —True if the rule condition is met.
getComparisonValue()
Get the comparison value from either a field name or a direct value
protected
getComparisonValue(string $fieldOrValue) : mixed
Parameters
- $fieldOrValue : string