我使用的库"FluentValidation.AspNetCore": "6.4.0-beta3"中.netcore WebApi的一个项目。您可以在下面看到项目结构。如果我将 CurrencyDTO.cs代码放在第2节(Project FH.WebAPI)中,并且如果将相同的代码放在第1节(Class Library DTO)中,则库工作正常。要求是我必须将代码放置在Class库中FH.Common。周围有什么解决办法。我已经搜索了,但是没有找到任何东西
项目结构
CurrencyDTO.cs
[Validator(typeof(CurrencyDTOValidator))]
public class CurrencyDTO
{
public int Id { get { return CurrencyId; } }
public int CurrencyId { get; set; }
public string Name { get; set; }
public string Symbol { get; set; }
}
public class CurrencyDTOValidator : AbstractValidator<CurrencyDTO>
{
public CurrencyDTOValidator()
{
RuleFor(x => x.Name).NotEmpty().NotNull().WithMessage("The currency 'Name' is required.")
.Length(0, 250).WithMessage("The currency 'Name' cannot be more than 250 characters.");
RuleFor(x …Run Code Online (Sandbox Code Playgroud)