Class: MetadataPresenter::CatchAllValidator

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

Constant Summary collapse

ERROR_NAME_PREFIX =
'error.'.freeze

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, #error_key, #error_message_hash, #initialize, #schema_key, #user_answer, #valid?, #validation_value

Constructor Details

This class inherits a constructor from MetadataPresenter::BaseValidator

Instance Method Details

#invalid_answer?Boolean

NOTE: generic errors in other components can be implemented by introducing new case branching if neccessary.

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
# File 'app/validators/metadata_presenter/catch_all_validator.rb', line 7

def invalid_answer?
  case component.type
  when 'upload', 'multiupload'
    upload_user_answer&.error_name.to_s.start_with?(ERROR_NAME_PREFIX)
  else
    false
  end
end