【发布时间】:2020-05-25 10:55:43
【问题描述】:
我希望通过 Fluent Validation 验证二级密码不能与第一个密码相同
RuleFor(x => x.FirstPassword).NotEqual(x => x.SecondPassword).WithMessage("Second password are not allow to same as first password.");
FirstPassword 输入 => 123456
第二个密码输入 => 123456
都输入了相同的密码,但验证没有触发
更新
使用Must尝试另一种方式,但仍然无法触发
RuleFor(x => x.FirstPassword).Must((x, y) => y != x.SecondPassword).WithMessage("Second password are not allow to same as first password.");
【问题讨论】:
-
您希望在哪里验证控件?客户端不支持某些验证。 docs.fluentvalidation.net/en/latest/…
标签: c# asp.net asp.net-mvc asp.net-core fluentvalidation