Sha256: f6da85edf299727611c585d62c3f7a93c4079ac9088c82b7a5cb64c0653892af

Contents?: true

Size: 521 Bytes

Versions: 30

Compression:

Stored size: 521 Bytes

Contents

# Just like `presence` except that it properly ignores allow_nil / allow_blank.
# This is how Rails 3.2 worked, but was changed in Rails 4. Mongoid 3 and 4 both
#   act like Rails 4, so this is useful there too.

module ActiveModel::Validations
  class ExistenceValidator < ActiveModel::Validations::PresenceValidator
    def validate(record)
      attributes.each do |attribute|
        value = record.read_attribute_for_validation(attribute)
        validate_each(record, attribute, value)
      end
    end
  end  
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
can_has_validations-1.10.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.9.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.8.2 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.8.1 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.8.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.7.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.6.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.5.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.4.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.3.2 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.3.1 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.3.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.2.1 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.2.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.1.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.0.2 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.0.1 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-1.0.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-0.6.3 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-0.6.2 lib/can_has_validations/validators/existence_validator.rb