I'm developing a little ERP to my company and I crashed into a problem about validation:
I have self property object like:
public class Person
{
[Required]
public string Name { get; set; }
public int Phone { get; set; }
public bool HasContact { get; set; }
public Person Contact { get; set; }
}
If HasContact is false, I don`t want put a Contact. If is true, I want.
The problem is my ModelState never is Valid, because Name is Required and Contact self implement Person.
I would like to set condition if HasContact is true, my application try validate the Contact property. If is not, set Valid and execute controller correct.
Is it possible or am I crazy?