project reorganized
This commit is contained in:
@@ -1,26 +1,13 @@
|
||||
using FluentValidation;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database;
|
||||
using WatchIt.Shared.Models.Accounts.Authenticate;
|
||||
using WatchIt.Common.Model.Accounts;
|
||||
|
||||
namespace WatchIt.WebAPI.Validators.Accounts
|
||||
namespace WatchIt.WebAPI.Validators.Accounts;
|
||||
|
||||
public class AuthenticateRequestValidator : AbstractValidator<AuthenticateRequest>
|
||||
{
|
||||
public class AuthenticateRequestValidator : AbstractValidator<AuthenticateRequest>
|
||||
public AuthenticateRequestValidator()
|
||||
{
|
||||
#region CONSTRUCTOR
|
||||
|
||||
public AuthenticateRequestValidator(DatabaseContext database)
|
||||
{
|
||||
RuleFor(x => x.UsernameOrEmail).NotEmpty();
|
||||
RuleFor(x => x.Password).NotEmpty();
|
||||
}
|
||||
|
||||
#endregion
|
||||
RuleFor(x => x.UsernameOrEmail).NotEmpty();
|
||||
RuleFor(x => x.Password).NotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,21 @@
|
||||
using FluentValidation;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Common.Model.Accounts;
|
||||
using WatchIt.Database;
|
||||
using WatchIt.Shared.Models.Accounts.Register;
|
||||
|
||||
namespace WatchIt.WebAPI.Validators.Accounts
|
||||
namespace WatchIt.WebAPI.Validators.Accounts;
|
||||
|
||||
public class RegisterRequestValidator : AbstractValidator<RegisterRequest>
|
||||
{
|
||||
public class RegisterRequestValidator : AbstractValidator<RegisterRequest>
|
||||
public RegisterRequestValidator(DatabaseContext database)
|
||||
{
|
||||
#region CONSTRUCTOR
|
||||
|
||||
public RegisterRequestValidator(DatabaseContext database)
|
||||
{
|
||||
RuleFor(x => x.Username).MinimumLength(5)
|
||||
.MaximumLength(50)
|
||||
.CannotBeIn(database.Accounts, x => x.Username).WithMessage("Username was already used");
|
||||
RuleFor(x => x.Email).EmailAddress()
|
||||
.CannotBeIn(database.Accounts, x => x.Email).WithMessage("Email was already used");
|
||||
RuleFor(x => x.Password).MinimumLength(8)
|
||||
.Must(x => x.Any(c => Char.IsUpper(c))).WithMessage("Password must contain at least one uppercase letter.")
|
||||
.Must(x => x.Any(c => Char.IsLower(c))).WithMessage("Password must contain at least one lowercase letter.")
|
||||
.Must(x => x.Any(c => Char.IsDigit(c))).WithMessage("Password must contain at least one digit.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
RuleFor(x => x.Username).MinimumLength(5)
|
||||
.MaximumLength(50)
|
||||
.CannotBeIn(database.Accounts, x => x.Username).WithMessage("Username was already used");
|
||||
RuleFor(x => x.Email).EmailAddress()
|
||||
.CannotBeIn(database.Accounts, x => x.Email).WithMessage("Email was already used");
|
||||
RuleFor(x => x.Password).MinimumLength(8)
|
||||
.Must(x => x.Any(char.IsUpper)).WithMessage("Password must contain at least one uppercase letter.")
|
||||
.Must(x => x.Any(char.IsLower)).WithMessage("Password must contain at least one lowercase letter.")
|
||||
.Must(x => x.Any(char.IsDigit)).WithMessage("Password must contain at least one digit.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user