refactor (readonly for static objects in tests and file-scoped namespaces
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ApplicationLayer
|
||||
namespace ApplicationLayer;
|
||||
|
||||
public static class Constants
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public readonly static Regex EnglishWordRegex = new("^[a-zA-Z]*$");
|
||||
public readonly static Regex EnglishWordRegex = new("^[a-zA-Z]*$");
|
||||
|
||||
public readonly static Regex EnglishPhraseRegex = new(@"^[a-zA-Z №0-9;,\-_+=#*']*$");
|
||||
public readonly static Regex EnglishPhraseRegex = new(@"^[a-zA-Z №0-9;,\-_+=#*']*$");
|
||||
|
||||
public readonly static Regex PhoneNumRegex = new(@"^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$");
|
||||
}
|
||||
}
|
||||
public readonly static Regex PhoneNumRegex = new(@"^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$");
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ApplicationLayer.Services.AuthServices.Common
|
||||
namespace ApplicationLayer.Services.AuthServices.Common;
|
||||
|
||||
public class AuthToken
|
||||
{
|
||||
public class AuthToken
|
||||
{
|
||||
[Required] public string Token { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
[Required] public string Token { get; set; } = null!;
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Domains;
|
||||
|
||||
namespace ApplicationLayer.Services.Users.Models
|
||||
{
|
||||
/// Auth data with nullable password for making change auth data requests
|
||||
public class ChangeAuthData
|
||||
{
|
||||
[Required]
|
||||
[MaxLength(ConfigurationConstraints.EmailLength)]
|
||||
public string Email { get; set; } = null!;
|
||||
namespace ApplicationLayer.Services.Users.Models;
|
||||
|
||||
[MaxLength(ConfigurationConstraints.PasswordLength)]
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
||||
/// Auth data with nullable password for making change auth data requests
|
||||
public class ChangeAuthData
|
||||
{
|
||||
[Required]
|
||||
[MaxLength(ConfigurationConstraints.EmailLength)]
|
||||
public string Email { get; set; } = null!;
|
||||
|
||||
[MaxLength(ConfigurationConstraints.PasswordLength)]
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Domains;
|
||||
|
||||
namespace ApplicationLayer.Services.Users.Models
|
||||
{
|
||||
public class UserModel
|
||||
{
|
||||
/// Unique Identifier of user
|
||||
[Required]
|
||||
public Guid Id { get; private set; } = Guid.NewGuid();
|
||||
namespace ApplicationLayer.Services.Users.Models;
|
||||
|
||||
[Required]
|
||||
[MaxLength(ConfigurationConstraints.EmailLength)]
|
||||
public string Email { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
public class UserModel
|
||||
{
|
||||
/// Unique Identifier of user
|
||||
[Required]
|
||||
public Guid Id { get; private set; } = Guid.NewGuid();
|
||||
|
||||
[Required]
|
||||
[MaxLength(ConfigurationConstraints.EmailLength)]
|
||||
public string Email { get; set; } = null!;
|
||||
}
|
||||
@@ -1,24 +1,23 @@
|
||||
using Domains;
|
||||
using FluentValidation;
|
||||
|
||||
namespace ApplicationLayer.Services.Users.Requests.Validation
|
||||
namespace ApplicationLayer.Services.Users.Requests.Validation;
|
||||
|
||||
public class ChangeUserAuthDataRequestValidator : AbstractValidator<ChangeUserAuthDataRequest>
|
||||
{
|
||||
public class ChangeUserAuthDataRequestValidator : AbstractValidator<ChangeUserAuthDataRequest>
|
||||
public ChangeUserAuthDataRequestValidator()
|
||||
{
|
||||
public ChangeUserAuthDataRequestValidator()
|
||||
{
|
||||
RuleFor(r => r.UserId)
|
||||
.NotEmpty();
|
||||
RuleFor(r => r.UserId)
|
||||
.NotEmpty();
|
||||
|
||||
RuleFor(r => r.NewAuthData)
|
||||
.NotEmpty();
|
||||
RuleFor(r => r.NewAuthData)
|
||||
.NotEmpty();
|
||||
|
||||
RuleFor(r => r.NewAuthData.Email)
|
||||
.NotEmpty()
|
||||
.EmailAddress()
|
||||
.WithMessage("Email should be valid")
|
||||
.MaximumLength(ConfigurationConstraints.EmailLength)
|
||||
.WithMessage($"Email address length must be less than {ConfigurationConstraints.EmailLength}");
|
||||
}
|
||||
RuleFor(r => r.NewAuthData.Email)
|
||||
.NotEmpty()
|
||||
.EmailAddress()
|
||||
.WithMessage("Email should be valid")
|
||||
.MaximumLength(ConfigurationConstraints.EmailLength)
|
||||
.WithMessage($"Email address length must be less than {ConfigurationConstraints.EmailLength}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user