Module: SlackValidBlockKit::Validator::SelectMenu
- Included in:
- Runner
- Defined in:
- lib/slack_valid_block_kit/validator/select_menu.rb
Constant Summary collapse
- STATIC_SELECT_PROPERTIES =
%i(type placeholder action_id options option_groups initial_options confirm focus_on_load)
- EXTERNAL_SELECT_PROPERTIES =
%i(type placeholder action_id min_query_length initial_options confirm focus_on_load)
- USERS_SELECT_PROPERTIES =
%i(type placeholder action_id initial_user confirm focus_on_load)
- CONVERSATIONS_SELECT_PROPERTIES =
%i(type placeholder action_id initial_conversation default_to_current_conversation confirm response_url_enabled filter focus_on_load)
- CHANNELS_SELECT_PROPERTIES =
%i(type placeholder action_id initial_channel confirm response_url_enabled focus_on_load)
Instance Method Summary collapse
- #validate_channels_select(hash, path, options = nil) ⇒ Object
- #validate_conversations_select(hash, path, options = nil) ⇒ Object
- #validate_external_select(hash, path, options = nil) ⇒ Object
- #validate_static_select(hash, path, options = nil) ⇒ Object
- #validate_users_select(hash, path, options = nil) ⇒ Object
Instance Method Details
#validate_channels_select(hash, path, options = nil) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/slack_valid_block_kit/validator/select_menu.rb', line 65 def validate_channels_select(hash, path, = nil) validate_for_properties(hash, path, CHANNELS_SELECT_PROPERTIES) validate_for(hash[:type], "#{path}.type", String, true, only: ["channels_select"]) validate_for(hash[:initial_channel], "#{path}.initial_channel", String, false) validate_for(hash[:response_url_enabled], "#{path}.response_url_enabled", :bool, false) validate_common_for_select(hash, path, ) end |
#validate_conversations_select(hash, path, options = nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/slack_valid_block_kit/validator/select_menu.rb', line 53 def validate_conversations_select(hash, path, = nil) validate_for_properties(hash, path, CONVERSATIONS_SELECT_PROPERTIES) validate_for(hash[:type], "#{path}.type", String, true, only: ["conversations_select"]) validate_for(hash[:initial_conversation], "#{path}.initial_conversation", String, false) validate_for(hash[:default_to_current_conversation], "#{path}.default_to_current_conversation", :bool, false) validate_filter(hash["filter"], "#{path}.filter") validate_for(hash[:response_url_enabled], "#{path}.response_url_enabled", :bool, false) validate_common_for_select(hash, path, ) end |
#validate_external_select(hash, path, options = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/slack_valid_block_kit/validator/select_menu.rb', line 34 def validate_external_select(hash, path, = nil) validate_for_properties(hash, path, EXTERNAL_SELECT_PROPERTIES) validate_for(hash[:type], "#{path}.type", String, true, only: ["external_select"]) validate_for(hash[:min_query_length], "#{path}.min_query_length", Integer, false) validate_for(hash[:initial_options], "#{path}.initial_options", Array, false) validate_common_for_select(hash, path, ) end |
#validate_static_select(hash, path, options = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/slack_valid_block_kit/validator/select_menu.rb', line 9 def validate_static_select(hash, path, = nil) validate_for_properties(hash, path, STATIC_SELECT_PROPERTIES) validate_for(hash[:type], "#{path}.type", String, true, only: ["static_select"]) validate_for(hash[:options], "#{path}.options", Array, false, max: 100) = Array(hash[:options]) .each_with_index do |e, i| validate_option(e, "#{path}.options[#{i}]", { text_type: :text_objects }) end validate_for(hash[:option_groups], "#{path}.option_groups", Array, false, max: 100) option_groups = Array(hash[:option_groups]) option_groups.each_with_index do |e, i| validate_option_group(e, "#{path}.option_groups[#{i}]") end if hash[:options].nil? && hash[:option_groups].nil? add_error(path, :require_options_or_option_groups) end validate_for_initial_option_of_multi_static_select(hash[:initial_option], "#{path}.initial_option", options: , option_groups: option_groups) validate_common_for_select(hash, path, ) end |
#validate_users_select(hash, path, options = nil) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/slack_valid_block_kit/validator/select_menu.rb', line 44 def validate_users_select(hash, path, = nil) validate_for_properties(hash, path, USERS_SELECT_PROPERTIES) validate_for(hash[:type], "#{path}.type", String, true, only: ["users_select"]) validate_for(hash[:initial_user], "#{path}.initial_user", String, false) validate_common_for_select(hash, path, ) end |