Fluent Validation 中的密码验证器

Password Validator in Fluent Validation

如何使用 Fluent Validation 验证密码? 例如,使用数据注释,我们可以将此属性 [Password] 设置为密码 属性how to get the same result but using流畅的验证???

当我在密码框中输入时,当我使用数据注释时,它显示黑圈,如何做同样但使用流畅的验证?

您可以使用相等验证器来检查 属性 是否等于另一个 属性 的值,例如

RuleFor(customer => customer.Password)
    .Equal(customer => customer.PasswordConfirmation);

Equal Validator Documentation

要创建隐藏输入的密码输入字段,请使用 type="password" 例如

<input type="password" @asp-for="Model.Password">

Input field documentation