Tuesday, August 4, 2009

How to validate money amount in ActiveRecord?

This is how I validate money amount in Romey.
Basically an regex that allows up to 2 decimal points or whole integers.

validates_format_of :amount, :with => /^\d+$|^\d+\.\d\d?$/

No comments: