Ejemplo n.º 1
0
 public HasSearchOptionsValidator(IHasGetOptionsValidator hasGetOptionsValidator)
 {
     When(dto => dto.Limit.HasValue, () =>
     {
         RuleFor(dto => dto.Limit.Value).InclusiveBetween(SearchOptions.NoLimit, SearchOptions.MaxLimit)
         .WithMessage(Resources.HasSearchOptionsValidator_InvalidLimit.Format(SearchOptions.NoLimit,
                                                                              SearchOptions.DefaultLimit));
     });
     When(dto => dto.Offset.HasValue, () =>
     {
         RuleFor(dto => dto.Offset.Value).InclusiveBetween(SearchOptions.NoOffset, SearchOptions.MaxLimit)
         .WithMessage(Resources.HasSearchOptionsValidator_InvalidOffset.Format(SearchOptions.NoOffset,
                                                                               SearchOptions.MaxLimit));
     });
     When(dto => dto.Sort.HasValue(), () =>
     {
         RuleFor(dto => dto.Sort).Matches(SortExpression)
         .WithMessage(Resources.HasSearchOptionsValidator_InvalidSort);
     });
     When(dto => dto.Filter.HasValue(), () =>
     {
         RuleFor(dto => dto.Filter).Matches(FilterExpression)
         .WithMessage(Resources.HasSearchOptionsValidator_InvalidFilter);
     });
     When(dto => dto.Embed.HasValue(), () => { RuleFor(dto => dto).SetValidator(hasGetOptionsValidator); });
 }
Ejemplo n.º 2
0
        public GetPersonRequestValidator(IHasGetOptionsValidator hasGetOptionsValidator,
                                         IIdentifierFactory identifierFactory)
        {
            hasGetOptionsValidator.GuardAgainstNull(nameof(hasGetOptionsValidator));

            Include(hasGetOptionsValidator);
            RuleFor(dto => dto.Id).IsEntityId(identifierFactory)
            .WithMessage(Resources.AnyValidator_InvalidId);
        }