c# - 使用 ASP.Net Web 应用程序的 DataAnnotation 强制执行身份密码规则
问题描述
我有一个带有 EntityFrameWorkStore 托管标识的 web 应用程序。我已经设置了这样的密码要求:
services.AddIdentity<User, IdentityRole>(o =>
{
o.Password.RequireDigit = true;
o.Password.RequiredLength = 8;
o.Password.RequireLowercase = true;
o.Password.RequireNonAlphanumeric = false;
o.Password.RequireUppercase = true;
})
有没有办法让 DataAnnotations 强制执行 Requations?我目前正在使用这样的正则表达式:
[Required]
[RegularExpression(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$")]
[DataType(DataType.Password)]
public string NewPassword { get; set; }
先感谢您
解决方案
推荐阅读
- tkinter - 无法在 python2 中查看 tkinter 表单
- angular - 将插入的值存储在数组中
- c# - UseExceptionHandler 保存上下文并重定向到控制器
- jenkins - 有没有办法为参数化构建预填充 Jenkins 构建页面?
- typescript - 如何将 WebAssembly 函数导入 TypeScript?
- ios - 如何在具有深层层次结构的领域(Swift)中优化结果更改侦听器的性能?
- sqlite - kafka jdbc 源连接器:时间戳模式不适用于 sqlite3
- javascript - setInterval() 在浏览器和 Node 之间是不同的
- r - 函数式编程:在函数内使用 broom nest->tidy->unnest 和 map
- sql-server - SSIS 脚本组件 - 获取数据流中的原始行数据