Steve Jorgensen
unread,Jan 14, 2013, 12:14:38 AM1/14/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubyonra...@googlegroups.com
One of the annoying problems with validations is that they are always applied after typecasting. This means, for instance, that the :only_integer option is effectively a no-op for an integer AR attribute. Whatever digits the user thought they were entering have already been lost before the validation can see the problem. This can be worked around, but it's awkward and kludgey.
A clean way to handle this would be to have a :before_type_cast option that runs the validation against the <attr>_before_type_cast attribute, but still associates the error with the regular attribute.