fix: 自助注册租户账号仅允许字母数字

This commit is contained in:
2025-12-12 22:18:33 +08:00
parent 8b18d0cb96
commit 456b575596
2 changed files with 23 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ public sealed record SelfRegisterTenantCommand : IRequest<SelfRegisterResultDto>
/// </summary>
[Required]
[StringLength(64)]
[RegularExpression("^[A-Za-z0-9]+$", ErrorMessage = "")]
public string AdminAccount { get; init; } = string.Empty;
/// <summary>

View File

@@ -0,0 +1,22 @@
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("登录账号仅允许大小写字母和数字");
}
}