Oihana PHP System

ElevationRule extends AbstractRangeRule

Ensures that a value represents a valid elevation (altitude) in meters.

The elevation must be a numeric value between -11500 (deepest ocean depth) and +8900 (above Mount Everest), inclusive.

Tags
example
use oihana\validations\rules\ElevationRule;

$rule = new ElevationRule();

$rule->check(0);        // true  (sea level)
$rule->check(8848);     // true  (Mount Everest)
$rule->check(-10994);   // true  (Mariana Trench)
$rule->check(-12000);   // false (too deep)
$rule->check(9000);     // false (too high)
$rule->check('foo');    // false
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$max  : float|int
Maximum allowed elevation (in meters).
$message  : string
Custom error message.
$min  : float|int
Minimum allowed elevation (in meters).

Methods

check()  : bool
Check if the given value lies within the defined range.
getMax()  : float|int
Gets the maximum bound.
getMin()  : float|int
Gets the minimum bound.

Properties

$max

Maximum allowed elevation (in meters).

protected float|int $max = 8900

$message

Custom error message.

protected string $message = 'The :attribute must be a valid elevation between -11500 and 8900 meters.'

$min

Minimum allowed elevation (in meters).

protected float|int $min = -11500

Methods

check()

Check if the given value lies within the defined range.

public check(mixed $value) : bool
Parameters
$value : mixed
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