Open corylown opened 2 months ago
Carrierwave still lists the file_validators gem as one of the solutions for validating file size: https://github.com/carrierwaveuploader/carrierwave/wiki/How-to%3A-Validate-image-file-size (wiki page last updated in 2020).
The first solution listed is a carrierwave only solution that doesn't require any additional gems.
CarrierWave supports this since version 1.0.0.beta (2016-09-08) by defining a size_range method inside your uploader class. The method should return a Range for minimum/maximum allowed file size in bytes. For example, to allow a size of greater than or equal to 1 byte and less than or equal to 10 MB, you'd do:
def size_range 1.byte..10.megabytes end
This is used to validate the the featured image is not too large:
It's possibly unmaintained: https://github.com/musaffa/file_validators