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

namespace TakeoutSaaS.Application.App.Products.Validators;

/// <summary>
/// 分类排序命令验证器。
/// </summary>
public sealed class SortProductCategoryCommandValidator : AbstractValidator<SortProductCategoryCommand>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public SortProductCategoryCommandValidator()
    {
        RuleFor(x => x.StoreId).GreaterThan(0);
        RuleFor(x => x.Items).NotNull();
        RuleForEach(x => x.Items).SetValidator(new SortProductCategoryItemValidator());
    }
}

/// <summary>
/// 分类排序项验证器。
/// </summary>
public sealed class SortProductCategoryItemValidator : AbstractValidator<SortProductCategoryItem>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public SortProductCategoryItemValidator()
    {
        RuleFor(x => x.CategoryId).GreaterThan(0);
        RuleFor(x => x.Sort).GreaterThan(0);
    }
}
