In Grails controller actions, for validations, We use command objects. The problem is the number of CommandObject classes have exploded.
def publish = { PublishCommand command ->
if (command.hasErrors()) {
return redirect(action: 'errors',params:params)
}
//rest of the code
}
......
Class PublishCommand {
long personId
String name
static constraints = {
personId(nullable: false, blank: false)
name(nullable: false, blank: false)
}
}
PublishCommand Class exists only for this databinding & validation purpose. Number of such classes have exploded, 1 created for each of the action of the application. Question is, Is there a way I can have this PublishCommand as innerClass? Or other ways where I don't have to create so many classes?