[12.x] Addition of fluent Granular Dimension Rule Messages #54631
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.
This Pull Request is a resubmit of the work from #52707 - I believe given the PR contained no breaking changes and that is a major constraint that been set for the scope of 12.x that is it worth considering inclusion of the improvements in this PR.
The PR will give users the ability to use granular error messages translation strings for more precise validation feedback for users on how the user can rectify the specific issues with the uploaded asset provided.
Currently, no matter how many constraints you set for the Image Dimensions rule, the framework only provides 1 validation message advising that the image upload is not within the constraints set.
I believe it's important to bring all of the Validation messages inline with the other fluent rules, and this is one of the last ones to be Macroable, DataAware & to use the framework initially setup in #43271 by @lukeraymonddowning and implemented in many other PR's on the other Fluent validation rules like #54067
Logic has been added ensure compatibility with the existing string representations of the image rule & prevent any breaking changes to existing codebases that upgrade to 12.x, as per this section here:
Link to the code in diff
NOTE: The only behavioural change that is of note & the reason it's more suited to a major release, is any existing codebase that has a custom translation string for the string representation of the dimension rule, eg:
Will now return the granular default messages that have been added into validation.php, so while this is not a breaking change, you may describe it as unexpected behaviour.
Having said this, I think that the additional granularity in feedback far outweighs the possibility of defaulting to the grandular message string in instances where the users have added custom messages for the string representation.