using FluentValidation;

namespace CMSMicroservice.Application.CommissionCQ.Queries.GetMyCommissionPayouts;

public class GetMyCommissionPayoutsQueryValidator : AbstractValidator<GetMyCommissionPayoutsQuery>
{
    public GetMyCommissionPayoutsQueryValidator()
    {
        RuleFor(x => x.PaginationState)
            .NotNull()
            .WithMessage("Pagination state is required");

        When(x => x.PaginationState != null, () =>
        {
            RuleFor(x => x.PaginationState!.PageNumber)
                .GreaterThan(0)
                .WithMessage("Page number must be greater than 0");

            RuleFor(x => x.PaginationState!.PageSize)
                .GreaterThan(0)
                .LessThanOrEqualTo(100)
                .WithMessage("Page size must be between 1 and 100");
        });
    }
}
