RangeRule extends AbstractRangeRule
Validates that a numeric value lies between a minimum and a maximum value (inclusive).
The min and max values are provided as parameters.
Example usage:
use oihana\validations\rules\RangeRule;
$rule = new RangeRule();
$rule->fillParameters(['min' => 0, 'max' => 100]);
$rule->check(50); // true
$rule->check(101); // false
When used in a validation array:
'score' => 'range:0,100',
Tags
Table of Contents
Constants
Properties
- $fillableParams : array<string|int, string>
- Parameter names expected by this rule.
- $max : float|int
- Upper numeric bound (inclusive).
- $message : string
- Default error message.
- $min : float|int
- Lower numeric bound (inclusive).
Methods
- check() : bool
- Check if the given value is within the min/max parameters.
- getMax() : float|int
- Gets the maximum bound.
- getMin() : float|int
- Gets the minimum bound.
Constants
MAX
The 'max' parameter.
public
mixed
MAX
= 'max'
MIN
The 'min' parameter.
public
mixed
MIN
= 'min'
Properties
$fillableParams
Parameter names expected by this rule.
protected
array<string|int, string>
$fillableParams
= ['min', 'max']
$max
Upper numeric bound (inclusive).
protected
float|int
$max
$message
Default error message.
protected
string
$message
= 'The :attribute must be between :min and :max.'
$min
Lower numeric bound (inclusive).
protected
float|int
$min
Methods
check()
Check if the given value is within the min/max parameters.
public
check(mixed $value) : bool
Parameters
- $value : mixed
Tags
Return values
boolgetMax()
Gets the maximum bound.
public
getMax() : float|int
Return values
float|intgetMin()
Gets the minimum bound.
public
getMin() : float|int