mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 23:16:33 +00:00
30 lines
993 B
C#
30 lines
993 B
C#
using FluentValidation;
|
|
|
|
namespace Azaion.Common.Requests;
|
|
|
|
public class GetResourceRequest
|
|
{
|
|
public string Password { get; set; } = null!;
|
|
public string Hardware { get; set; } = null!;
|
|
public string FileName { get; set; } = null!;
|
|
}
|
|
|
|
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.Hardware)
|
|
.NotEmpty()
|
|
.WithMessage(_ => BusinessException.GetMessage(ExceptionEnum.BadHardware));
|
|
|
|
RuleFor(r => r.FileName)
|
|
.NotEmpty()
|
|
.WithErrorCode(ExceptionEnum.WrongResourceName.ToString())
|
|
.WithMessage(_ => BusinessException.GetMessage(ExceptionEnum.WrongResourceName));
|
|
}
|
|
} |