Module: Mongoid::Validatable::LocalizedEachValidator

Defined in:
lib/locomotive/mongoid/patches.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(document, attribute, value) ⇒ Object



203
204
205
206
207
208
209
210
# File 'lib/locomotive/mongoid/patches.rb', line 203

def validate_each(document, attribute, value)
  # validate the value only in the current locale
  if (field = document.fields[document.database_field_name(attribute)]).try(:localized?)
    value = value.try(:slice, ::Mongoid::Fields::I18n.locale.to_s)
  end

  super(document, attribute, value)
end