Question

The struts2 validation framework allows you to define your validation for an action or at the domain object level.

My question is, is there an advantage or disadvantage using one over the other? What do you recommend?

My own findings: You may use the same domain objects in several actions and may have to re-define validation rules per action...maybe its better to place the validation rules in the object. But, I feel uncomfortable placing validation rules at the domain level since it seems to be something that belongs in the action.

Was it helpful?

Solution

In the MVC architecture the validation should be done at the model level i.e. domain objects. I don't think it's appropriate to have validation logic in controllers (Actions).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top