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-0.6.1 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-0.6.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-0.5.1 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-0.5.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-0.4.3 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-0.4.2 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-0.4.1 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-0.4.0 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-0.3.1 lib/can_has_validations/validators/existence_validator.rb
can_has_validations-0.3.0 lib/can_has_validations/validators/existence_validator.rb