VAB and inherited classes

Topics: Validation Application Block
Jan 16, 2008 at 9:16 AM
For example I use following classes:

public class Person
{
private string _Name;

public string Name
{
get { return _Name; }
set { _Name = value; }
}
}

public class Employee : Person
{
private string _Department;

StringLengthValidator(1,99)
public string Department
{
get { return _Department; }
set { _Department = value; }
}
}

And I want to validate a Person

Employee e = new Employee();
e.Name = "John";
e.Department = "";
Person p = e;
ValidationResults res = Validation.Validate(p);

the result is valid although the Department is empty.

How can I pass a base class and validate a possible sub-class?

Regards

Aron