Module: Mongoid::Validatable::LocalizedEachValidator

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

Instance Method Summary collapse

Instance Method Details

#validate_each(document, attribute, value) ⇒ Object



185
186
187
188
189
190
191
192
# File 'lib/locomotive/mongoid/patches.rb', line 185

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