Class: ContentSizeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ContentSizeValidator
- Defined in:
- app/models/concerns/content_size_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/models/concerns/content_size_validator.rb', line 4 def validate_each(record, attribute, value) return unless value.attached? return if value.byte_size < content_size value.purge record.errors.add(attribute, :byte_size, ) end |