Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

validates_length_of does not accept custom messages when :within used

#1057

validates_length_of does not accept custom messages when :within or :in used. Instead it shows standard error message.

Code to reproduce

validates_length_of :mobile,

                  :in => 10..20,
                  :on => :create,
                  :message => "Sample: 5329999999"

using :minimum and :maximum instead of :in works fine anyway

This is on 2.1.1

Reported by Serdar Soydemir · September 16th, 2008 @ 01:57 PM

State: committed
Milestone: 2.x
Assigned to: Michael Koziarski Michael Koziarski
Importance: none

Activity

  1. Emilio Tagua
    Emilio Tagua
    • Tag changed from 2.1, activerecord, validation to 2.1, activerecord, patch, validation

    Here is the patch to add custom message to vlo when using :in or :within option.

    September 16th, 2008 @ 02:39 PM

  2. Emilio Tagua
  3. Emilio Tagua
    Emilio Tagua

    Edge patch, since this is actually not working on edge either.

    September 16th, 2008 @ 03:21 PM

  4. Pratik
    Pratik
    • Assigned user set to Pratik
    • State changed from new to incomplete

    Hey Emilio,

    That looks good. I think we need to have a test case for :within as well.

    Catch me in IRC and we'll get this going.

    Thanks!

    December 20th, 2008 @ 07:25 PM

  5. Emilio Tagua
    Emilio Tagua

    Pratik,

    As we spoke in IRC some time ago the :within tests is redundant since it's an alias from :in.

    January 29th, 2009 @ 05:59 PM

  6. Pratik
    Pratik
    • State changed from incomplete to open
    • Assigned user changed from Pratik to Michael Koziarski

    January 29th, 2009 @ 06:05 PM

  7. Repository
    Repository
    • State changed from open to committed

    (from [2b8be761e476c103e94f8567c3880ea7363dfec0]) validate_length_of should use custom message if given when using in or within.

    Signed-off-by: Michael Koziarski michael@koziarski.com [#1057 validates_length_of does not accept custom messages when :within used state:committed] http://github.com/rails/rails/co...

    February 1st, 2009 @ 02:02 AM