\Omega\Validation\Rule IntegerRule

Integer rule class.

The IntegerRule class is responsible for validating whether a given input is a valid integer. It checks if the input is empty and, if not, verifies if it is numeric and if it can be converted to an integer. If the input is empty, it is considered valid.

Summary

Methods
Properties
Constants
validate
getMessage
No public properties found
No public constants found
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Methods

validate()

validate(array  $data, string  $field, string[]  $params) : string|bool

Validate the rule.

Parameters

array $data

Holds array of data.

string $field

Holds the name of the field being validated.

string[] $params

Holds an array of parameters (not used for this rule).

Returns

string|bool —

Returns true if validation is successful (valid integer format), or an error message if the validation fails.

getMessage()

getMessage(array  $data, string  $field, string[]  $params) : string

Get the validation error message.

Parameters

array $data

Holds an array of data.

string $field

Holds the name of the field that failed validation.

string[] $params

Holds an array of parameters (not used for this rule).

Returns

string —

Returns the error message indicating that the field should be in a valid integer format.