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

namespace TakeoutSaaS.Application.App.Products.Validators;

/// <summary>
/// 替换价格策略验证器。
/// </summary>
public sealed class ReplaceProductPricingRulesCommandValidator : AbstractValidator<ReplaceProductPricingRulesCommand>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public ReplaceProductPricingRulesCommandValidator()
    {
        RuleFor(x => x.ProductId).GreaterThan(0);
        RuleForEach(x => x.PricingRules).ChildRules(rule =>
        {
            rule.RuleFor(x => x.Price).GreaterThan(0);
            rule.RuleFor(x => x.ConditionsJson).NotEmpty();
        });
    }
}
