LessThan
in package
implements
ValidationRule
Validation rule to check if a value is less than a specified threshold.
This class implements the ValidationRule interface and provides functionality to validate that a given value is less than a predefined limit.
Table of Contents
Interfaces
- ValidationRule
- Interface ValidationRule
Properties
Methods
- __construct() : mixed
- message() : string
- Returns the validation error message.
- validate() : bool
- Validates that the value of a given field is less than a specified maximum value.
Properties
$lessThan
private
float
$lessThan
$max
private
float
$max
Methods
__construct()
public
__construct(float $lessThan) : mixed
Parameters
- $lessThan : float
message()
Returns the validation error message.
public
message() : string
Tags
Return values
string —The error message indicating the field must be a number.
validate()
Validates that the value of a given field is less than a specified maximum value.
public
validate(string $field, array<string|int, mixed> $data) : bool
Parameters
- $field : string
-
The name of the field to validate.
- $data : array<string|int, mixed>
-
The data array containing the field to validate.
Return values
bool —Returns true if the field exists in the data array, is numeric, and is less than the maximum value; otherwise, false.