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

namespace TakeoutSaaS.Application.App.Stores.Validators;

/// <summary>
/// 更新配送区域命令验证器。
/// </summary>
public sealed class UpdateStoreDeliveryZoneCommandValidator : AbstractValidator<UpdateStoreDeliveryZoneCommand>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public UpdateStoreDeliveryZoneCommandValidator()
    {
        RuleFor(x => x.DeliveryZoneId).GreaterThan(0);
        RuleFor(x => x.StoreId).GreaterThan(0);
        RuleFor(x => x.ZoneName).NotEmpty().MaximumLength(64);
        RuleFor(x => x.PolygonGeoJson).NotEmpty();
        RuleFor(x => x.MinimumOrderAmount).GreaterThanOrEqualTo(0).When(x => x.MinimumOrderAmount.HasValue);
        RuleFor(x => x.DeliveryFee).GreaterThanOrEqualTo(0).When(x => x.DeliveryFee.HasValue);
        RuleFor(x => x.EstimatedMinutes).GreaterThan(0).When(x => x.EstimatedMinutes.HasValue);
        RuleFor(x => x.Color).MaximumLength(32);
        RuleFor(x => x.Priority).GreaterThanOrEqualTo(0);
        RuleFor(x => x.SortOrder).GreaterThanOrEqualTo(0);
    }
}
