Sha256: 47dd1945fc9e6404427c19054f8791ee57844963123450ecf5c9cdb59e5c5f0d

Contents?: true

Size: 460 Bytes

Versions: 5

Compression:

Stored size: 460 Bytes

Contents

# frozen_string_literal: true

# @private
# Ensure that all items in the array are valid
class PGTrunk::AllItemsValidValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    Array.wrap(value).each.with_index.map do |item, index|
      item.errors.messages.each do |name, list|
        list.each do |message|
          record.errors.add :base, "#{attribute}[#{index}]: #{name} #{message}"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pg_trunk-0.2.0 lib/pg_trunk/core/validators/all_items_valid_validator.rb
pg_trunk-0.1.3 lib/pg_trunk/core/validators/all_items_valid_validator.rb
pg_trunk-0.1.2 lib/pg_trunk/core/validators/all_items_valid_validator.rb
pg_trunk-0.1.1 lib/pg_trunk/core/validators/all_items_valid_validator.rb
pg_trunk-0.1.0 lib/pg_trunk/core/validators/all_items_valid_validator.rb