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:
i could write a set of classes, each representing a single validation, e.g. RegexValidation with its Pattern property, LengthValidation with it's Min and Max 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.
the second approach is to create an abstract class Validation and all the validator classes will inherit from it. They will have a dictionary that maps arguments names to their values (so that LengthValidation will have items with keys "max" and "min" and RegexValidation will have items with keys "pattern" 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.
so what would you suggest? any other ideas?