I have the following property in my view model:
[Required]
[MaxLength(12)]
[MinLength(1)]
[RegularExpression("[^0-9]", ErrorMessage = "UPRN must be numeric")]
public string Uprn { get; set; }
Regardless of Uprn
being a string
, I want to throw a validation error if there is anything other than numbers entered into the Uprn box on page submit.
With the above, I am getting the error "UPRN must be numeric" whether its a string or int
What's going on here?