Class: MetadataPresenter::MaxSizeValidator

Inherits:
BaseUploadValidator show all
Defined in:
app/validators/metadata_presenter/max_size_validator.rb

Instance Attribute Summary

Attributes inherited from BaseValidator

#component, #page_answers

Instance Method Summary collapse

Methods inherited from BaseUploadValidator

#invalid_answer?, #user_answer

Methods inherited from BaseValidator

#allow_blank?, #custom_error_message, #default_error_message, #error_key, #initialize, #invalid_answer?, #schema_key, #user_answer, #valid?, #validation_value

Constructor Details

This class inherits a constructor from MetadataPresenter::BaseValidator

Instance Method Details

#error_message_hashObject



7
8
9
10
11
# File 'app/validators/metadata_presenter/max_size_validator.rb', line 7

def error_message_hash
  super.merge(
    { schema_key.to_sym => human_max_size }
  )
end

#error_nameObject



3
4
5
# File 'app/validators/metadata_presenter/max_size_validator.rb', line 3

def error_name
  'invalid.too-large'
end

#human_max_sizeObject



13
14
15
# File 'app/validators/metadata_presenter/max_size_validator.rb', line 13

def human_max_size
  (component.validation[schema_key].to_f / (1024.0 * 1024.0)).round
end