PlanTempusApp/PlanTempus.Components/Accounts/Create/CreateAccountValidator.cs

24 lines
912 B
C#
Raw Permalink Normal View History

2025-03-04 17:13:02 +01:00
using FluentValidation;
namespace PlanTempus.Components.Accounts.Create
2025-03-04 17:13:02 +01:00
{
public class CreateAccountValidator : AbstractValidator<CreateAccountCommand>
2025-03-04 17:13:02 +01:00
{
public CreateAccountValidator()
2025-03-04 17:13:02 +01:00
{
RuleFor(x => x.Email)
.NotEmpty().WithMessage("Email skal angives.")
.EmailAddress().WithMessage("Ugyldig emailadresse.")
.MaximumLength(256).WithMessage("Email må højst være 256 tegn.");
RuleFor(x => x.Password)
.NotEmpty().WithMessage("Password skal angives.")
.MinimumLength(8).WithMessage("Password skal være mindst 8 tegn.")
.Matches("[A-Z]").WithMessage("Password skal indeholde mindst ét stort bogstav.")
.Matches("[a-z]").WithMessage("Password skal indeholde mindst ét lille bogstav.")
.Matches("[0-9]").WithMessage("Password skal indeholde mindst ét tal.")
.Matches("[^a-zA-Z0-9]").WithMessage("Password skal indeholde mindst ét specialtegn.");
}
}
}