コード例 #1
0
 /// <summary>
 /// 拓展方法,验证单个值
 /// </summary>
 /// <param name="value">单个值</param>
 /// <param name="validationOptionss">验证逻辑</param>
 /// <param name="validationTypes">验证类型</param>
 /// <returns></returns>
 public static DataValidationResult TryValidate(this object value, ValidationPattern validationOptionss, params object[] validationTypes)
 {
     return(DataValidator.TryValidateValue(value, validationOptionss, validationTypes));
 }
コード例 #2
0
 /// <summary>
 /// 拓展方法,验证单个值
 /// </summary>
 /// <param name="value">单个值</param>
 /// <param name="validationAttributes">验证特性</param>
 /// <returns></returns>
 public static DataValidationResult TryValidate(this object value, params ValidationAttribute[] validationAttributes)
 {
     return(DataValidator.TryValidateValue(value, validationAttributes));
 }
コード例 #3
0
 /// <summary>
 /// 拓展方法,验证单个值
 /// </summary>
 /// <param name="value">单个值</param>
 /// <param name="regexPattern">正则表达式</param>
 /// <param name="regexOptions">正则表达式选项</param>
 /// <returns></returns>
 public static bool TryValidate(this object value, string regexPattern, RegexOptions regexOptions = RegexOptions.None)
 {
     return(DataValidator.TryValidateValue(value, regexPattern, regexOptions));
 }
コード例 #4
0
 /// <summary>
 /// 拓展方法,验证类类型对象
 /// </summary>
 /// <param name="obj">对象实例</param>
 /// <param name="validateAllProperties">是否验证所有属性</param>
 /// <returns>验证结果</returns>
 public static DataValidationResult TryValidate(this object obj, bool validateAllProperties = true)
 {
     return(DataValidator.TryValidateObject(obj, validateAllProperties));
 }
コード例 #5
0
 /// <summary>
 /// 拓展方法,验证单个值
 /// </summary>
 /// <param name="value">单个值</param>
 /// <param name="validationOptionss">验证逻辑</param>
 /// <param name="validationTypes">验证类型</param>
 public static void Validate(this object value, ValidationPattern validationOptionss, params object[] validationTypes)
 {
     DataValidator.TryValidateValue(value, validationOptionss, validationTypes).AddError();
 }
コード例 #6
0
 /// <summary>
 /// 拓展方法,验证单个值
 /// </summary>
 /// <param name="value">单个值</param>
 /// <param name="validationAttributes">验证特性</param>
 public static void Validate(this object value, params ValidationAttribute[] validationAttributes)
 {
     DataValidator.TryValidateValue(value, validationAttributes).AddError();
 }
コード例 #7
0
 /// <summary>
 /// 拓展方法,验证类类型对象
 /// </summary>
 /// <param name="obj">对象实例</param>
 /// <param name="validateAllProperties">是否验证所有属性</param>
 public static void Validate(this object obj, bool validateAllProperties = true)
 {
     DataValidator.TryValidateObject(obj, validateAllProperties).AddError();
 }
コード例 #8
0
 /// <summary>
 /// 拓展方法,验证单个值
 /// </summary>
 /// <param name="value">单个值</param>
 /// <param name="validationTypes">验证类型</param>
 public static void Validate(this object value, params object[] validationTypes)
 {
     DataValidator.TryValidateValue(value, validationTypes).ThrowIf();
 }