Class: Mongoid::Validations::PresenceValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Mongoid::Validations::PresenceValidator
- Defined in:
- lib/mongoid/validations/presence.rb
Overview
Validates that the specified attributes are not blank (as defined by Object#blank?).
Instance Method Summary collapse
-
#validate_each(document, attribute, value) ⇒ Object
Validate the document for the attribute and value.
Instance Method Details
#validate_each(document, attribute, value) ⇒ Object
Validate the document for the attribute and value.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mongoid/validations/presence.rb', line 28 def validate_each(document, attribute, value) field = document.fields[attribute.to_s] if field && field.localized? && !value.blank? value.each_pair do |locale, value| document.errors.add(attribute, :blank, ) if value.blank? end else document.errors.add(attribute, :blank, ) if value.blank? end end |