流利验证永远无法在任何条件下使用MVC 5

我在我的项目中使用了流利的验证,但是它在任何条件下都无法使用。在没有任何条件的简单情况下,它可以正常工作。但是,当我使用dependentRule或进行条件处理时,它永远不会起作用。在经历了Fluent文档之后,我尝试了100多次,但确实无济于事,这真令人沮丧。请任何人知道为什么在条件不触发时有这种情况,并且有任何方法可以查看这些值。

public class Employee
  {
    public string Qualification { get; set; }
    public bool IsRebadged { get; set; }

  }
public class EmployeePersonalDetailsValidator : AbstractValidator<Employee>
{
    public EmployeePersonalDetailsValidator()
    {

        Qualification();
    }
    public void Qualification()
    {
        RuleFor(dto => dto.Qualification)
         .NotEmpty()
         .When(d => d.IsRebadged == true)
         .WithMessage("Please get your Qualification updated");
    }




 <div class="col-md-3 form-group">
                    <label>Qualification</label>
                    @Html.TextBoxFor(m => m.Qualification,new { @class = "form-control",@readonly = "readonly" })                    
                    @Html.ValidationmessageFor(m => m.Qualification,"",new { @class = "text-danger" })

                </div>

FilterConfig.cs

 public class FilterConfig
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            FluentValidationmodelValidatorProvider.Configure();
        }
    }

我已经在Global.asax中配置了相同的设置,但无法正常工作 Global.asax

 protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(Routetable.Routes);
            BundleConfig.RegisterBundles(Bundletable.Bundles);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            AntiForgeryConfig.UniqueclaimTypeIdentifier = ClaimTypes.NameIdentifier;
            FluentValidationmodelValidatorProvider.Configure();

        }
zhongnancrack 回答:流利验证永远无法在任何条件下使用MVC 5

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3097350.html

大家都在问