title: How to design a simple class structure that allows defining validations?
body: <p>my company processes paper forms so that written data is being put to databases. every form has a set of fields. i'm writing a simple internal app to define the form's fields and that includes field's validations. i'm thinking of classes structure now and i can think of two approaches:   </p>
  
  <ol>
  <li><p>i could write a set of classes, each representing a single validation, e.g. <strong>RegexValidation</strong> with its <strong>Pattern</strong> property, <strong>LengthValidation</strong> with it's <strong>Min</strong> and <strong>Max</strong> and so on. However if any new validation type appears in the future, i will probably have a lot of places in the project where i will have to write new code. i don't really think there will be any new validation types but it's an assumption i shouldn't make as a programmer.  </p></li>
  <li><p>the second approach is to create an abstract class <strong>Validation</strong> and all the validator classes will inherit from it. They will have a dictionary that maps arguments names to their values (so that <strong>LengthValidation</strong> will have items with keys "<strong>max</strong>" and "<strong>min</strong>" and <strong>RegexValidation</strong> will have items with keys "<strong>pattern</strong>" and so on). It looks pretty nice, but there is a major problem - when writing data to the database i have to know which validation is which one so that i could put the values in appropriate places. I could use a strategy design pattern and let Validation class have Save method so that every class will know how it is saved in the database. but on the other hand i don't want the validation classes to be responsible for writing data to database.  </p></li>
  </ol>
  
  <p>so what would you suggest? any other ideas?</p>