AtLeast

AtLeast - Value is at least equal to provided number.

AtLeast only works with int and float, any other type is ignored.

Basic usage

use Jawira\Sanitizer\Filters as Sanitizer;

class Motorcycle {
  #[Sanitizer\AtLeast(number: 2)]
  public int $wheels;
}

Parameters

int|float number (optional):
The property value will be compared against this number, if value is less than provided number then this number will be used instead.
Default value is 0.

Examples

Value must be positive or zero.

use Jawira\Sanitizer\Filters as Sanitizer;

class Post {
  #[Sanitizer\AtLeast]
  public int $likes;
}
0 → 0
10 → 10
-5 → 5

Value must be greater or equal than -273.15.

use Jawira\Sanitizer\Filters as Sanitizer;

class Chemical {
  #[Sanitizer\AtLeast(number: -273.15)]
  public int|float $temperature;
}
53  → 53
-100.50 → -100.50
-3000 → -273.15

See also

AtMost - Value is at most equal to provided number.