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

namespace TakeoutSaaS.Application.App.Products.Validators;

/// <summary>
/// 商品选择器查询验证器。
/// </summary>
public sealed class SearchProductPickerQueryValidator : AbstractValidator<SearchProductPickerQuery>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public SearchProductPickerQueryValidator()
    {
        RuleFor(x => x.StoreId).GreaterThan(0);
        RuleFor(x => x.CategoryId).GreaterThan(0).When(x => x.CategoryId.HasValue);
        RuleFor(x => x.Keyword).MaximumLength(64);
        RuleFor(x => x.Limit).InclusiveBetween(1, 500);
    }
}
