-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gte/Lte/Lt/Gt incorrectly treat strings as numeric? #40308
Comments
Hi there, Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels: However, this issue will not be locked and everyone is still free to discuss solutions to your problem! Thanks. |
Hi driesvints, Either the documentation is wrong, or there is a bug.
The problem is that it does not evaluate it the same as the size rule. There is some more logic in the code before it uses the getSize function (and I believe part of the issue is that it checks the type of the parameter, which is always going to be a number, and so it never actually gets to calling getSize). |
Furthermore to this issue, i've managed (finally! :) ) to set up PHP debugging, and i've stepped through the code: I believe that Issue #33711 and #28174 have both contributed to this change in behaviour (and this was commented about in the latter!) The docs should probably be changed to point out that you cannot use these operators (Gt/Gte/Lt/Lte) for string comparisons (at the very least, i've not tested other results). I can't see what i'm doing grossly incorrectly from the docs. |
See PR for final change, I was incorrect in my initial reasoning. |
Description:
When validating strings using Gte/Gt/Lte/Lt, as per the Laravel docs, it should count characters in strings, as per the size validator.
When validating "password" using rule "gte:8" it will fail
When validating "8" using rule "gte:8" it will pass
When validating "7" using rule "gte:8" it will fail
When validating "9" using rule "gte:8" it will pass
Size works correctly:
When validating "password" using rule "size:8" it will pass
When validating "8" using rule "size:8" it will fail
If i'm doing it wrong, I apologise!
Steps To Reproduce:
Validate a string with lte/lt/gt/gte to match lengths
The text was updated successfully, but these errors were encountered: