Fix for the GT, GTE, LT, LTE comparison operators not comparing strings, arrays, or files to a numeric parameter #40309
+86
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for the GT, GTE, LT, LTE operators not comparing to a numeric value (i.e. characters in strings, file length or array length). Fixes my issue #40308
For proof of bug, run the tests included in this PR without the changes to ValidatesAttributes.php file.
Removes the numeric check for value (which may not be numeric if comparing strings, files or arrays). This is the case if you do not pass another attribute to compare to (i.e. just passing in a number to compare to). getSize has the logic required to deal with what type it is.
This means that the operators work correctly, as per the Laravel documentation.
Tests fully pass on my machine.