using FluentValidation;

namespace Baya.Application.Features.Payouts.Commands.GeneratePayoutBatch;

public sealed class GeneratePayoutBatchCommandValidator : AbstractValidator<GeneratePayoutBatchCommand>
{
    public GeneratePayoutBatchCommandValidator()
    {
        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 batch a future period.
        RuleFor(x => x.PeriodEnd)
            .Must(pe => pe <= DateOnly.FromDateTime(DateTime.UtcNow.Date))
            .WithMessage("period_end cannot be in the future.");
    }
}
