19 lines
566 B
C#
19 lines
566 B
C#
using FluentValidation;
|
|
using SimpleTodoApiWithPg.Models;
|
|
|
|
|
|
public class RegisterRequestValidator : AbstractValidator<RegisterRequest>
|
|
{
|
|
public RegisterRequestValidator()
|
|
{
|
|
RuleFor(x => x.Username)
|
|
.NotEmpty().WithMessage("用户名是必填的。")
|
|
.Length(3, 20).WithMessage("用户名长度必须在 {MinLength} 到 {MaxLength} 之间。");
|
|
|
|
RuleFor(x => x.Email)
|
|
.NotEmpty().WithMessage("邮箱是必填的。")
|
|
.EmailAddress().WithMessage("请输入有效的邮箱地址。");
|
|
|
|
}
|
|
}
|