structure app by rest api standards

add getusers
tidy up BusinessException
This commit is contained in:
Alex Bezdieniezhnykh
2024-11-14 22:45:36 +02:00
parent ace57eaf27
commit 4bc76bbbac
12 changed files with 182 additions and 37 deletions
+11 -2
View File
@@ -15,9 +15,18 @@ public class GetResourceRequestValidator : AbstractValidator<GetResourceRequest>
public GetResourceRequestValidator()
{
RuleFor(r => r.Password)
.MinimumLength(8).WithErrorCode(ExceptionEnum.PasswordLengthIncorrect.ToString()).WithMessage("Password should be at least 8 characters.");
.MinimumLength(8)
.WithErrorCode(ExceptionEnum.PasswordLengthIncorrect.ToString())
.WithMessage(_ => BusinessException.GetMessage(ExceptionEnum.PasswordLengthIncorrect));
RuleFor(r => r.HardwareId)
.NotEmpty().WithErrorCode(ExceptionEnum.HardwareIdMismatch.ToString()).WithMessage("Hardware Id should be not empty.");
.MinimumLength(8)
.WithErrorCode(ExceptionEnum.HardwareIdLength.ToString())
.WithMessage(_ => BusinessException.GetMessage(ExceptionEnum.HardwareIdLength));
RuleFor(r => r.ResourceEnum)
.NotEqual(ResourceEnum.None)
.WithErrorCode(ExceptionEnum.WrongResourceType.ToString())
.WithMessage(_ => BusinessException.GetMessage(ExceptionEnum.WrongResourceType));
}
}
@@ -15,7 +15,7 @@ public class RegisterUserValidator : AbstractValidator<RegisterUserRequest>
public RegisterUserValidator()
{
RuleFor(r => r.Email)
.MinimumLength(8).WithErrorCode(ExceptionEnum.UserLengthIncorrect.ToString()).WithMessage("Email address should be at least 8 characters.")
.MinimumLength(8).WithErrorCode(ExceptionEnum.EmailLengthIncorrect.ToString()).WithMessage("Email address should be at least 8 characters.")
.EmailAddress().WithErrorCode(ExceptionEnum.WrongEmail.ToString()).WithMessage("Email address is not valid.");
RuleFor(r => r.Password)