Reputation: 208
I recently upgraded a 1.3.6 application to Grails2. My test cases have started failing
Here is the scenario, I have a command object and a constraint. When the request hits the action, without the parameter name
(localhost:8080/app-name/Book/test?i=0
)
I am getting a validation error. Grails doc says Command Object fields are nullable by default. Looks like it is not, from this test. My question is how do I make them nullable true globally for all command objects? Code below,
class BookController {
def test = {TestCommand cmd ->
cmd.validate()
if (cmd.hasErrors()) {
println "has Errors"
render 'Error'
} else {
println "Success"
render 'Hello World'
}
}
}
Command Object is :
class TestCommand {
int i;
String name
static constraints = {
name(password: true)
}
}
Upvotes: 0
Views: 848
Reputation: 208
It turned out to be a Grails bug. Grails 2.0 has changed behaviour about default nullable value for Command Objects. Here is the JIRA
Upvotes: 2