I have just started to “play” with Play framework (2.0) and I’m having some trouble to find a solution to validate models directly. I have googled the problem but I can’t find any examples.
In Rails you can check if a model is valid by writing like this: my_model.valid?
I have only seen examples where I can validate the models in the controller but that’s not what I want to do right now when I’m writing unit tests.
It would be nice to have myModel.isValid(); or something similar.
You can define a
validatemethod on your Java model classes. See the corresponding documentation.