From 456b575596fc8047ec6d95c5bf55cf8fb761cc61 Mon Sep 17 00:00:00 2001 From: MSuMshk <2039814060@qq.com> Date: Fri, 12 Dec 2025 22:18:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=87=AA=E5=8A=A9=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E8=B4=A6=E5=8F=B7=E4=BB=85=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E5=AD=97=E6=AF=8D=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/SelfRegisterTenantCommand.cs | 1 + .../SelfRegisterTenantCommandValidator.cs | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/Application/TakeoutSaaS.Application/App/Tenants/Validators/SelfRegisterTenantCommandValidator.cs diff --git a/src/Application/TakeoutSaaS.Application/App/Tenants/Commands/SelfRegisterTenantCommand.cs b/src/Application/TakeoutSaaS.Application/App/Tenants/Commands/SelfRegisterTenantCommand.cs index 259a004..cddd7ed 100644 --- a/src/Application/TakeoutSaaS.Application/App/Tenants/Commands/SelfRegisterTenantCommand.cs +++ b/src/Application/TakeoutSaaS.Application/App/Tenants/Commands/SelfRegisterTenantCommand.cs @@ -14,6 +14,7 @@ public sealed record SelfRegisterTenantCommand : IRequest /// [Required] [StringLength(64)] + [RegularExpression("^[A-Za-z0-9]+$", ErrorMessage = "登录账号仅允许大小写字母和数字")] public string AdminAccount { get; init; } = string.Empty; /// diff --git a/src/Application/TakeoutSaaS.Application/App/Tenants/Validators/SelfRegisterTenantCommandValidator.cs b/src/Application/TakeoutSaaS.Application/App/Tenants/Validators/SelfRegisterTenantCommandValidator.cs new file mode 100644 index 0000000..411d834 --- /dev/null +++ b/src/Application/TakeoutSaaS.Application/App/Tenants/Validators/SelfRegisterTenantCommandValidator.cs @@ -0,0 +1,22 @@ +using FluentValidation; +using TakeoutSaaS.Application.App.Tenants.Commands; + +namespace TakeoutSaaS.Application.App.Tenants.Validators; + +/// +/// 自助注册租户命令验证器。 +/// +public sealed class SelfRegisterTenantCommandValidator : AbstractValidator +{ + /// + /// 初始化验证规则。 + /// + public SelfRegisterTenantCommandValidator() + { + RuleFor(x => x.AdminAccount) + .NotEmpty() + .MaximumLength(64) + .Matches("^[A-Za-z0-9]+$") + .WithMessage("登录账号仅允许大小写字母和数字"); + } +}