Format messages in validates_format_of

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.

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.

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] #319 Validation message formatting across the board - Ruby on Rails - rails