public FluentPostFilterValidator(IReadSocialListsRepository readSocialListsRepository,
                                             IReadPeopleRepository readPeopleRepository)
            {
                _readSocialListsRepository = readSocialListsRepository;
                _readPeopleRepository      = readPeopleRepository;

                RuleFor(post => post.DateRange)
                .SetValidator(new DateRangeValidator());

                RuleFor(post => post.Page)
                .SetValidator(new PageValidator());

                When(post => !string.IsNullOrWhiteSpace(post.Network), () =>
                {
                    RuleFor(post => post.Network)
                    .Must(network => _validateNetworks.Contains(network.ToLower()))
                    .WithMessage("Invalid network");
                });

                When(post => post.Lists?.Count(x => !string.IsNullOrWhiteSpace(x)) > 0, () =>
                {
                    RuleForEach(post => post.Lists)
                    .MustAsync(BeAExistingListAsync)
                    .WithMessage("Invalid list");
                });

                When(post => post.AccountNames?.Count(x => !string.IsNullOrWhiteSpace(x)) > 0, () =>
                {
                    RuleForEach(post => post.AccountNames)
                    .MustAsync(BeAExistingAuthorAsync)
                    .WithMessage("Invalid account name");
                });
            }
예제 #2
0
 public PostQuery(IReadPostRepository readPostRepository,
                  IReadSocialListsRepository readSocialListsRepository,
                  IPostSearchRequestValidator postFilterValidator)
 {
     _readPostRepository        = readPostRepository;
     _postFilterValidator       = postFilterValidator;
     _readSocialListsRepository = readSocialListsRepository;
 }
예제 #3
0
 public SocialListsQuery(IReadSocialListsRepository readSocialListsRepository)
 {
     _readSocialListsRepository = readSocialListsRepository;
 }
 public PostSearchRequestValidator(IReadSocialListsRepository readSocialListsRepository,
                                   IReadPeopleRepository readPeopleRepository)
 {
     _validator = new FluentPostFilterValidator(readSocialListsRepository, readPeopleRepository);
 }