using FluentValidation;

namespace Baya.Application.Features.Payouts.Queries.ComputeEligibleEarnings;

public sealed class ComputeEligibleEarningsQueryValidator : AbstractValidator<ComputeEligibleEarningsQuery>
{
    public ComputeEligibleEarningsQueryValidator()
    {
        RuleFor(x => x.PeriodStart)
            .LessThanOrEqualTo(x => x.PeriodEnd)
            .WithMessage("period_start must be on or before period_end.");

        // A payout window must be closed — never preview a future period.
        RuleFor(x => x.PeriodEnd)
            .Must(pe => pe <= DateOnly.FromDateTime(DateTime.UtcNow.Date))
            .WithMessage("period_end cannot be in the future.");
    }
}
