mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 11:46:33 +00:00
4bc76bbbac
add getusers tidy up BusinessException
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using Azaion.Common.Entities;
|
|
using FluentValidation;
|
|
|
|
namespace Azaion.Common.Requests;
|
|
|
|
public class GetResourceRequest
|
|
{
|
|
public string Password { get; set; } = null!;
|
|
public string HardwareId { get; set; } = null!;
|
|
public ResourceEnum ResourceEnum { get; set; }
|
|
}
|
|
|
|
public class GetResourceRequestValidator : AbstractValidator<GetResourceRequest>
|
|
{
|
|
public GetResourceRequestValidator()
|
|
{
|
|
RuleFor(r => r.Password)
|
|
.MinimumLength(8)
|
|
.WithErrorCode(ExceptionEnum.PasswordLengthIncorrect.ToString())
|
|
.WithMessage(_ => BusinessException.GetMessage(ExceptionEnum.PasswordLengthIncorrect));
|
|
|
|
RuleFor(r => r.HardwareId)
|
|
.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));
|
|
}
|
|
} |