Sha256: 98c3ef9a7e09934d92c0647b0aa0b18c864e2bbafc5294e880f68e5d0d5042d2

Contents?: true

Size: 858 Bytes

Versions: 13

Compression:

Stored size: 858 Bytes

Contents

module Shoulda
  module Matchers
    module ActiveModel
      # @private
      module Helpers
        def pretty_error_messages(object)
          format_validation_errors(object.errors)
        end

        def format_validation_errors(errors)
          list_items = errors.keys.map do |attribute|
            messages = errors[attribute]
            "* #{attribute}: #{messages}"
          end

          list_items.join("\n")
        end

        def default_error_message(type, options = {})
          model_name = options.delete(:model_name)
          attribute = options.delete(:attribute)
          instance = options.delete(:instance)

          RailsShim.generate_validation_message(
            instance,
            attribute.to_sym,
            type,
            model_name,
            options
          )
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
shoulda-matchers-4.4.1 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-4.4.0 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-4.3.0 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-4.2.0 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-4.1.2 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-4.1.1 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-4.1.0 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-4.0.1 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-3.1.3 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-4.0.0.rc1 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-3.1.2 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-3.1.1 lib/shoulda/matchers/active_model/helpers.rb
shoulda-matchers-3.1.0 lib/shoulda/matchers/active_model/helpers.rb