using FluentValidation;
using TakeoutSaaS.Application.App.Deliveries.Commands;

namespace TakeoutSaaS.Application.App.Deliveries.Validators;

/// <summary>
/// 更新配送单命令验证器。
/// </summary>
public sealed class UpdateDeliveryOrderCommandValidator : AbstractValidator<UpdateDeliveryOrderCommand>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public UpdateDeliveryOrderCommandValidator()
    {
        RuleFor(x => x.DeliveryOrderId).GreaterThan(0);
        RuleFor(x => x.OrderId).GreaterThan(0);
        RuleFor(x => x.ProviderOrderId).MaximumLength(64);
        RuleFor(x => x.CourierName).MaximumLength(64);
        RuleFor(x => x.CourierPhone).MaximumLength(32);
        RuleFor(x => x.FailureReason).MaximumLength(256);
        RuleFor(x => x.DeliveryFee).GreaterThanOrEqualTo(0).When(x => x.DeliveryFee.HasValue);
    }
}
