Class: NilValidator
- Inherits:
- 
      ActiveModel::EachValidator
      
        - Object
- ActiveModel::EachValidator
- NilValidator
 
- Defined in:
- app/validators/nil_validator.rb
Overview
Validator to ensure an attribute is nil.  Intended for use conditionally with :if or :unless to ensure an
attribute is nil under one condition while a different validation, such as :presence or :inclusion is used under
the dual of that condition.
Instance Method Summary collapse
- 
  
    
      #validate_each(record, attribute, value)  ⇒ void 
    
    
  
  
  
  
  
  
  
  
  
    Validates that valueisnil.
Instance Method Details
#validate_each(record, attribute, value) ⇒ void
This method returns an undefined value.
Validates that value is nil.
| 11 12 13 14 15 | # File 'app/validators/nil_validator.rb', line 11 def validate_each(record, attribute, value) unless value.nil? record.errors[attribute] << 'must be nil' end end |