Number
in package
implements
ValidationRule
Class Number
This class implements a validation rule to check if a given field's value is a number.
Table of Contents
Interfaces
- ValidationRule
- Interface ValidationRule
Methods
- message() : string
- Returns the validation error message.
- validate() : bool
- Validates whether the given field in the data array is a number.
Methods
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 whether the given field in the data array is a number.
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 —True if the field exists and its value is numeric, false otherwise.