Sha256: 83b049d10f824b564e022eea62274c19bc3a13e9a493354bbcce381b833d0d94

Contents?: true

Size: 516 Bytes

Versions: 6

Compression:

Stored size: 516 Bytes

Contents

module Attachs
  module ActiveRecord
    module Validators
      class AttachmentPresenceValidator < ActiveModel::EachValidator

        def validate_each(record, attribute, value)
          if value.blank?
            record.errors.add attribute, :attachment_presence
          end
        end

      end
      module ClassMethods

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

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
attachs-0.4.5 lib/attachs/active_record/validators/attachment_presence_validator.rb
attachs-0.4.4 lib/attachs/active_record/validators/attachment_presence_validator.rb
attachs-0.4.3 lib/attachs/active_record/validators/attachment_presence_validator.rb
attachs-0.4.2 lib/attachs/active_record/validators/attachment_presence_validator.rb
attachs-0.4.1 lib/attachs/active_record/validators/attachment_presence_validator.rb
attachs-0.4.0 lib/attachs/active_record/validators/attachment_presence_validator.rb