Backend login and register

This commit is contained in:
2026-02-19 13:49:01 +01:00
parent 0b6bb019b6
commit 93a78e4614
62 changed files with 11588 additions and 13 deletions

View File

@@ -0,0 +1,29 @@
using Application.Models;
using FluentValidation;
namespace Application.Validators;
public class RegisterRequestValidator : AbstractValidator<RegisterRequest>
{
public RegisterRequestValidator()
{
RuleFor(x => x.Email)
.NotEmpty().WithMessage("{PropertyName} is required.")
.EmailAddress().WithMessage("{PropertyName} is not valid.");
RuleFor(x => x.Password)
.NotEmpty().WithMessage("{PropertyName} is required.")
.MinimumLength(10).WithMessage("{PropertyName} must be at least 10 characters long.")
.Matches("[A-Z]").WithMessage("{PropertyName} must contain at least one uppercase letter.")
.Matches("[a-z]").WithMessage("{PropertyName} must contain at least one lowercase letter.")
.Matches("[0-9]").WithMessage("{PropertyName} must contain at least one digit.")
.Matches("[^a-zA-Z0-9]").WithMessage("{PropertyName} must contain at least one special character.");
RuleFor(x => x.Username)
.NotEmpty().WithMessage("{PropertyName} is required.")
.MinimumLength(3).WithMessage("{PropertyName} must be at least 3 characters long.")
.MaximumLength(20).WithMessage("{PropertyName} must not exceed 20 characters.")
.Matches("^[a-zA-Z0-9_]*$")
.WithMessage("{PropertyName} can only contain letters, numbers, and underscores.");
}
}