Oihana PHP System

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
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Constants

MAX  = 'max'
The 'max' parameter.
MIN  = 'min'
The 'min' parameter.

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']

$message

Default error message.

protected string $message = 'The :attribute must be between :min and :max.'

Methods

check()

Check if the given value is within the min/max parameters.

public check(mixed $value) : bool
Parameters
$value : mixed
Tags
throws
ParameterException
Return values
bool

getMax()

Gets the maximum bound.

public getMax() : float|int
Return values
float|int

getMin()

Gets the minimum bound.

public getMin() : float|int
Return values
float|int

        
On this page

Search results