I need to declare many model properties that have the same attributes. I was wondering if there is a way to do this in MVC.
[Required] [Range(0, 4, ErrorMessage = "Integrity is required.")] public int Integrity { get; set; } [Required] [Range(0, 4, ErrorMessage = "Empathy is required.")] public int Empathy { get; set; }
I have a bunch of fields that use these 2 attributes (a range is also required). The only difference is the name of the properties. Is there a way to declare them so that they do not repeat?
Datbear
source share