Hi,
I have some problems with validation using Data Annotations in ASP.NET MVC 2. For example, I have Address class:
public class Address
{
public long Id { get; set; }
[Required]
public string City { get; set; }
[Required]
public string PostalCode { get; set; }
[Required]
public string Street { get; set; }
}
And Order class:
public class Order
{
public long Id { get; set; }
public Address FirstAddress { get; set; }
public Address SecondAddress { get; set; }
public bool RequireSecondAddress { get; set; }
}
I want to validate Order.FirstAddress all the time, but Order.SecondAddress should be validated only if Order.RequireSecondAddress is set to true.
Any ideas? :)
Chris