using FluentValidation; using Galaeth.Services.Dtos; using Injectio.Attributes; namespace Galaeth.Services.Validators; /// /// Validation for . /// [RegisterScoped] public class AuthenticateUserValidator : AbstractValidator { private const int MinimumUsernameLength = 4; /// /// Initializes a new instance of the class. /// public AuthenticateUserValidator() { RuleFor(dto => dto.Username).NotEmpty().WithMessage("Username must be provided") .MinimumLength(MinimumUsernameLength) .WithMessage("Username must be a minimum of " + MinimumUsernameLength + " characters") .Matches(@"^[A-Za-z0-9._-]+$") .WithMessage("Username can only contain letters, numbers, hyphens, dashes and periods."); RuleFor(dto => dto.Password).NotEmpty().WithMessage("Password must be provided"); } }