Initial commit
This commit is contained in:
27
MealPlan.Api/Validators/RegisterRequestValidator.cs
Normal file
27
MealPlan.Api/Validators/RegisterRequestValidator.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using FluentValidation;
|
||||
using MealPlan.Api.DTOs.Auth;
|
||||
|
||||
namespace MealPlan.Api.Validators;
|
||||
|
||||
public class RegisterRequestValidator : AbstractValidator<RegisterRequestDto>
|
||||
{
|
||||
public RegisterRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.Email)
|
||||
.NotEmpty()
|
||||
.EmailAddress()
|
||||
.MaximumLength(256);
|
||||
|
||||
RuleFor(x => x.UserName)
|
||||
.MaximumLength(256)
|
||||
.When(x => !string.IsNullOrWhiteSpace(x.UserName));
|
||||
|
||||
RuleFor(x => x.Password)
|
||||
.NotEmpty()
|
||||
.MinimumLength(8)
|
||||
.MaximumLength(256)
|
||||
.Matches(@"[A-Z]").WithMessage("Password must contain at least one uppercase letter.")
|
||||
.Matches(@"[a-z]").WithMessage("Password must contain at least one lowercase letter.")
|
||||
.Matches(@"[0-9]").WithMessage("Password must contain at least one digit.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user