Class: MetadataPresenter::AutocompleteValidator
- Inherits:
-
BaseValidator
- Object
- BaseValidator
- MetadataPresenter::AutocompleteValidator
- Defined in:
- app/validators/metadata_presenter/autocomplete_validator.rb
Instance Attribute Summary collapse
-
#autocomplete_items ⇒ Object
readonly
Returns the value of attribute autocomplete_items.
Attributes inherited from BaseValidator
Instance Method Summary collapse
- #autocomplete_item_list ⇒ Object
-
#initialize(page_answers:, component:, autocomplete_items:) ⇒ AutocompleteValidator
constructor
A new instance of AutocompleteValidator.
- #invalid_answer? ⇒ Boolean
Methods inherited from BaseValidator
#allow_blank?, #custom_error_message, #default_error_message, #error_key, #error_message_hash, #schema_key, #user_answer, #valid?, #validation_value
Constructor Details
#initialize(page_answers:, component:, autocomplete_items:) ⇒ AutocompleteValidator
Returns a new instance of AutocompleteValidator.
5 6 7 8 9 |
# File 'app/validators/metadata_presenter/autocomplete_validator.rb', line 5 def initialize(page_answers:, component:, autocomplete_items:) super(page_answers:, component:) @autocomplete_items = autocomplete_items end |
Instance Attribute Details
#autocomplete_items ⇒ Object (readonly)
Returns the value of attribute autocomplete_items.
3 4 5 |
# File 'app/validators/metadata_presenter/autocomplete_validator.rb', line 3 def autocomplete_items @autocomplete_items end |
Instance Method Details
#autocomplete_item_list ⇒ Object
17 18 19 |
# File 'app/validators/metadata_presenter/autocomplete_validator.rb', line 17 def autocomplete_item_list @autocomplete_item_list ||= autocomplete_items[component.uuid] end |
#invalid_answer? ⇒ Boolean
11 12 13 14 15 |
# File 'app/validators/metadata_presenter/autocomplete_validator.rb', line 11 def invalid_answer? return if autocomplete_item_list.blank? autocomplete_item_list.exclude?(JSON.parse(user_answer)) end |