How do i set the min and max annotation on a Property, with Data Annotations Extensions?
This is what i have tried:
[Required(ErrorMessage = "Dette felt er påkrævet!")]
[Digits(ErrorMessage = "Indtast kun cifre")]
[Min(8, ErrorMessage = "Brugernavnet skal være 8 tegn langt.")]
[Max(8, ErrorMessage = "Brugernavnet skal være 8 tegn langt.")]
[Display(Name = "Brugernavn")]
public string UserName { get; set; }
I get the following error:
Validation type names in unobtrusive client validation rules must be unique. The following validation type was seen more than once: range
Min and Max are for decimal types. For strings you use the
[StringLength]or the[RegularExpression]attributes: