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

namespace TakeoutSaaS.Application.App.Stores.Validators;

/// <summary>
/// 自提配置验证器。
/// </summary>
public sealed class UpsertStorePickupSettingCommandValidator : AbstractValidator<UpsertStorePickupSettingCommand>
{
    /// <summary>
    /// 初始化规则。
    /// </summary>
    public UpsertStorePickupSettingCommandValidator()
    {
        RuleFor(x => x.StoreId).GreaterThan(0);
        RuleFor(x => x.AllowDaysAhead).GreaterThanOrEqualTo(0);
        RuleFor(x => x.DefaultCutoffMinutes).GreaterThanOrEqualTo(0);
        RuleFor(x => x.MaxQuantityPerOrder).GreaterThan(0).When(x => x.MaxQuantityPerOrder.HasValue);
        RuleFor(x => x.FineRuleJson).MaximumLength(20000);
    }
}
