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

namespace TakeoutSaaS.Application.App.Stores.Validators;

/// <summary>
/// 创建配送区域命令验证器。
/// </summary>
public sealed class CreateStoreDeliveryZoneCommandValidator : AbstractValidator<CreateStoreDeliveryZoneCommand>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public CreateStoreDeliveryZoneCommandValidator()
    {
        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.SortOrder).GreaterThanOrEqualTo(0);
    }
}
