我正在MVC4中使用数据注释进行模型验证,目前正在使用StringLengthAttribute,但是我不想指定最大值(当前设置为50),但是想要指定最小字符串长度值。
是否有一种方法只指定最小长度?也许可以使用另一个属性?
我的当前代码是:
[Required]
[DataType(DataType.Password)]
[Display(Name = "Confirm New Password")]
[StringLength(50, MinimumLength = 7)]
[CompareAttribute("NewPassword", ErrorMessage = "The New Password and Confirm New Password fields did not match.")]
public string ConfirmNewPassword { get; set; }