我设置的值MinimunLenghtValidator修改ApplicationUserManager类我怎样才能得到MinimumLengthValidator的RequiredLength值(Microsoft.AspNet.Identity与密码)
public class ApplicationUserManager : UserManager<ApplicationUser>
{
public ApplicationUserManager() : base(new UserStore<ApplicationUser>(new DataContext()))
{
PasswordValidator = new MinimumLengthValidator(8);
}
}
现在,我希望检索值使用,例如,在AccountViewModel验证(放眼整个StringLength线)
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = IWANTTHEVALUEHERE)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
任何人都可以告诉我怎么去的价值。
Regards
谢谢斯科特,这对我的问题很有用。只是好奇心,你知道是否有可能获得MinimunLenghtValidator属性的值吗? – RLB
@RLB:我更新了答案,以显示如何获得您想要的价值。你只是无法从'StringLength'属性中完成。 –