using FluentValidation;
using SIGCM2.Application.Common;

namespace SIGCM2.Application.Products.Prices.AddPrice;

/// <summary>
/// PRD-003 — FluentValidation validator para AddProductPriceCommand.
/// Inyecta TimeProvider para obtener hoy_AR (Cat2, nunca DateTime.Now).
/// FakeTimeProvider en tests garantiza determinismo.
/// </summary>
public sealed class AddProductPriceCommandValidator : AbstractValidator<AddProductPriceCommand>
{
    public AddProductPriceCommandValidator(TimeProvider timeProvider)
    {
        var today = timeProvider.GetArgentinaToday();

        RuleFor(x => x.ProductId)
            .GreaterThan(0)
            .WithMessage("ProductId debe ser un entero positivo.");

        RuleFor(x => x.Price)
            .GreaterThan(0m)
            .WithMessage("El precio debe ser mayor a cero.");

        RuleFor(x => x.PriceValidFrom)
            .GreaterThanOrEqualTo(today)
            .WithMessage($"PriceValidFrom debe ser >= hoy ({today:yyyy-MM-dd} ART). No se permiten precios con fecha retroactiva.");
    }
}
