In my model I have a person with a HomeAddress and BillingAddress of type location:
class Person {
public Location HomeAddress { get; set; }
public Location BillingAddress { get; set; }
... other properties
}
class Location {
[Required]
public string ZipCode { get; set; }
... other properties
}
I'm looking for an elegant way to validate the 'required' properties only on the required property HomeAddress. I'm using the normal componentmodel attributes and built in model validation from MVC. So what I'm looking for is an attribute that would check if the Location is in Person.HomeAddress or .BillingAddress, and only validate in the first case. Or should I change my design and make the bindingaddress NULL in case not enough info is entered?