Sha256: bf1c9a8c25549135280de69961b0007b849da9f013732df98e69e2cb41ad8e07

Contents?: true

Size: 599 Bytes

Versions: 3

Compression:

Stored size: 599 Bytes

Contents

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

        class AttachmentPresenceValidator < AttachmentValidator

          def validate_attachment(record, attachment)
            if attachment.blank?
              attachment.errors.add :value, :blank
            end
          end

        end
        module ClassMethods

          def validates_attachment_presence_of(*attributes)
            validates_with AttachmentPresenceValidator, _merge_attributes(attributes)
          end

        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
attachs-4.0.0.5 lib/attachs/extensions/active_record/validations/attachment_presence_validator.rb
attachs-4.0.0.4 lib/attachs/extensions/active_record/validations/attachment_presence_validator.rb
attachs-4.0.0.3 lib/attachs/extensions/active_record/validations/attachment_presence_validator.rb