Class: MongoMapper::Validations::ValidatesExclusionOf

Inherits:
Validatable::ValidationBase
  • Object
show all
Defined in:
lib/mongomapper/validations.rb

Instance Method Summary collapse

Instance Method Details

#message(instance) ⇒ Object



48
49
50
# File 'lib/mongomapper/validations.rb', line 48

def message(instance)
  super || "is reserved"
end

#valid?(instance) ⇒ Boolean

Returns:



40
41
42
43
44
45
46
# File 'lib/mongomapper/validations.rb', line 40

def valid?(instance)
  value = instance[attribute]
  return true if allow_nil && value.nil?
  return true if allow_blank && value.blank?
  
  !within.include?(instance[attribute])
end