31 lines
No EOL
739 B
C#
31 lines
No EOL
739 B
C#
using FluentValidation;
|
|
using Mizuki.Dtos;
|
|
|
|
namespace Mizuki.Validators;
|
|
|
|
/// <summary>
|
|
/// The validator for the login data.
|
|
/// </summary>
|
|
public class LoginDataValidator : AbstractValidator<LoginDataDto>
|
|
{
|
|
/// <summary>
|
|
/// Constructs the ruleset for the LoginDataValidator.
|
|
/// </summary>
|
|
public LoginDataValidator()
|
|
{
|
|
RuleFor(x => x.Username)
|
|
.NotEmpty();
|
|
|
|
RuleFor(x => x.Username)
|
|
.Matches("^[a-zA-Z0-9_.]*$");
|
|
|
|
RuleFor(x => x.Password)
|
|
.NotEmpty();
|
|
|
|
RuleFor(x => x.Password)
|
|
.MinimumLength(8);
|
|
|
|
RuleFor(x => x.Password)
|
|
.Matches(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@#$%^&*!])[A-Za-z\d@#$%^&*!]{8,}$");
|
|
}
|
|
} |