31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
using FluentValidation;
|
|
using SIGCM2.Application.Common;
|
|
|
|
namespace SIGCM2.Application.Pricing.ChargeableChars.SchedulePrice;
|
|
|
|
/// <summary>
|
|
/// PRC-001 — FluentValidation validator for SchedulePriceChangeCommand.
|
|
/// Surface validation only (price > 0, validFrom >= today_AR, id > 0).
|
|
/// Forward-only check (ValidFrom > existing row's ValidFrom) is performed in the handler
|
|
/// where the existing entity is loaded.
|
|
/// </summary>
|
|
public sealed class SchedulePriceChangeCommandValidator : AbstractValidator<SchedulePriceChangeCommand>
|
|
{
|
|
public SchedulePriceChangeCommandValidator(TimeProvider timeProvider)
|
|
{
|
|
var today = timeProvider.GetArgentinaToday();
|
|
|
|
RuleFor(x => x.Id)
|
|
.GreaterThan(0L)
|
|
.WithMessage("Id debe ser un entero positivo.");
|
|
|
|
RuleFor(x => x.PricePerUnit)
|
|
.GreaterThan(0m)
|
|
.WithMessage("PricePerUnit debe ser > 0.");
|
|
|
|
RuleFor(x => x.ValidFrom)
|
|
.GreaterThanOrEqualTo(today)
|
|
.WithMessage($"ValidFrom debe ser >= hoy ({today:yyyy-MM-dd} ART).");
|
|
}
|
|
}
|