You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.7 KiB
C#

using EntrustSettle.Model.Dtos;
using FluentValidation;
namespace EntrustSettle.Model.Validator
{
public class OrderSubmitDtoValidator : AbstractValidator<OrderSubmitDto>
{
public OrderSubmitDtoValidator()
{
RuleFor(x => x.MblnoList).NotEmpty();
RuleFor(x => x.CompanyId).NotNull().NotEmpty();
RuleFor(x => x.CompanyName).NotNull().NotEmpty();
RuleFor(x => x.ServiceType).InclusiveBetween(1, 3).WithMessage("服务类型错误");
RuleFor(x => x.ProjectType).NotNull().NotEmpty().WithMessage("项目类型不能为空");
RuleFor(x => x.ProjectType).Must(x =>
{
if (!string.IsNullOrWhiteSpace(x))
{
var projects = x.Split(',');
foreach (var project in projects)
{
if (!int.TryParse(project, out int _))
{
return false;
}
}
}
return true;
}).WithMessage("项目类型错误");
RuleFor(x => x.AnnexIdList).Must(x => x == null || x.Count <= 5).WithMessage("附件数量不能超过5个");
//RuleFor(x => x.Remark).MaximumLength(2000).WithMessage("备注过长");
}
}
public class FileTypeEnumValidator : AbstractValidator<FileTypeEnum>
{
public FileTypeEnumValidator()
{
RuleFor(x => x).IsInEnum();
}
}
public class ChangeStatusDtoValidator : AbstractValidator<ChangeStatusDto>
{
public ChangeStatusDtoValidator()
{
RuleFor(x => x.Status).IsInEnum();
}
}
}