size, lte, and gte rules are comparing numeric value instead of string length when applied to text fields #134
Unanswered
MontherTwisi
asked this question in
Questions
Replies: 1 comment 6 replies
-
I wasn't able to reproduce this in the sandbox, can you maybe help with it? You are right, when |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When using validation rules such as size, lte, and gte on a text field, the validation currently treats the input as a numeric value rather than validating against the character length of the string. This results in unexpected behavior — for example, setting size:3 on a text field causes it to fail unless the input is literally "3" or "003", instead of checking if the string is 3 characters long.
Steps to reproduce the behavior:
Create a simple text field.
Add a size:3 rule (or lte:5, gte:2).
Try inputting a 3-character string like "abc" or "123".
Validation fails, unless the input is a numeric value matching the number (e.g. 3).
The size, lte, and gte rules should evaluate the length of the string input when used on a text field, not its numeric value. This is how Laravel validation works with strings and matches the intuitive expectation for frontend validation.
Actual behavior
The rules interpret the input value numerically — treating "abc" as invalid for size:3, while "3" passes.
Beta Was this translation helpful? Give feedback.
All reactions