Esempio n. 1
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            if (string.IsNullOrWhiteSpace(value?.ToString()))
            {
                return(ValidationResult.ValidResult);
            }
            // 数字和字母验证
            NumbericAndWordValidationRule numbericAndWordValidation = new NumbericAndWordValidationRule();

            if (!numbericAndWordValidation.Validate(value, cultureInfo).IsValid)
            {
                return(numbericAndWordValidation.Validate(value, cultureInfo));
            }
            // 长度为28位验证
            return(RuleHelper.IsRequiredLength(value, 28)
                ? ValidationResult.ValidResult
                : new ValidationResult(false, "长度应是28位"));
        }
 /// <summary>
 /// 检查不动产单元号
 /// </summary>
 /// <param name="table"></param>
 /// <param name="rownum"></param>
 /// <param name="value"></param>
 /// <param name="name"></param>
 private void CheckBDCDYH(String table, String id, String value, String name)
 {
     if (RuleHelper.IsNotEmpty(value)) // 可以为空
     {
         if (!RuleHelper.IsNumberAndWord(value))
         {
             ErrorMsg.Add(table + "表中," + id + "的" + name + "格式错误,应是数字或字母");
             //ErrorMsg.Add(table + "表中,第" + rownum + "行的" + name + "格式错误,应是数字或字母");
             return;
         }
         if (!RuleHelper.IsRequiredLength(value, 28))
         {
             ErrorMsg.Add(table + "表中," + id + "的" + name + "格式错误,长度应是28位");
             //ErrorMsg.Add(table + "表中,第" + rownum + "行的" + name + "格式错误,长度应是28位");
             return;
         }
     }
 }
Esempio n. 3
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            // 非空验证
            NotEmptyValidationRule notEmptyValidation = new NotEmptyValidationRule();

            if (!notEmptyValidation.Validate(value, cultureInfo).IsValid)
            {
                return(notEmptyValidation.Validate(value, cultureInfo));
            }
            // 数字和字母验证
            NumbericAndWordValidationRule numbericAndWordValidation = new NumbericAndWordValidationRule();

            if (!numbericAndWordValidation.Validate(value, cultureInfo).IsValid)
            {
                return(numbericAndWordValidation.Validate(value, cultureInfo));
            }
            // 长度为28位验证
            return(RuleHelper.IsRequiredLength(value, 19)
                ? ValidationResult.ValidResult
                : new ValidationResult(false, "长度应是19位"));
        }