lib/tapioca/helpers/config_helper.rb in tapioca-0.7.3 vs lib/tapioca/helpers/config_helper.rb in tapioca-0.8.0

- old
+ new

@@ -70,10 +70,11 @@ sig { params(config_file: String, config: T::Hash[T.untyped, T.untyped]).void } def validate_config!(config_file, config) # To ensure that this is not re-entered, we mark during validation return if @validating_config + @validating_config = T.let(true, T.nilable(T::Boolean)) commands = T.cast(self, Thor).class.commands errors = config.flat_map do |config_key, config_options| @@ -123,9 +124,21 @@ end error_msg = "invalid value for option `#{config_option_key}` for key `#{config_key}` - expected " \ "`#{command_option.type.capitalize}` but found #{config_option_value_type.capitalize}" next build_error(error_msg) unless config_option_value_type == command_option.type + + case config_option_value_type + when :array + error_msg = "invalid value for option `#{config_option_key}` for key `#{config_key}` - expected " \ + "`Array[String]` but found `#{config_option_value}`" + next build_error(error_msg) unless config_option_value.all? { |v| v.is_a?(String) } + when :hash + error_msg = "invalid value for option `#{config_option_key}` for key `#{config_key}` - expected " \ + "`Hash[String, String]` but found `#{config_option_value}`" + all_strings = (config_option_value.keys + config_option_value.values).all? { |v| v.is_a?(String) } + next build_error(error_msg) unless all_strings + end end.compact end class ConfigErrorMessagePart < T::Struct const :message, String