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

validates_length_of not working for localized fields

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

      class Page
        include Mongoid::Document
        field :seo_title, type: String, default: "", localize: true
        validates_length_of :seo_title, within: 3..32, allow_blank: true
      end
      
      p = Page.new
      => #<Page _id: 51ee3e98de939d0721000003, seo_title: {"en"=>""}>
      p.valid?
      => false
      p.errors
      #<ActiveModel::Errors:0x002b10782a3c40 @base=#<Page _id: 51ee3e98de939d0721000003, seo_title: {"en"=>""}>, @messages={:seo_title=>["is too short (minimum is 3 characters)"]}>
      

            Assignee:
            durran Durran Jordan
            Reporter:
            macbury macbury
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: