C# FluentValidation MustAsync子级丢失父属性值

C# FluentValidation MustAsync子级丢失父属性值,c#,fluentvalidation,C#,Fluentvalidation,在父验证程序中,我们有多个子验证。这样宣布 RuleFor(x => x.Country) .Cascade(CascadeMode.StopOnFirstFailure) .NotEmpty().WithMessage(ValidationErrorMessageCodes.CountryRequired) .SetValidator(new CountryValidator(countryS

在父验证程序中,我们有多个子验证。这样宣布

            RuleFor(x => x.Country)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty().WithMessage(ValidationErrorMessageCodes.CountryRequired)
            .SetValidator(new CountryValidator(countryService)).WithMessage(ValidationErrorMessageCodes.CountryDoesNotExist);
在CountryValidator中,我们设置了这个

            RuleFor(c => c)
            .MustAsync(async candidateCountryCode =>
                (await countryService.GetAll())
                .Any(x => string.Equals(x.Code, candidateCountryCode, StringComparison.CurrentCultureIgnoreCase)))
            .WithMessage(ValidationErrorMessageCodes.CountryDoesNotExist);
当我们使用Validate和Must时,这一切都很好,但现在我们使用ValidateAsync和MustAsync,以满足Api中更深层次的调用,所有调用都使用异步任务

由于以这种方式进行更改,我们得到以下错误消息

无法为表达式c=>c自动确定属性名。请通过调用“WithName”指定自定义属性名称

如果我将.WithName(“Country”)添加到子验证器中,那么返回的参数名是“Country.Country”,而以前它只是“Country”

两者都从AbstractValidator继承,父对象有一个RequestModel,子对象正好是


如何才能返回“国家/地区”错误?

升级到最新版本的FluentValidation解决了此问题

升级到最新版本的FluentValidation解决了此问题