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

namespace TakeoutSaaS.Application.App.Inventory.Validators;

/// <summary>
/// 库存调整命令验证器。
/// </summary>
public sealed class AdjustInventoryCommandValidator : AbstractValidator<AdjustInventoryCommand>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public AdjustInventoryCommandValidator()
    {
        RuleFor(x => x.StoreId).GreaterThan(0);
        RuleFor(x => x.ProductSkuId).GreaterThan(0);
        RuleFor(x => x.QuantityDelta).NotEqual(0);
        RuleFor(x => x.SafetyStock).GreaterThanOrEqualTo(0).When(x => x.SafetyStock.HasValue);
    }
}
