FluentValidation-如果包含失败,则停止执行下一条规则

时间:2019-08-19 19:27:02

标签: fluentvalidation

我有以下代码。如果basevalidator中有错误,我不想执行RuleFor createdby。我该怎么办?

 public GroupValidator()
    {
        Include(new BaseValidator());

        RuleFor(x => x.CreatedBy)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty()
            .Length(2, 500).WithMessage("Created by should not be empty and between 2 and 500 characters.");
    }

0 个答案:

没有答案