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

namespace TakeoutSaaS.Application.App.Stores.Validators;

/// <summary>
/// 门店列表查询验证器。
/// </summary>
public sealed class SearchStoresQueryValidator : AbstractValidator<SearchStoresQuery>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public SearchStoresQueryValidator()
    {
        // 1. 校验分页参数
        RuleFor(query => query.Page).GreaterThan(0);
        RuleFor(query => query.PageSize).InclusiveBetween(1, 200);

        // 2. 校验字符串长度
        RuleFor(query => query.Keyword).MaximumLength(64);
    }
}

