Data annotations for validating an incoming model in MVC:
public class ValidNumber
{
[RegularExpression(@"^\d+$", ErrorMessage = "*")]
public string number { get; set; }
}
Do I need to create my own class to test, List<string>or can I do something like this? What code could I write in C # to add a Regex checker for a list of strings?
public class ValidNumberList
{
[RegularExpression(@"^\d+$", ErrorMessage = "*")]
public List<string> numbers { get; set; }
}
source
share