MaxValue Rule should only fail, when $value is higher than the given maximal value #75
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.
Description of the Issue
The failure message in the
MaxValueRule
currently states:The {attribute} must be less than or equal to {value}
However, the corresponding
if
condition in the implementation looks like this:This causes the maximum value itself to be incorrectly treated as invalid.
Example
10
10
Expected outcome: The validation should pass, as the input meets the "less than or equal to" condition.
Actual outcome: The validation fails with the error message:
The reduction must be less than or equal to 10
Proposed Fix
The issue lies in the use of the
>=
operator in the condition. To align the behavior with the intended rule, the check should verify only if the value is strictly greater than the maximum:This ensures that the maximum value is accepted as valid, consistent with the rule's message.