I just submitted a patch to substitute the attribute value into the message in validates_format_of, the same way validates_length_of, validates_inclusion_of, and validates_exclusion_of already do. http://rails.lighthouseapp.com/projects/8994/tickets/273-format-messages-in-validates_format_of If that seems useful, please take a look. Thanks. -hume. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Though there''s one +1 on it, it doesn''t seem like there''s much interest in that patch. I''m currently working on adding consistent message formatting for all the validations (where it seems to make sense). To clarify, the change passes the rejected value to the message''s % method (in addition to what''s already passed for those validations that already plug in mins, maxes, what-have-you), so you can do something like this: validates_length_of :login, :min => 3, :message => "has to be at least $d characters. ''$s'' isn''t long enough." Besides the fact that we need it in one validation for our app, the main motivation was to get the other validations consistent with validates_inclusion_of and validates_exclusion_of. (I was mistaken earlier when I said validates_length_of already does this too.) Will update the ticket once all validations are formatting the same way. -hume. On Wed, May 28, 2008 at 10:50 PM, John D. Hume <duelin.markers@gmail.com> wrote:> I just submitted a patch to substitute the attribute value into the > message in validates_format_of, the same way validates_length_of, > validates_inclusion_of, and validates_exclusion_of already do. > > http://rails.lighthouseapp.com/projects/8994/tickets/273-format-messages-in-validates_format_of > > If that seems useful, please take a look. Thanks. > -hume. >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Oops ... I didn''t notice the patch from that ticket was already committed[1]. Great. So I''ve entered a new ticket[2] with a patch adding the same feature to the other validations, plus doc updates. I just added examples (or modified the existing examples). It seemed too small a feature to explain in wordy detail. Please take a look. Thanks. -hume. [1] http://github.com/rails/rails/commit/f6e921f9568d7f2e4807edf8728e6b0df8991816 [2] http://rails.lighthouseapp.com/projects/8994/tickets/319-validation-message-formatting-across-the-board On Tue, Jun 3, 2008 at 10:52 AM, John D. Hume <duelin.markers@gmail.com> wrote:> Though there''s one +1 on it, it doesn''t seem like there''s much > interest in that patch. > > I''m currently working on adding consistent message formatting for all > the validations (where it seems to make sense). To clarify, the change > passes the rejected value to the message''s % method (in addition to > what''s already passed for those validations that already plug in mins, > maxes, what-have-you), so you can do something like this: > > validates_length_of :login, :min => 3, :message => "has to be at > least $d characters. ''$s'' isn''t long enough." > > Besides the fact that we need it in one validation for our app, the > main motivation was to get the other validations consistent with > validates_inclusion_of and validates_exclusion_of. (I was mistaken > earlier when I said validates_length_of already does this too.) > > Will update the ticket once all validations are formatting the same way. > -hume. > > > On Wed, May 28, 2008 at 10:50 PM, John D. Hume <duelin.markers@gmail.com> wrote: >> I just submitted a patch to substitute the attribute value into the >> message in validates_format_of, the same way validates_length_of, >> validates_inclusion_of, and validates_exclusion_of already do. >> >> http://rails.lighthouseapp.com/projects/8994/tickets/273-format-messages-in-validates_format_of >> >> If that seems useful, please take a look. Thanks. >> -hume. >> >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---