Sha256: 7f2800045d18e50944c94a7db64e79041ed3d07e48e44dea3c4261a86a3e49b2

Contents?: true

Size: 402 Bytes

Versions: 50

Compression:

Stored size: 402 Bytes

Contents

require "active_model"

module ActiveModel
  module Validations
    # Validates that a file is attached
    #
    # Example:
    #
    #   validates :logo, attached: true
    #
    class AttachedValidator < EachValidator
      def validate_each(record, attribute, value)
        record.errors.add(attribute, (options[:message] || "must be attached")) unless value.attached?
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
plutonium-0.15.22 lib/active_model/validations/attached_validator.rb
plutonium-0.15.21 lib/active_model/validations/attached_validator.rb
plutonium-0.15.20 lib/active_model/validations/attached_validator.rb
plutonium-0.15.19 lib/active_model/validations/attached_validator.rb
plutonium-0.15.18 lib/active_model/validations/attached_validator.rb
plutonium-0.15.17 lib/active_model/validations/attached_validator.rb
plutonium-0.15.16 lib/active_model/validations/attached_validator.rb
plutonium-0.15.15 lib/active_model/validations/attached_validator.rb
plutonium-0.15.14 lib/active_model/validations/attached_validator.rb
plutonium-0.15.13 lib/active_model/validations/attached_validator.rb
plutonium-0.15.12 lib/active_model/validations/attached_validator.rb
plutonium-0.15.11 lib/active_model/validations/attached_validator.rb
plutonium-0.15.10 lib/active_model/validations/attached_validator.rb
plutonium-0.15.9 lib/active_model/validations/attached_validator.rb
plutonium-0.15.8 lib/active_model/validations/attached_validator.rb
plutonium-0.15.7 lib/active_model/validations/attached_validator.rb
plutonium-0.15.6 lib/active_model/validations/attached_validator.rb
plutonium-0.15.5 lib/active_model/validations/attached_validator.rb
plutonium-0.15.4 lib/active_model/validations/attached_validator.rb
plutonium-0.15.3 lib/active_model/validations/attached_validator.rb