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

namespace TakeoutSaaS.Application.App.Tenants.Validators;

/// <summary>
/// 自助注册租户命令验证器。
/// </summary>
public sealed class SelfRegisterTenantCommandValidator : AbstractValidator<SelfRegisterTenantCommand>
{
    /// <summary>
    /// 初始化验证规则。
    /// </summary>
    public SelfRegisterTenantCommandValidator()
    {
        RuleFor(x => x.AdminAccount)
            .NotEmpty()
            .MaximumLength(64)
            .Matches("^[A-Za-z0-9]+$")
            .WithMessage("登录账号仅允许大小写字母和数字");
        RuleFor(x => x.Country).MaximumLength(64);
        RuleFor(x => x.Province).MaximumLength(64);
        RuleFor(x => x.City).MaximumLength(64);
        RuleFor(x => x.Address).MaximumLength(256);
    }
}
