- 在 LoginCommandValidator 中添加空行以改善代码可读性 - 在 RegisterCommandValidator 中添加空行以改善代码可读性 - 统一验证器代码格式规范
21 lines
755 B
C#
21 lines
755 B
C#
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 个字符");
|
||
}
|
||
}
|