using FluentValidation;
using TakeoutSaaS.Application.App.Finance.Transactions.Queries;

namespace TakeoutSaaS.Application.App.Finance.Transactions.Validators;

/// <summary>
/// 交易流水统计查询验证器。
/// </summary>
public sealed class GetFinanceTransactionStatsQueryValidator : AbstractValidator<GetFinanceTransactionStatsQuery>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public GetFinanceTransactionStatsQueryValidator()
    {
        RuleFor(x => x.StoreId).GreaterThan(0);
        RuleFor(x => x.Keyword).MaximumLength(64);
        RuleFor(x => x)
            .Must(x => !x.StartAt.HasValue || !x.EndAt.HasValue || x.StartAt < x.EndAt)
            .WithMessage("开始时间必须早于结束时间");
    }
}
