If I have a collection of database tables (in an Access file, for example) and need to validate each table in this collection against a rule set that has both common rules a
Just an update on this: I decided to go with the Decorator pattern. That is, I have one 'generic' table class that implements an IValidateableTable
interface (which contains validate()
method). Then, I created several validation decorators (that also implement IValidateableTable
) which I can wrap around each table that I'm trying to validate.
So, the code ends up looking like this:
IValidateableTable table1 = new GenericTable(myDataSet);
table1 = new NonNullNonEmptyColumnValidator(table1, "ColumnA");
table1 = new ColumnValueValidator(table1, "ColumnB", "ExpectedValue");
Then, all I need to do is call table1.Validate()
which unwinds through the decorators calling all of the needed validations. So far, it seems to work really well, though I am still open to suggestions.