public FloorValidator() { RuleFor(m => m.Name) .NotEmpty().WithMessage("楼层名称不能为空") .Length(1, 100).WithMessage("楼层名称长度为1-100") .Must(m => !ValidatorToolkit.HasSpecialChar(m)).WithMessage("楼层名称不能有特殊字符"); RuleFor(m => m.Photo) .NotEmpty().WithMessage("请上传楼层平面图"); }
public TimeZoneViewModelValidator() { RuleFor(m => m.Name) .NotEmpty().WithMessage("时间区名称不能为空") .Must(m => !ValidatorToolkit.HasSpecialChar(m)).WithMessage("时间区名称不能有特殊字符") .Length(1, 100).WithMessage("时间区名称长度为1-100"); RuleFor(m => m.Code) .NotEmpty().WithMessage("时间区编号不能为空") .Must(ValidatorToolkit.IsNumeric).WithMessage("时间区编号必须为数字"); }
public DeviceGroupViewModelValidator() { RuleFor(m => m.DeviceGroupName) .NotEmpty().WithMessage("设备组名称不能为空") .Length(1, 100).WithMessage("设备组名称长度为1-100") .Must(m => !ValidatorToolkit.HasSpecialChar(m)).WithMessage("设备组名称:[{0}]不能有特殊字符", x => x.DeviceGroupName); RuleFor(m => m.CheckInDeviceID) .NotEqual(m => m.CheckOutDeviceID) .WithMessage("出门设备和入门设备不能相同"); }
public DeviceValidator() { RuleFor(m => m.Name) .NotEmpty().WithMessage("设备名称不能为空") .Length(1, 100).WithMessage("设备名称长度为1-100") .Must(m => !ValidatorToolkit.HasSpecialChar(m)).WithMessage("设备名称不能有特殊字符"); RuleFor(m => m.Code) .NotEmpty().WithMessage("设备编号不能为空") .Must(ValidatorToolkit.IsNumeric).WithMessage("设备编号只能为数字"); RuleFor(m => m.Model) .NotEmpty().WithMessage("设备型号不能为空") .Length(1, 100).WithMessage("设备型号长度为1-100"); RuleFor(m => m.Mac) .NotEmpty().WithMessage("Mac地址不能为空") .Length(1, 100).WithMessage("Mac地址长度为1-100"); RuleFor(m => m.SN) .NotEmpty().WithMessage("产品序列号不能为空") .Length(1, 100).WithMessage("产品序列号长度为1-100"); RuleFor(m => m.BaudRate) .Length(1, 100).When(m => !string.IsNullOrWhiteSpace(m.BaudRate)).WithMessage("波特率长度为1-100"); RuleFor(m => m.SerialPort) .Length(1, 100).When(m => !string.IsNullOrWhiteSpace(m.SerialPort)).WithMessage("串号端口号长度为1-100"); RuleFor(m => m.Password) .Length(1, 100).When(m => !string.IsNullOrWhiteSpace(m.Password)).WithMessage("密码长度为1-100"); RuleFor(m => m.IP) .Length(1, 100).When(m => !string.IsNullOrWhiteSpace(m.IP)).WithMessage("设备Ip长度为1-100"); RuleFor(m => m.Port) .Must(ValidatorToolkit.IsNumeric).When(m => !string.IsNullOrWhiteSpace(m.Port)).WithMessage("设备端口只能为数字"); RuleFor(m => m.ServerURL) .Length(1, 1024).When(m => !string.IsNullOrWhiteSpace(m.ServerURL)).WithMessage("后台服务器地址长度为1-1024"); RuleFor(m => m.Label) .Length(1, 1024).When(m => !string.IsNullOrWhiteSpace(m.Label)).WithMessage("备注长度为1-1024"); RuleFor(m => m.Remark) .Length(1, 1024).When(m => !string.IsNullOrWhiteSpace(m.Remark)).WithMessage("备注长度为1-1024"); RuleFor(m => m.DeviceControllerParameter).SetValidator(NinjectBinder.GetValidator <DeviceParameterValidator>()); RuleFor(m => m.DeviceDoors).SetCollectionValidator(NinjectBinder.GetValidator <DoorValidator>()); RuleFor(m => m.DeviceHeadReadings).SetCollectionValidator(NinjectBinder.GetValidator <HeadReadingValidator>()); }
public DepartmentValidator() { RuleFor(m => m.Name) .NotEmpty().WithMessage("部门名称不能为空") .Length(1, 100).WithMessage("部门名称长度为1-100") .Must(m => !ValidatorToolkit.HasSpecialChar(m)).WithMessage("部门名称不能有特殊字符"); RuleFor(m => m.DepartmentCode) .NotEmpty().WithMessage("部门编号不能为空") .Length(1, 25).WithMessage("部门编号长度为1-25") .Must(ValidatorToolkit.IsNumberOrChar).WithMessage("部门编号只能为数字或者字母"); RuleFor(m => m.Remark) .Length(1, 1024).When(m => !string.IsNullOrWhiteSpace(m.Remark)).WithMessage("备注长度为1-1024"); }
public DeviceRoleViewModelValidator() { RuleFor(m => m.Name) .NotEmpty().WithMessage("设备角色名称不能为空") .Length(1, 100).WithMessage("设备角色名称长度为1-100") .Must(m => !ValidatorToolkit.HasSpecialChar(m)).WithMessage("设备角色名称不能有特殊字符"); RuleFor(m => m.DeviceDtos) .Must(m => m.Any(x => x.IsSelected)).WithMessage("必须至少关联一台设备"); RuleFor(m => m.SelectedPermissionAction) .Must(m => Enum.GetValues(typeof(DevicePermissionAction)).AsQueryable().Cast <int>().Contains(m)).WithMessage("关联设备权限不能为空"); RuleFor(m => m.SelectedTimezone) .NotEmpty().WithMessage("关联时间区不能为空"); }
public DoorValidator() { RuleFor(m => m.Name) .NotEmpty().WithMessage("门名称不能为空") .Length(1, 100).WithMessage("门名称长度为1-100") .Must(m => !ValidatorToolkit.HasSpecialChar(m)).WithMessage("门名称:[{0}]不能有特殊字符", x => x.Name); RuleFor(m => m.Code) .NotEmpty().WithMessage("门编号不能为空") .Must(ValidatorToolkit.IsNumeric).WithMessage("门编号只能为数字"); RuleFor(m => m.Remark) .Length(1, 1024).When(m => !string.IsNullOrWhiteSpace(m.Remark)).WithMessage("备注长度为1-1024"); RuleFor(m => m.DuressPassword) .Length(1, 100).When(m => !string.IsNullOrWhiteSpace(m.DuressPassword)).WithMessage("胁迫密码长度为1-100"); }
public TimeSegmentViewModelValidator() { RuleFor(m => m.TimeSegmentName) .NotEmpty().WithMessage("时间段名称不能为空") .Must(m => !ValidatorToolkit.HasSpecialChar(m)).WithMessage("时间段名称不能有特殊字符") .Length(1, 100).WithMessage("时间段名称长度为1-100"); RuleFor(m => m.TimeSegmentCode) .NotEmpty().WithMessage("时间段编号不能为空") .Must(ValidatorToolkit.IsNumeric).WithMessage("时间段编号必须为数字"); RuleFor(m => m.StartHour) .NotEmpty().WithMessage("开始时间小时数值不能为空") .Must(ValidatorToolkit.VerifyHourFormat).WithMessage("开始时间小时数值无效"); RuleFor(m => m.EndHour) .NotEmpty().WithMessage("结束时间小时数值不能为空") .Must(ValidatorToolkit.VerifyHourFormat).WithMessage("结束时间小时数值无效"); RuleFor(m => m.StartMinute) .NotEmpty().WithMessage("开始时间分钟数值不能为空") .Must(ValidatorToolkit.VerifyMinuteFormat).WithMessage("开始时间分钟数值无效"); RuleFor(m => m.EndMinute) .NotEmpty().WithMessage("结束时间分钟数值不能为空") .Must(ValidatorToolkit.VerifyMinuteFormat).WithMessage("结束时间分钟数值无效"); }
public HeadReadingValidator() { RuleFor(m => m.Name) .NotEmpty().WithMessage("读头名称不能为空") .Length(1, 100).WithMessage("读头名称长度为1-100") .Must(m => !ValidatorToolkit.HasSpecialChar(m)).WithMessage("读头名称:[{0}]不能有特殊字符", x => x.Name); RuleFor(m => m.Code) .NotEmpty().WithMessage("读头编号不能为空") .Must(ValidatorToolkit.IsNumeric).WithMessage("读头编号只能为数字"); RuleFor(m => m.Mac) .NotEmpty().WithMessage("读头Mac地址不能为空") .Length(1, 100).WithMessage("读头Mac地址长度为1-100"); RuleFor(m => m.HeadReadingSN) .NotEmpty().WithMessage("读头产品序列号不能为空") .Length(1, 100).WithMessage("读头产品长度为1-100"); RuleFor(m => m.HeadReadingPerformance) .Length(1, 100).When(m => !string.IsNullOrWhiteSpace(m.HeadReadingPerformance)).WithMessage("读头性能长度为1-100"); }
public UserValidator() { RuleFor(m => m.Name) .NotEmpty().WithMessage("人员名称不能为空") .Length(1, 100).WithMessage("人员名称长度为1-100") .Must(m => !ValidatorToolkit.HasSpecialChar(m)).WithMessage("人员名称不能有特殊字符"); RuleFor(m => m.UserCode) .NotEmpty().WithMessage("人员编号不能为空") .Must(ValidatorToolkit.IsNumeric).WithMessage("人员编号只能为数字"); RuleFor(m => m.Phone) .NotEmpty().WithMessage("手机号码不能为空") .Must(ValidatorToolkit.IsPhoneNumberFormat).WithMessage("号码格式错误") .Length(7, 13).WithMessage("号码长度为7-13"); RuleFor(m => m.StartDate.Date) .LessThan(m => m.EndDate.Value.Date).When(m => m.EndDate.HasValue).WithMessage("开始时间必须小于结束时间"); RuleFor(m => m.Remark) .Length(1, 1024).When(m => !string.IsNullOrWhiteSpace(m.Remark)).WithMessage("备注长度为1-1024"); RuleFor(m => m.UserPropertyInfo).SetValidator(NinjectBinder.GetValidator <UserPropertyInfoValidator>()); }