状态校验
This commit is contained in:
parent
8791f12423
commit
82cee1ed13
@ -28,7 +28,7 @@ namespace SJZY.Track.Application.Validations.TrackContents
|
|||||||
{
|
{
|
||||||
RuleFor(x => x.SubSystemId).GreaterThan(0).WithMessage("子系统的id必须大于0!");
|
RuleFor(x => x.SubSystemId).GreaterThan(0).WithMessage("子系统的id必须大于0!");
|
||||||
RuleFor(x => x.TrackStatusId).GreaterThan(0).WithMessage("所属状态的id必须大于0!");
|
RuleFor(x => x.TrackStatusId).GreaterThan(0).WithMessage("所属状态的id必须大于0!");
|
||||||
RuleFor(x => x.Code).NotNull().WithMessage("轨迹代码必填!").NotEmpty().WithMessage("轨迹代码不能为空!");
|
RuleFor(x => x.Code).NotNull().WithMessage("轨迹内容代码必填!").NotEmpty().WithMessage("轨迹内容代码不能为空!");
|
||||||
RuleFor(x => x.Content).NotNull().WithMessage("轨迹内容必填!").NotEmpty().WithMessage("轨迹内容不能为空!");
|
RuleFor(x => x.Content).NotNull().WithMessage("轨迹内容必填!").NotEmpty().WithMessage("轨迹内容不能为空!");
|
||||||
RuleFor(x => x.EnContent).NotNull().WithMessage("轨迹内容英文必填!").NotEmpty().WithMessage("轨迹内容英文不能为空!");
|
RuleFor(x => x.EnContent).NotNull().WithMessage("轨迹内容英文必填!").NotEmpty().WithMessage("轨迹内容英文不能为空!");
|
||||||
});
|
});
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
using SJZY.Track.Application.Dtos.TrackContents;
|
||||||
|
using SJZY.Track.Application.Dtos.TrackStatus;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SJZY.Track.Application.Validations.TrackStatus
|
||||||
|
{
|
||||||
|
public class EditTrackStatusInputValidation : AbstractValidator<EditTrackStatusInput>, IValidationEnabled
|
||||||
|
{
|
||||||
|
public EditTrackStatusInputValidation()
|
||||||
|
{
|
||||||
|
//条件分支
|
||||||
|
When(x => x.Options == OptionType.修改 || x.Options == OptionType.删除, () =>
|
||||||
|
{
|
||||||
|
RuleFor(x => x.Id).GreaterThan(0).WithMessage("修改或删除时Id必须大于0!");
|
||||||
|
});
|
||||||
|
|
||||||
|
When(x => x.Options == OptionType.新增, () =>
|
||||||
|
{
|
||||||
|
RuleFor(x => x.Id).Equal(0).WithMessage("新增时Id必须等于0!");
|
||||||
|
});
|
||||||
|
|
||||||
|
When(x => x.Options == OptionType.修改 || x.Options == OptionType.新增, () =>
|
||||||
|
{
|
||||||
|
RuleFor(x => x.SubSystemId).GreaterThan(0).WithMessage("子系统的id必须大于0!");
|
||||||
|
RuleFor(x => x.NodeId).GreaterThan(0).WithMessage("所属节点的id必须大于0!");
|
||||||
|
RuleFor(x => x.Code).NotNull().WithMessage("轨迹状态代码必填!").NotEmpty().WithMessage("轨迹状态代码不能为空!");
|
||||||
|
RuleFor(x => x.TrackStatus).NotNull().WithMessage("轨迹状态必填!").NotEmpty().WithMessage("轨迹状态不能为空!");
|
||||||
|
RuleFor(x => x.EntrackStatus).NotNull().WithMessage("轨迹状态英文必填!").NotEmpty().WithMessage("轨迹状态英文不能为空!");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user