There are multiple data annotation attributes in C#, such as [Required], [MaxLength] etc, each of which has it own default validation message.
What I trying to achieve here is to override the default validation message without inheriting the attribute in following way. I need a base for this, and not simply put [MaxLength(5, Error Message = "Custom Error Message")]. Put in in simple term, when i decorate with [MaxLength(5)], the output of model validation error should be "Custom Error Message" instead of default error message. What I have achieve now is need to use [MyMaxLength(5)] instead.
public class MyMaxLengthAttribute : MaxLengthAttribute
{
public MyMaxLengthAttribute(int length) : base(length)
{
ErrorMessage = "Custom Error Message"
}
}