You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The Numericality allows spaces when validating
To Reproduce
Create a field with a Numericality validator. Type "1 " and it will pass
Expected behavior
I would expect this would not pass.
Details
Phalcon version: 5.4.0
PHP Version: 8.2
Additional context
I have a number field in my form, that eventually will be stored in the DB as a number. The input is validated using Numericality, because it must be a number. Something like "1 " or "1 1" passes with Numericality. And then I get an error from the DB because it's not a valid number. So then I would have to write extra logic for it to work.
The text was updated successfully, but these errors were encountered:
@krazzer From what I see in the code the validator removes the spaces from the input and then validates using regex. As such, what you see is correct but not desirable. The code that was added to the validator to remove spaces was because this validator was not working in certain locales.
I can make some modifications to now take into account spaces. The best candidate is to use ctype_digit but that does not take into account periods, so 123.45 will not validate as a number.
I am thinking the long term solution would be to change this validator and split it into a Digits one and then maybe have others that are more specific such as Int or Float.
Describe the bug
The Numericality allows spaces when validating
To Reproduce
Create a field with a Numericality validator. Type "1 " and it will pass
Expected behavior
I would expect this would not pass.
Details
Additional context
I have a number field in my form, that eventually will be stored in the DB as a number. The input is validated using Numericality, because it must be a number. Something like "1 " or "1 1" passes with Numericality. And then I get an error from the DB because it's not a valid number. So then I would have to write extra logic for it to work.
The text was updated successfully, but these errors were encountered: