Module: Mongoid::Validations::ClassMethods
- Defined in:
- lib/mongoid/validations.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#validates_associated(*args) ⇒ Object
Validates whether or not an association is valid or not.
-
#validates_format_of(*args) ⇒ Object
Validates whether or not a field matches a certain regular expression.
-
#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.
121 122 123 |
# File 'lib/mongoid/validations.rb', line 121 def validates_associated(*args) validates_with(AssociatedValidator, _merge_attributes(args)) end |
#validates_format_of(*args) ⇒ Object
Validates whether or not a field matches a certain regular expression.
103 104 105 |
# File 'lib/mongoid/validations.rb', line 103 def validates_format_of(*args) validates_with(FormatValidator, _merge_attributes(args)) end |
#validates_presence_of(*args) ⇒ Object
Validates whether or not a field is present - meaning nil or empty.
155 156 157 |
# File 'lib/mongoid/validations.rb', line 155 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.
138 139 140 |
# File 'lib/mongoid/validations.rb', line 138 def validates_uniqueness_of(*args) validates_with(UniquenessValidator, _merge_attributes(args)) end |