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

namespace TakeoutSaaS.Application.App.Stores.Validators;

/// <summary>
/// 费用预览计算查询验证器。
/// </summary>
public sealed class CalculateStoreFeeQueryValidator : AbstractValidator<CalculateStoreFeeQuery>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public CalculateStoreFeeQueryValidator()
    {
        RuleFor(x => x.StoreId).GreaterThan(0);
        RuleFor(x => x.OrderAmount).GreaterThanOrEqualTo(0);

        RuleForEach(x => x.Items).ChildRules(item =>
        {
            item.RuleFor(x => x.SkuId).GreaterThan(0);
            item.RuleFor(x => x.Quantity).GreaterThan(0);
            item.RuleFor(x => x.PackagingFee).GreaterThanOrEqualTo(0);
        });
    }
}
