Class: MetadataPresenter::UploadValidator

Inherits:
BaseValidator show all
Defined in:
app/validators/metadata_presenter/upload_validator.rb

Instance Attribute Summary

Attributes inherited from BaseValidator

#component, #page_answers

Instance Method Summary collapse

Methods inherited from BaseValidator

#allow_blank?, #custom_error_message, #default_error_message, #initialize, #schema_key, #valid?, #validation_value

Constructor Details

This class inherits a constructor from MetadataPresenter::BaseValidator

Instance Method Details

#error_message_hashObject



13
14
15
16
17
18
# File 'app/validators/metadata_presenter/upload_validator.rb', line 13

def error_message_hash
  {
    control: page_answers.send(component.id)['original_filename'],
    schema_key.to_sym => component.validation[schema_key]
  }
end

#invalid_answer?Boolean

Returns:

  • (Boolean)


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

def invalid_answer?
  user_answer.error_name == error_name
end

#user_answerObject



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

def user_answer
  page_answers.uploaded_files.find do |uploaded_file|
    component.id == uploaded_file.component.id
  end
end