0
class Item < ActiveRecord::Base
  validates :price, :format => { :with => /\A\d+(?:\.\d{0,2})?\z/ }, :numericality => {:greater_than => 0}

My question is what the ?: is doing in the pricing format. Also, this regex is failing. It is not allowing 0.01 to be a valid price and, subsequently, a valid item. Why?

From what I understand the regex is: looking at the beginning, and looking for one ore more digits and then comes the ?: which I am confused about. What does it do?

Jwan622
  • 8,910
  • 11
  • 56
  • 125

0 Answers0