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

namespace TakeoutSaaS.Application.App.Tenants.Validators;

/// <summary>
/// 更新公告命令验证器。
/// </summary>
public sealed class UpdateAnnouncementCommandValidator : AbstractValidator<UpdateTenantAnnouncementCommand>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public UpdateAnnouncementCommandValidator()
    {
        RuleFor(x => x.Title)
            .NotEmpty()
            .MaximumLength(128);

        RuleFor(x => x.Content)
            .NotEmpty();

        RuleFor(x => x.RowVersion)
            .NotNull()
            .Must(rowVersion => rowVersion != null && rowVersion.Length > 0)
            .WithMessage("RowVersion 不能为空");
    }
}
