lundi 17 août 2020

C# Reflection: Is it possible to get validation attributes from all properties and show them to the user if there is a validation?

I generate my views genericly with reflection so I am wondering if it is possible to get the validation attributes for all the properties of a class and then make them show in the view if there is a violation

For example:

    public class Person 
    {
        [Range(0,300)]
        [Required(ErrorMessage ="Please provide a weight")]
        public double Weight { get; set; }
    }





Aucun commentaire:

Enregistrer un commentaire