Validator Discovery

Topics: Validation Application Block
Sep 17, 2007 at 1:44 PM
I think the ValidationFactory should be able to create the Validator tree based on both the target type as per defined when you call Validation.Validate<T> and the concrete type of the target instance.

e.g.

interface ICustomer
{
[NotNullValidator]string Name { get; }
}

class Customer : ICustomer
{
public string Name { get { return DataAccess ?? null : DataAccess.GetCustomerName(Id); } }

[NotNullValidator]public IDataAccess DataAccess { get; }
}

ICustomer customer = new Customer();
ValidationResults results = Validation.Validate<ICustomer>(customer);
Assert.AreEqual(2, results.Count());