Class: Hyrax::AvatarValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/models/hyrax/avatar_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



4
5
6
7
# File 'app/models/hyrax/avatar_validator.rb', line 4

def validate(record)
  return unless record.avatar?
  record.errors.add(:avatar_file_size, 'must be less than 2MB') if record.avatar.size > 2.megabytes.to_i
end