2 votes

How can I avoid duplicate annotations when validating both Entity and DTOs?

The problem here is that annotations tightly couple your class to some package, NHibernate? and Whatever validation package you are using. Ideally you would have a clean POJO class for your business ...
Ewan's user avatar
  • 75.6k
1 vote

How can I avoid duplicate annotations when validating both Entity and DTOs?

A potential solution would be declaring a new annotation type for each shared field and decorating it with the validation rules. @NotNull @NotBlank @Length(min = 3, max = 21) @Documented @Constraint(...
Marco Pierre White's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible