示例#1
0
 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"));
     }
 }
示例#3
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (PhotoFile != null && PhotoFile.Length > MaxPhotoLength)
     {
         context.Results.Add(new ValidationResult("照片文件不能大于50K!"));
     }
 }
示例#4
0
 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'"));
     }
 }
示例#5
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (Tasks == null || Tasks.Count == 0)
     {
         context.Results.Add(new ValidationResult("请至少选择一条任务", new[] { "TaskId", "AssignedPersonId" }));
     }
 }
示例#6
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (Id <= 0)
     {
         context.Results.Add(new ValidationResult($"{nameof(Id)} is required"));
     }
 }
示例#7
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (string.IsNullOrEmpty(Name))
     {
         context.Results.Add(new ValidationResult("Name is not be empty"));
     }
 }
示例#8
0
 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("两次输入的新密码不一致"));
     }
 }
示例#10
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (string.IsNullOrEmpty(Name))
     {
         context.Results.Add(new ValidationResult($"{nameof(Name)} is required"));
     }
 }
示例#11
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (string.Compare(StartTime, EndTime) >= 0)
     {
         context.Results.Add(new ValidationResult("出发时间不能晚于返回时间"));
     }
 }
示例#12
0
 /// <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" }));
     }
 }
示例#14
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (startDate.HasValue && endDate.HasValue && startDate.Value > endDate.Value)
     {
         context.Results.Add(new ValidationResult("结束日期必须大于或等于开始日期"));
     }
 }
示例#15
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (AssignedPersonId == null && State == null)
     {
         context.Results.Add(new ValidationResult("Simple Task not updated"));
     }
 }
示例#16
0
 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" }));
     }
 }
示例#17
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (!UseGravatarProfilePicture && FileToken.IsNullOrEmpty())
     {
         throw new ArgumentNullException(nameof(FileToken));
     }
 }
示例#18
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (Description.Length > 5)
     {
         context.Results.Add(new ValidationResult("描述长度不能大于5"));
         // throw new UserFriendlyException("省份编码长度不能超过5个字符");
     }
 }
示例#19
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (string.IsNullOrWhiteSpace(Floor))
     {
         string error = "楼层数不能为空";
         context.Results.Add(new ValidationResult(error));
     }
 }
示例#20
0
 /// <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));
     }
 }
示例#21
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (AssignedPersonId == null && TaskId == 0)
     {
         context.Results.Add(new ValidationResult("任务ID和员工ID不能同时为空", new[] { "TaskId", "AssignedPersonId" }));
         ;
     }
 }
示例#22
0
        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!"));
            }
        }
示例#23
0
 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) + "]中之一。");
     //}
 }
示例#24
0
 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."));
         }
     }
 }
示例#25
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     if (!IsStatic)
     {
         if (string.IsNullOrWhiteSpace(Name))
         {
             context.Results.Add(new ValidationResult("Role name is required!"));
         }
     }
 }
示例#26
0
 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!"));
            }
        }
示例#29
0
        public virtual void AddValidationErrors(CustomValidationContext context)
        {
            //if (string.IsNullOrWhiteSpace(EmailAddress) && string.IsNullOrWhiteSpace(PhoneNumber))
            //{
            //    context.Results.Add(new ValidationResult("手机号和邮箱不能都为空!"));
            //}


            CreateValidationRoleTypeList(context);
        }
示例#30
0
 public void AddValidationErrors(CustomValidationContext context)
 {
     try
     {
         System.Version.Parse(Version);
     }
     catch (Exception e)
     {
         context.Results.Add(new ValidationResult(e.Message));
     }
 }