I am trying to implement some command object validation, but one property of command object is not binding its always return null
Domain class
package ni.sb
class PurchaseOrder implements Serializable {
Date dateCreated
Date dutyDate
String invoiceNumber
BigDecimal balance
String typeOfPurchase
Date lastUpdated
static constraints = {
dutyDate nullable:false, validator: { dutyDate ->
def today = new Date()
if (dutyDate <= today) {
"notMatch"
}
}
invoiceNumber blank:false, unique:true
balance nullable:true
typeOfPurchase inList:["Contado", "Credito"], maxSize:255
}
}
This is the command object
class PurchaseOrderCommand implements Serializable {
Date dutyDate
String invoiceNumber
String typeOfPurchase
static constraints = {
importFrom PurchaseOrder
}
}
Here is the controller action
def actName(PurchaseOrderCommand cmd) {
if (cmd.hasErrors()) {
println params.dump()
println cmd.dump()
return
}
}
dutyDate is not binding, after i try dumb() in params and cmd i get this
snippet params.dump()
dutyDate:2014-09-25
snippet cmd.dump()
dutyDate=null
I hope you can help me