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

namespace TakeoutSaaS.Application.App.Products.Validators;

/// <summary>
/// 分类管理列表查询验证器。
/// </summary>
public sealed class GetProductCategoryManageListQueryValidator : AbstractValidator<GetProductCategoryManageListQuery>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public GetProductCategoryManageListQueryValidator()
    {
        RuleFor(x => x.StoreId).GreaterThan(0);
        RuleFor(x => x.Status)
            .Must(status => string.IsNullOrWhiteSpace(status) || ProductCategoryManageMapping.IsValidStatus(status))
            .WithMessage("status 必须为空或 enabled/disabled");
        RuleFor(x => x.Keyword).MaximumLength(64);
    }
}
