首页 > 解决方案 > 基于 2 个列表项的流利验证

问题描述

我的班级有 2 个列表,我需要一个基于 2 的验证规则

public class StdQA{
      public int Qid {get; set;}
      public int responsetypeid {get; set;}
  }

public class AddlQA{

    public string Qtext {get; set;}
    public int responsetypeid {get; set;}

}

public class CandidateQA{

    public List<StdQA> StdQAs

    public List<AddlQA> AddlQAs
}

我需要使用 FluentValidation 的验证规则如下:对于候选 QA,StdQAs 和 AddlQAs 中 responsetypeid = 3 的项目计数总和应 >=5。我们还需要确保对于 AddlQA where responsetypeid = 3 Qtext 不为空或空白。我们如何在 c# .Net 中使用 FluentValidation 来实现这一点

标签: c#fluentvalidation

解决方案


推荐阅读