I have a person class, which for the purpose of this question, is simply
public class Person
{
[Required(ErrorMessage = "***")]
[Display(Name = "Your full name")]
public string Name { get; set; }
}
I inherit this is in my Complaints class
public class Complaints : Person
{
[Required(ErrorMessage = "***")]
[Display(Name = "Detail of the issue")]
public string Detail{ get; set; }
}
Everything works as expected.
The problem is, we now want the user to not need to entire their name but, I have it already set to required.
Since my Person class is used else where, I can't change the Required attribute.
How can I override the DataAnnotations
in my derived class? I'm guessing (which also explains my confusion) because the DataAnnotation
belongs to the property that I can't just override the DataAnnocation
and have to override the entire property?