mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-14 17:54:42 +00:00
21 lines
735 B
C#
21 lines
735 B
C#
using FluentValidation;
|
|
|
|
namespace Features.Users.Commands.Account.UpdateUsername;
|
|
|
|
/// <summary>Validates <see cref="UpdateUsernameCommand" />, mirroring the username rules in <c>RegisterUserValidator</c>.</summary>
|
|
public class UpdateUsernameValidator : AbstractValidator<UpdateUsernameCommand>
|
|
{
|
|
public UpdateUsernameValidator()
|
|
{
|
|
RuleFor(x => x.NewUsername)
|
|
.NotEmpty()
|
|
.WithMessage("Username is required")
|
|
.Length(3, 64)
|
|
.WithMessage("Username must be between 3 and 64 characters")
|
|
.Matches("^[a-zA-Z0-9._-]+$")
|
|
.WithMessage(
|
|
"Username can only contain letters, numbers, dots, underscores, and hyphens"
|
|
);
|
|
}
|
|
}
|