📜  dataannotations 电话号码验证 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:04.310000             🧑  作者: Mango

代码示例1
[Required(ErrorMessage = "You must provide a phone number")]
[Display(Name = "Home Phone")]
[DataType(DataType.PhoneNumber)]
[RegularExpression(@"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$", ErrorMessage = "Not a valid phone number")]
public string PhoneNumber { get; set; }