0

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)
       }
} 
0

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.