Module: Mongoid::Validatable::Macros
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
| Included In: | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Class Chain: 
          self,
          ActiveSupport::Concern
         | |
| Defined in: | lib/mongoid/validatable/macros.rb | 
Overview
Mixin module included in ::Mongoid::Document which adds various validation macro methods, such as #validates_presence_of and #validates_uniqueness_of.
Instance Method Summary
- 
    
      #validates_associated(*args)  
    
    Validates whether or not an association is valid or not. 
- 
    
      #validates_format_of(*args)  
    
    Validates the format of a field. 
- 
    
      #validates_length_of(*args)  
    
    Validates the length of a field. 
- 
    
      #validates_numericality_of(*args)  
    
    Validates whether or not a field contains a numeric value. 
- 
    
      #validates_presence_of(*args)  
    
    Validates whether or not a field is present - meaning nil or empty. 
- 
    
      #validates_uniqueness_of(*args)  
    
    Validates whether or not a field is unique against the documents in the database. 
Instance Method Details
#validates_associated(*args)
Validates whether or not an association is valid or not. Will correctly handle has one and has many associations.
# File 'lib/mongoid/validatable/macros.rb', line 27
def validates_associated(*args) validates_with(AssociatedValidator, _merge_attributes(args)) end
#validates_format_of(*args)
Validates the format of a field.
# File 'lib/mongoid/validatable/macros.rb', line 59
def validates_format_of(*args) validates_with(FormatValidator, _merge_attributes(args)) end
#validates_length_of(*args)
Validates the length of a field.
# File 'lib/mongoid/validatable/macros.rb', line 74
def validates_length_of(*args) validates_with(LengthValidator, _merge_attributes(args)) end
#validates_numericality_of(*args)
Validates whether or not a field contains a numeric value.
# File 'lib/mongoid/validatable/macros.rb', line 104
def validates_numericality_of(*args) validates_with(NumericalityValidator, _merge_attributes(args)) end
#validates_presence_of(*args)
Validates whether or not a field is present - meaning nil or empty.
# File 'lib/mongoid/validatable/macros.rb', line 89
def validates_presence_of(*args) validates_with(PresenceValidator, _merge_attributes(args)) end
#validates_uniqueness_of(*args)
Validates whether or not a field is unique against the documents in the database.
# File 'lib/mongoid/validatable/macros.rb', line 44
def validates_uniqueness_of(*args) validates_with(UniquenessValidator, _merge_attributes(args)) end