Module: Mongoid::Validations::Macros
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mongoid/validations/macros.rb
Instance Method Summary collapse
-
#validates_associated(*args) ⇒ Object
Validates whether or not an association is valid or not.
-
#validates_format_of(*args) ⇒ Object
Validates the format of a field.
-
#validates_length_of(*args) ⇒ Object
Validates the length of a field.
-
#validates_presence_of(*args) ⇒ Object
Validates whether or not a field is present - meaning nil or empty.
-
#validates_uniqueness_of(*args) ⇒ Object
Validates whether or not a field is unique against the documents in the database.
Instance Method Details
#validates_associated(*args) ⇒ Object
Validates whether or not an association is valid or not. Will correctly handle has one and has many associations.
20 21 22 |
# File 'lib/mongoid/validations/macros.rb', line 20 def validates_associated(*args) validates_with(AssociatedValidator, _merge_attributes(args)) end |
#validates_format_of(*args) ⇒ Object
Validates the format of a field.
54 55 56 |
# File 'lib/mongoid/validations/macros.rb', line 54 def validates_format_of(*args) validates_with(Mongoid::Validations::FormatValidator, _merge_attributes(args)) end |
#validates_length_of(*args) ⇒ Object
Validates the length of a field.
71 72 73 |
# File 'lib/mongoid/validations/macros.rb', line 71 def validates_length_of(*args) validates_with(Mongoid::Validations::LengthValidator, _merge_attributes(args)) end |
#validates_presence_of(*args) ⇒ Object
Validates whether or not a field is present - meaning nil or empty.
88 89 90 |
# File 'lib/mongoid/validations/macros.rb', line 88 def validates_presence_of(*args) validates_with(PresenceValidator, _merge_attributes(args)) end |
#validates_uniqueness_of(*args) ⇒ Object
Validates whether or not a field is unique against the documents in the database.
37 38 39 |
# File 'lib/mongoid/validations/macros.rb', line 37 def validates_uniqueness_of(*args) validates_with(UniquenessValidator, _merge_attributes(args)) end |