Sha256: 99c6d11fb323c9a0cf544d7007593fcb2bc5ba1311a5820246d7913631fad857

Contents?: true

Size: 637 Bytes

Versions: 3

Compression:

Stored size: 637 Bytes

Contents

module Attachs
  module Extensions
    module ActiveRecord
      module Validations
        extend ActiveSupport::Concern

        class AttachmentValidator < ActiveModel::EachValidator

          def validate_each(record, attribute, attachment_or_collection)
            case attachment_or_collection
            when Collection
              attachment_or_collection.each do |attachment|
                validate_one record, attribute, attachment
              end
            when Attachment
              validate_one record, attribute, attachment_or_collection
            end
          end

        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
attachs-4.0.0.2 lib/attachs/extensions/active_record/validations/attachment_validator.rb
attachs-4.0.0.1 lib/attachs/extensions/active_record/validations/attachment_validator.rb
attachs-4.0.0.0 lib/attachs/extensions/active_record/validations/attachment_validator.rb