views:

40

answers:

2

validates_format_of :price_in_cents, :with =>

What is the regexp for this simple validation

+2  A: 

You can use validates_numericality_of with only_integer, combined with positive numbers to represent price in pennies.

marklai
Yes, great. Thanks!
Sam
A: 

/[0-9]+/ Matches one or more integers, however there are better ways to do this (as seen in marklai's answer).

adamse