Added models for presentation layer with data annotations
This commit is contained in:
		| @@ -1,5 +1,4 @@ | ||||
| using ApplicationLayer.Services.AuthServices.Common; | ||||
| using ApplicationLayer.Services.AuthServices.NeededServices; | ||||
| using Domains; | ||||
| using FluentValidation; | ||||
|  | ||||
| @@ -7,25 +6,20 @@ namespace ApplicationLayer.Services.AuthServices.Requests.Validation; | ||||
|  | ||||
| public class AuthDataValidator : AbstractValidator<AuthData> | ||||
| { | ||||
|     public AuthDataValidator(IUsersRepository users) | ||||
|     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}") | ||||
|                 .MustAsync(async (email, ct) => | ||||
|                 { | ||||
|                     return await users.FindByEmailAsync(email, ct) is null; | ||||
|                 }) | ||||
|                 .WithMessage("Email already exists"); | ||||
|         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") | ||||
|                 .MaximumLength(ConfigurationConstraints.PasswordLength) | ||||
|                 .WithMessage($"Password length must be less than {ConfigurationConstraints.PasswordLength}"); | ||||
|         } | ||||
| } | ||||
|         RuleFor(d => d.Password) | ||||
|             .NotEmpty() | ||||
|             .WithMessage("Password can not be empty") | ||||
|             .MaximumLength(ConfigurationConstraints.PasswordLength) | ||||
|             .WithMessage($"Password length must be less than {ConfigurationConstraints.PasswordLength}"); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user