Add min_size and max_size to :file_size_out_of_range error message #134
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.
Currently, the error message for an invalid file size can't include the expected min or max size of the file.
The error message only states:
This PR allows using the interpolated variables
%{min_size}
and%{max_size}
in the localized error message string.Thus the error message can be customized by projects using this gem to look like this:
Future work
For now, the error message doesn't include the size information by default. The extra information must be added by projects using the gem.
In a future PR, I'd like to introduce new localized strings for "too large" and "too small" errors, which would allow to have the default error messages mention the string by default. (This is more work because of retro-compatibility concerns though).