Sep 5, 2007 at 4:17 PM
I'd like to be able to use the validation application block to add validation to an application where there aren't any business entity classes.
The data is contained in either an untyped DataSet or an untyped DataTable.

As far as I am aware, it is not possible to use the existing validation application block, as it is, because it always requires the type of the business entity.
This is the case for the WinForms integration even when using just the control validation and the object validation is not used.

Are there any plans to extend the validation application block to work without requiring a business entity type?
Sep 5, 2007 at 5:47 PM
Edited Sep 5, 2007 at 5:53 PM

You probably have a lot of different content/structures for your datasets/datatables - I guess not one validation rule could fit all cases.

So how would you like to use the block in that specific scenario? What kind of behavior would you expect ?

BTW: the ValueAccess/ValueAccessValidators seem to be designed somewhat for that purpose.
Sep 5, 2007 at 6:58 PM
What I'd like to be able to do is create rulesets and rules in the config file, and then associate a DataSet/DataTable with a ruleset (and the column names are associated with the rule names contained in the ruleset) or associate a UI control with a ruleset and a specific rule.

For example, if I have the following config:

<ruleset name="Quote">
<rule name="DateRaised">
<validator lowerBound="1969-01-01" lowerBoundType="Inclusive"
upperBound="" upperBoundType="Ignore" negated="false" messageTemplate="Must be raised after 1969"
messageTemplateResourceName="" messageTemplateResourceType=""
tag="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.DateTimeRangeValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Date Range Validator" />

Then on the UI control for the Date Raised field, just set a couple of properties for the ruleset and rule name, and add an ErrorProvider and a ValidationProvider to the form.

For a DataSet/DataTable, something similar to the ObjectValidator, instead of passing in an object, pass in a DataSet/DataTable. For each of the DataTables whose name corresponds to a ruleset name, the DataTable is validated against the ruleset, and for each column name that matches a rule name the cell value is validated against the rule.

So if I have a DataSet containing a single DataTable named 'Quote', and the DataTable contains a number of columns one of which is named 'DateRaised', I can validate the DataSet against the Quote ruleset by using something like this:

DataSetValidator validator = new DataSetValidator("Quote");
ValidationResults results = validator.Validate(dataSet);

The key point is that at no time does the validation rely on a type to match the ruleset or rule.