0
難以得到簡單的驗證在Rails 3中工作,即使the regex works fine。即使使用有效的格式,驗證也會失敗。Rails 3 validates_format_of不適用於簡單的正則表達式
型號:
validates_format_of :start,
with: /\A[0-9]{2}\/[0-9]{2}\/[0-9]{4}\z/,
message: "Invalid date format"
斷言:
Event.new(start: "12/10/2010").valid?.should eq(true)
這種說法是失敗,因爲valid?
回報false
。
我錯過了什麼?
也許在新事件中的其他事件導致事件無效? – Zabba 2011-01-08 09:46:46