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/ticke... If that seems useful, please take a look. Thanks. -hume.
on 2008-05-29 04:51
on 2008-06-03 16:54
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 2008-06-03 18:24
Oops ... I didn't notice the patch from that ticket was already committed. Great. So I've entered a new ticket 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.  http://github.com/rails/rails/commit/f6e921f9568d7...  http://rails.lighthouseapp.com/projects/8994/ticke...