// // Copyright (c) alveus.dev. All rights reserved. Licensed under the MIT License. // using Astral.Services.Dtos; using FluentValidation; using Injectio.Attributes; namespace Astral.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"); } }