validates_format_of

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?

/^[0-9]*.[0-9]{2}$/

Good luck,

-Conrad

Conrad Taylor wrote:

Andrew.

Andrew, does the following work for you?

/^[0-9]*.[0-9]{2}$/

I’m not Andrew, but I can tell you that that will have the exact same

problem as his original regex.

Good luck,

-Conrad

Best,

Marnen Laibow-Koser

http://www.marnen.org

marnen@marnen.org

I was able to successfully match the following cases:

300.00

123.00

123.11

300.01

-Conrad