Вытащил солюшен на уровень выше, чтобы прощё было дотнетить
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is failing
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	continuous-integration/drone/push Build is failing
				
			This commit is contained in:
		| @@ -0,0 +1,27 @@ | ||||
| using ApplicationLayer.Services.AuthServices.Common; | ||||
| using Domains; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.AuthServices.Requests.Validation; | ||||
|  | ||||
| public class AuthDataValidator : AbstractValidator<AuthData> | ||||
| { | ||||
|     public AuthDataValidator() | ||||
|     { | ||||
|         RuleFor(d => d.Email) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Email can not be empty") | ||||
|             .EmailAddress() | ||||
|             .WithMessage("Email must be valid") | ||||
|             .MaximumLength(ConfigurationConstraints.EmailLength) | ||||
|             .WithMessage($"Email length must be less than {ConfigurationConstraints.EmailLength}"); | ||||
|  | ||||
|         RuleFor(d => d.Password) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Password can not be empty") | ||||
|             .Matches(Constants.EnglishPhraseRegex) | ||||
|             .WithMessage("Password can contain only english letters, digits and special symbols") | ||||
|             .MaximumLength(ConfigurationConstraints.PasswordLength) | ||||
|             .WithMessage($"Password length must be less than {ConfigurationConstraints.PasswordLength}"); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,93 @@ | ||||
| using ApplicationLayer.InfrastructureServicesInterfaces; | ||||
| using ApplicationLayer.Services.Applicants.Models; | ||||
| using Domains; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.AuthServices.Requests.Validation; | ||||
|  | ||||
| public class RegisterApplicantRequestValidator : AbstractValidator<RegisterApplicantRequest> | ||||
| { | ||||
|     public RegisterApplicantRequestValidator( | ||||
|         IDateTimeProvider dateTimeProvider, | ||||
|         IValidator<NameModel> nameValidator, | ||||
|         IValidator<RegisterRequest> registerRequestValidator, | ||||
|         IValidator<PassportModel> passportValidator, | ||||
|         IValidator<PlaceOfWorkModel> placeOfWorkModelValidator) | ||||
|     { | ||||
|         RuleFor(r => r.RegisterRequest) | ||||
|             .NotEmpty() | ||||
|             .SetValidator(registerRequestValidator); | ||||
|  | ||||
|         RuleFor(r => r.ApplicantName) | ||||
|             .NotEmpty() | ||||
|             .SetValidator(nameValidator); | ||||
|  | ||||
|         RuleFor(r => r.FatherName) | ||||
|             .NotEmpty() | ||||
|             .SetValidator(nameValidator); | ||||
|  | ||||
|         RuleFor(r => r.MotherName) | ||||
|             .NotEmpty() | ||||
|             .SetValidator(nameValidator); | ||||
|  | ||||
|         RuleFor(r => r.Passport) | ||||
|             .NotEmpty() | ||||
|             .SetValidator(passportValidator); | ||||
|  | ||||
|         RuleFor(r => r.BirthDate) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Birth date can not be empty") | ||||
|             .LessThanOrEqualTo(dateTimeProvider.Now().AddYears(-ConfigurationConstraints.ApplicantMinAge)) | ||||
|             .WithMessage($"Applicant must be older than {ConfigurationConstraints.ApplicantMinAge}"); | ||||
|  | ||||
|         RuleFor(r => r.CountryOfBirth) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Country of birth can not be empty") | ||||
|             .Matches(Constants.EnglishPhraseRegex) | ||||
|             .WithMessage("Country of birth field can contain only english letters, digits and special symbols") | ||||
|             .MaximumLength(ConfigurationConstraints.CountryNameLength) | ||||
|             .WithMessage($"Country of birth name length must be less than {ConfigurationConstraints.CountryNameLength}"); | ||||
|  | ||||
|         RuleFor(r => r.CityOfBirth) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("City of birth can not be empty") | ||||
|             .Matches(Constants.EnglishPhraseRegex) | ||||
|             .WithMessage("City of birth field can contain only english letters, digits and special symbols") | ||||
|             .MaximumLength(ConfigurationConstraints.CityNameLength) | ||||
|             .WithMessage($"City of birth name length must be less than {ConfigurationConstraints.CityNameLength}"); | ||||
|  | ||||
|         RuleFor(r => r.Citizenship) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Citizenship can not be empty") | ||||
|             .Matches(Constants.EnglishPhraseRegex) | ||||
|             .WithMessage("Citizenship field can contain only english letters, digits and special symbols") | ||||
|             .MaximumLength(ConfigurationConstraints.CitizenshipLength) | ||||
|             .WithMessage($"Citizenship length must be less than {ConfigurationConstraints.CitizenshipLength}"); | ||||
|  | ||||
|         RuleFor(r => r.CitizenshipByBirth) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Citizenship by birth can not be empty") | ||||
|             .Matches(Constants.EnglishPhraseRegex) | ||||
|             .WithMessage("Citizenship by birth field can contain only english letters, digits and special symbols") | ||||
|             .MaximumLength(ConfigurationConstraints.CitizenshipLength) | ||||
|             .WithMessage($"Citizenship by birth length must be less than {ConfigurationConstraints.CitizenshipLength}"); | ||||
|  | ||||
|         RuleFor(r => r.Gender) | ||||
|             .IsInEnum(); | ||||
|  | ||||
|         RuleFor(r => r.MaritalStatus) | ||||
|             .IsInEnum(); | ||||
|  | ||||
|         RuleFor(r => r.JobTitle) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Title of job can not be empty") | ||||
|             .Matches(Constants.EnglishPhraseRegex) | ||||
|             .WithMessage("Title of job field can contain only english letters, digits and special symbols") | ||||
|             .MaximumLength(ConfigurationConstraints.JobTitleLength) | ||||
|             .WithMessage($"Title of job length must be less than {ConfigurationConstraints.JobTitleLength}"); | ||||
|  | ||||
|         RuleFor(r => r.PlaceOfWork) | ||||
|             .NotEmpty() | ||||
|             .SetValidator(placeOfWorkModelValidator); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,17 @@ | ||||
| using ApplicationLayer.Services.AuthServices.Common; | ||||
| using ApplicationLayer.Services.AuthServices.NeededServices; | ||||
| using FluentValidation; | ||||
|  | ||||
| namespace ApplicationLayer.Services.AuthServices.Requests.Validation; | ||||
|  | ||||
| public class RegisterRequestValidator : AbstractValidator<RegisterRequest> | ||||
| { | ||||
|     public RegisterRequestValidator(IUsersRepository users, IValidator<AuthData> authDataValidator) | ||||
|     { | ||||
|         RuleFor(r => r.AuthData) | ||||
|             .NotEmpty() | ||||
|             .SetValidator(authDataValidator) | ||||
|             .MustAsync(async (authData, ct) => await users.FindByEmailAsync(authData.Email, ct) is null) | ||||
|             .WithMessage("Email already exists"); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user