VAB - Subentity Validation (XML / App Config)

Topics: Validation Application Block
Feb 18, 2008 at 4:17 PM

Is there a simple way to validate "SubEntities" on a primary entity,

e.g. given the aggregate entity

class Invoice
String property...
Int Property ...
List<InvoiceItems> property ...

(Using the Sep 07 EntLib ExternallyConfiguredObjectValidator, and this is for business tier validation)

We have created Validation RuleSets for both Invoice and InvoiceItems

However, it seems we need to validate the entity and subentity separately
// Validate Main entity
results = validation.Validate(entity);

// Validate each subentity
foreach (invoiceItem in InvoiceItems)
results += validation.Validate(entity);

Ideally we would want to validate the Entity and Subentities in one "go", and key the results "property name" to the SubEntity (i.e. SubEntity.SomeProperty) to prevent namespace clash with the primary entity (if both entities e.g. have a property with the same name)

I guess a custom validator could be in order?

Thanks in Advance