title: Business data validation approach in java
body: <p>I am stuck with quite complex topic. I am trying to come up with some universal solution for data validation. We have system, that is similar to cell phone company customer management system, where customers has it's accounts full of information(costs, payments, personal information, events archive, debts etc.) and I need to validate this data in multiple situations. I cant forgot that there are various accounts and some of them need specific validating. What I cant figure out, is some universal, simple and reusable system to this work. </p>
  
  <p>Main idea is, that there will be many 'constraints' that will be used(like: customer has to have name, if there is debt, there cant be overpayment, etc.), and also there will be defined situations(like account canceling, demand for payment send etc.) when I want validate data(execution of validation from code is not topic here). Situation will have list of constraints that are validated, or executed for it. This is what we want.</p>
  
  <p><strong>But what is right java approach to this?</strong> Should all situations and constraints be classes? Situations will have constraints instances, and instances will have validate() methods? But each will have different arguments. Any other ideas?</p>
  
  <p>I know, answer here can be long, so I will appreciate directing me on some documentation on that topic to. <strong>Thanks a lot for answers!</strong></p>