JSR 303 Bean Validation – Why on getter and not setter?

Annotating getters doesn’t mean that validation is performed when a getter is invoked. It is just used to identify the property to which a constraint shall apply. The big advantage of putting constraints on (usually public) getters instead on (typically private) fields is that the constraints are part of the type’s public API that way. … Read more