Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Leya's avatar

"If you need to validate the input as being a number please use this rule in combination with the numeric validation rule."

For the integer validation rule in the docs it says:

This validation rule does not verify that the input is of the "integer" variable type, only that the input is of a type accepted by PHP's FILTER_VALIDATE_INT rule. If you need to validate the input as being a number please use this rule in combination with the numeric validation rule.

Can someone explain to me what exactly this means and what I gain by using the numeric rule together with the integer rule?

From how I understand it, adding numeric does nothing because neither guarantee that the value is a number and not just a string representing a number

numeric matches all kinds of numbers and the string representation of those number.

integer matches only whole numbers and string representations of whole numbers,

so effectively integer will just cancel out the broader range of numbers that would pass numeric if used together and behave exactly the same as just using integer, right?

Is there something I don't get, or is the information in the documentation just outdated and wrong?

0 likes
2 replies
Snapey's avatar

consider, is 23E+5 a number? Is it an integer?

is 2.00 an integer ?

What about 1,234? or 1.234 (depends on the locale)

Its not easy. If you want pure integer, try using the number input field with whole number steps, or use a client-side mask to limit what may be entered.

Please or to participate in this conversation.