Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2150

Evaluate validation conditions for each locale

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      First off: Thank you for all your efforts! I really enjoy working with Mongoid!

      I'd like validation conditions to be evaluated for each locale. For example:

      class Model
      include Mongoid::Document

      field :enabled, type: Boolean, localize: true
      field :title, type: String, localize: true

      validates_presence_of :title, if: :enabled
      end

      Currently the condition is run only once. The value for enabled is determined by I18n.locale. It's therefore very hard to have locale context aware conditions.

      I thought about looping through the locale versions and changing I18n.locale temporarily, but I couldn't get it working without error messages being translated too.

            Assignee:
            Unassigned Unassigned
            Reporter:
            teunvanvegchel teunvanvegchel
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: