I am creating a custom LabelFor
. Inside it want to get the DataAnnotations
properties linked to attribute mainly DataAnnotations
created by me and I'm not getting. Example: Obrigatorio
I need to get the values of DataAnnotations
for the labelFor leave the fields in bold when required. And depending on the validation, leave customized with styles.
My Class
public class GrupoRisco : IEntidadeBase
{
[Key]
public int GrupoRiscoID { get; set; }
[Obrigatorio]
[Display(Name="Descrição")]
public string Descricao { get; set; }
}
My Custom Atribute
public class Obrigatorio : RequiredAttribute
{
public Obrigatorio()
{
ErrorMessage = "* Obrigatório";
}
}
The attribute above is simple, but will create complex attributes.