public void AddValidationErrors(CustomValidationContext context) { if (RangeTime.Count() != 2) { context.Results.Add(new ValidationResult("时间范围设置错误")); } }
public void AddValidationErrors(CustomValidationContext context) { if (!string.IsNullOrWhiteSpace(CronString) && !CronStringHelper.IsValidCronExpression(CronString)) { context.Results.Add(new ValidationResult("CRON String is invalid")); } }
public void AddValidationErrors(CustomValidationContext context) { if (PhotoFile != null && PhotoFile.Length > MaxPhotoLength) { context.Results.Add(new ValidationResult("照片文件不能大于50K!")); } }
public void AddValidationErrors(CustomValidationContext context) { if (phone.Length > 11) { context.Results.Add(new ValidationResult("info:The field phone must be a string or array type with a maximum length of '11'")); } }
public void AddValidationErrors(CustomValidationContext context) { if (Tasks == null || Tasks.Count == 0) { context.Results.Add(new ValidationResult("请至少选择一条任务", new[] { "TaskId", "AssignedPersonId" })); } }
public void AddValidationErrors(CustomValidationContext context) { if (Id <= 0) { context.Results.Add(new ValidationResult($"{nameof(Id)} is required")); } }
public void AddValidationErrors(CustomValidationContext context) { if (string.IsNullOrEmpty(Name)) { context.Results.Add(new ValidationResult("Name is not be empty")); } }
public void AddValidationErrors(CustomValidationContext context) { if (!ValidationHelper.IsMobilePhone(PhoneNumber)) { context.Results.Add(new ValidationResult("Invalid mobile phone number!")); } }
public void AddValidationErrors(CustomValidationContext context) { if (!NewPassword.Equals(RepeatNewPassword)) { context.Results.Add(new ValidationResult("两次输入的新密码不一致")); } }
public void AddValidationErrors(CustomValidationContext context) { if (string.IsNullOrEmpty(Name)) { context.Results.Add(new ValidationResult($"{nameof(Name)} is required")); } }
public void AddValidationErrors(CustomValidationContext context) { if (string.Compare(StartTime, EndTime) >= 0) { context.Results.Add(new ValidationResult("出发时间不能晚于返回时间")); } }
/// <summary> /// 自定义检验 /// </summary> /// <param name="context"></param> public void AddValidationErrors(CustomValidationContext context) { if (IdList == null || IdList.Count == 0) { throw new AbpException("主键Id不能为空!"); } }
//Custom validation method. //It's called by ABP after data annotation validations. public void AddValidationErrors(CustomValidationContext context) { if (State == null) { context.Results.Add(new ValidationResult("State can not be null in order to update a Task!", new[] { "State" })); } }
public void AddValidationErrors(CustomValidationContext context) { if (startDate.HasValue && endDate.HasValue && startDate.Value > endDate.Value) { context.Results.Add(new ValidationResult("结束日期必须大于或等于开始日期")); } }
public void AddValidationErrors(CustomValidationContext context) { if (AssignedPersonId == null && State == null) { context.Results.Add(new ValidationResult("Simple Task not updated")); } }
public void AddValidationErrors(CustomValidationContext context) { if (AssignedPersonId == null && State == null) { context.Results.Add(new ValidationResult("Both of AssignedPersonId and State can not be null in order to update a Task!", new[] { "AssignedPersonId", "State" })); } }
public void AddValidationErrors(CustomValidationContext context) { if (!UseGravatarProfilePicture && FileToken.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(FileToken)); } }
public void AddValidationErrors(CustomValidationContext context) { if (Description.Length > 5) { context.Results.Add(new ValidationResult("描述长度不能大于5")); // throw new UserFriendlyException("省份编码长度不能超过5个字符"); } }
public void AddValidationErrors(CustomValidationContext context) { if (string.IsNullOrWhiteSpace(Floor)) { string error = "楼层数不能为空"; context.Results.Add(new ValidationResult(error)); } }
/// <summary> /// 添加自定义验证 /// </summary> /// <param name="context"></param> public void AddValidationErrors(CustomValidationContext context) { if (this.AllowOfflineAccess && (this.SlidingRefreshTokenLifetime == null || this.SlidingRefreshTokenLifetime <= 0)) { string error = "启用刷新RefreshToken时,请设置授权Token有效期 (小时)。"; context.Results.Add(new ValidationResult(error)); } }
public void AddValidationErrors(CustomValidationContext context) { if (AssignedPersonId == null && TaskId == 0) { context.Results.Add(new ValidationResult("任务ID和员工ID不能同时为空", new[] { "TaskId", "AssignedPersonId" })); ; } }
public void AddValidationErrors(CustomValidationContext context) { var session = context.IocResolver.Resolve <IAbpSession>(); if ((!AssignedPersonId.HasValue || AssignedPersonId.Value <= 0)) { context.Results.Add(new ValidationResult("AssignedPersonId must be set if SendEmailToAssignedPerson is true!")); } }
public void AddValidationErrors(CustomValidationContext context) { //string[] target = new string[] { "_blank", "_self", "_parent", "_top" }; //if (!target.Contains(Target)) //{ // context.Results.Add(new ValidationResult("Target 必须为 [" + string.Join(';', target) + "]中之一。")); // //throw new NotImplementedException("Target 必须为 [" + string.Join(';', target) + "]中之一。"); //} }
public void AddValidationErrors(CustomValidationContext context) { foreach (var usernamesInCrawler in UsernamesInCrawlers) { if (usernamesInCrawler.Value == null) { context.Results.Add(new ValidationResult("Items in UsernamesInCrawlers should not be null.")); } } }
public void AddValidationErrors(CustomValidationContext context) { if (!IsStatic) { if (string.IsNullOrWhiteSpace(Name)) { context.Results.Add(new ValidationResult("Role name is required!")); } } }
public void AddValidationErrors(CustomValidationContext context) { if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Description) || State == null) { context.Results.Add( new ValidationResult( "Name, Description and State can not be null in order to create a Task!", new[] { "Name", "Description", "State" })); } }
protected override ValidationResult IsValid(object value, CustomValidationContext customValidationContext, ValidationContext validationContext) { if (value is ICollection <string> items && items.Any(item => !customValidationContext.ValidItems.Contains(item))) { return(new ValidationResult($"Items contains invalid values. It must be any of {string.Join(", ", customValidationContext.ValidItems)}")); } return(ValidationResult.Success); }
public void AddValidationErrors(CustomValidationContext context) { var cart = JsonConvert.DeserializeObject <Carts.Cart>(Cart); if (!cart.Lines.Any()) { //ModelState.AddModelError("cartError", "Sorry, your cart is empty!"); context.Results.Add(new ValidationResult("Sorry, your cart is empty!")); } }
public virtual void AddValidationErrors(CustomValidationContext context) { //if (string.IsNullOrWhiteSpace(EmailAddress) && string.IsNullOrWhiteSpace(PhoneNumber)) //{ // context.Results.Add(new ValidationResult("手机号和邮箱不能都为空!")); //} CreateValidationRoleTypeList(context); }
public void AddValidationErrors(CustomValidationContext context) { try { System.Version.Parse(Version); } catch (Exception e) { context.Results.Add(new ValidationResult(e.Message)); } }