我確定這是一個總的noob問題,我錯過了一個明顯的錯誤,但是無論如何這裏都是這樣。未驗證的Grails命令對象
我有一個命令對象:
public class LeadCommand {
Integer OwnerId
String FirstName
String LastName
String Email
String Phone1
String Company
String StreetAddress1
String City
String State
String PostalCode
String Country
String Leadsource
static constraints = {
OwnerId(blank: false)
FirstName(blank: false)
LastName(blank: false)
Email(blank: false, email: true)
Phone1(blank: false)
Company(blank: false)
StreetAddress1(blank: false)
City(blank: false)
State(blank: false)
PostalCode(blank: false)
Country(blank: false)
Leadsource(blank: false)
}
}
和控制器的動作:
def process = { LeadCommand cmd ->
if (cmd.hasErrors()) {
redirect(action: index)
} else {
// do stuff
}
}
Command對象是越來越稀少,但並不跟隨驗證約束,我的設置。我通過閱讀文檔幾次,但我必須失去了一些東西...提前
感謝
BTW - 我使用Grails 1.3.7
編輯:
下面是一些示例數據後(直接從PARAMS地圖)
[Phone:,
OwnerId:1,
Country:United States,
LastName:,
City:,
PostalCode:,
State:,
Email:,
Leadsource:,
FirstName:,
Submit:Submit,
Company:,
StreetAddress1:,
action:process,
controller:leadEntry]
您可以發佈您提交的應該失敗的測試數據的示例嗎? – schmolly159
@ schmolly159更新了發佈數據的問題 – matmer