xiangning 9d2bd7e1a5 style(auth): 格式化验证器代码样式
- 在 LoginCommandValidator 中添加空行以改善代码可读性
- 在 RegisterCommandValidator 中添加空行以改善代码可读性
- 统一验证器代码格式规范
2026-07-02 14:55:23 +08:00

21 lines
755 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using FluentValidation;
using BuildFlow.Application.Auth.Commands;
namespace BuildFlow.Application.Auth.Validators;
/// <summary>
/// 登录Command的请求校验器(FluentValidation)。
/// </summary>
public class LoginCommandValidator : AbstractValidator<LoginCommand>
{
public LoginCommandValidator()
{
RuleFor(x => x.Username).NotEmpty().WithMessage("用户名不能为空")
.MaximumLength(50).WithMessage("用户名长度不能超过 50 个字符")
.Must(u => u == u.Trim()).WithMessage("用户名前后不能有空格");
RuleFor(x => x.Password).NotEmpty().WithMessage("密码不能为空")
.MaximumLength(100).WithMessage("密码长度不能超过 100 个字符");
}
}