Class: Validatable::ValidatesExclusionOf
- Inherits:
-
ValidationBase
- Object
- ValidationBase
- Validatable::ValidatesExclusionOf
- Defined in:
- lib/validatable/validations/validates_exclusion_of.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#in ⇒ Object
Returns the value of attribute in.
Attributes inherited from ValidationBase
#after_validate, #allow_blank, #allow_nil, #attribute, #if, #klass
Instance Method Summary collapse
Methods inherited from ValidationBase
Constructor Details
This class inherits a constructor from Validatable::ValidationBase
Instance Attribute Details
#in ⇒ Object
Returns the value of attribute in.
3 4 5 |
# File 'lib/validatable/validations/validates_exclusion_of.rb', line 3 def in @in end |
Instance Method Details
#message(instance) ⇒ Object
13 14 15 |
# File 'lib/validatable/validations/validates_exclusion_of.rb', line 13 def (instance) super || "is reserved" end |
#valid?(instance) ⇒ Boolean
5 6 7 8 9 10 11 |
# File 'lib/validatable/validations/validates_exclusion_of.rb', line 5 def valid?(instance) value = instance.send(attribute) return true if allow_nil && value.nil? return true if allow_blank && (!value or (value.respond_to?(:empty?) and value.empty?)) !self.in.include?(value) end |