Hi,
I have this in one of my models:
validates_format_of :amount, :with => /\A[0-9]{1,5}.[0-9]{2}\Z/
If I enter an amount that ends with “.00”, eg. 123.00 or 300.00 it
fails, and I cannot understand why. It works with 123.11 or 300.01,
etc.
I have also tried:
validates_format_of :amount, :with => /\A[0-9]{1,5}.[0-9][0-9]\Z/
but it gives the same result (ie. doesn’t work as I would have thought
it would).
Am I missing something?
I’m using JRuby on Netbeans under Windows Vista if that is relevant.
Andrew.
Andrew, does the following work for you?
/[1]*.[0-9]{2}$/
Good luck,
-Conrad
0-9 ↩︎