mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 10:36:33 +00:00
structure app by rest api standards
add getusers tidy up BusinessException
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user