|
|
|
@ -392,25 +392,21 @@ namespace Shentun.Peis |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#region 验证char类型参数
|
|
|
|
/// <summary>
|
|
|
|
/// 数据检查 字符
|
|
|
|
/// 验证char类型参数是否为null
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="value">需要验证的值</param>
|
|
|
|
/// <param name="parameterName">字段名称</param>
|
|
|
|
/// <param name="IsBoolValue"> 默认false(true 验证为Y跟N false 不验证)</param>
|
|
|
|
/// <param name="ExceptionMessage">异常提示后缀</param>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
public static void CheckCharIsNull(char? value, string parameterName, bool IsBoolValue = false, string ExceptionMessage = "不能为空") |
|
|
|
public static void CheckCharIsNull(char? value, string parameterName, string ExceptionMessage = "不能为空") |
|
|
|
{ |
|
|
|
if (value == null || value == '0') |
|
|
|
if (value == null) |
|
|
|
{ |
|
|
|
throw new ArgumentException($"{parameterName}{ExceptionMessage}"); |
|
|
|
} |
|
|
|
|
|
|
|
if (IsBoolValue && value != 'Y' && value != 'N') |
|
|
|
{ |
|
|
|
throw new ArgumentException($"{parameterName}参数为:{value},是无效值"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -433,27 +429,26 @@ namespace Shentun.Peis |
|
|
|
/// </summary>
|
|
|
|
/// <param name="value">需要验证的值</param>
|
|
|
|
/// <param name="parameterName">字段名称</param>
|
|
|
|
/// <param name="IsBoolValue"> 默认false(true 验证为Y跟N false 不验证)</param>
|
|
|
|
/// <param name="ExceptionMessage">异常提示后缀</param>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
public static void CheckCharValidValue(char value, string parameterName, string ExceptionMessage = "是无效值,只能为Y跟N") |
|
|
|
public static void CheckCharIsYOrN(char value, string parameterName) |
|
|
|
{ |
|
|
|
if (value != 'Y' && value != 'N') |
|
|
|
{ |
|
|
|
throw new ArgumentException($"{parameterName}参数为:{value},是无效值"); |
|
|
|
throw new ArgumentException($"{parameterName}参数为:{value},是无效值,只能为Y跟N"); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 数据检查 整型
|
|
|
|
/// 验证Int类型数据是否>0
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="value">需要验证的值</param>
|
|
|
|
/// <param name="parameterName">字段名称</param>
|
|
|
|
/// <param name="ExceptionMessage">异常提示后缀</param>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
public static void CheckIntIsNull(int? value, string parameterName, string ExceptionMessage = "不能为空") |
|
|
|
public static void CheckIntIsGeaterThanZero(int value, string parameterName, string ExceptionMessage = "只能为大于0的值") |
|
|
|
{ |
|
|
|
if (value == null || value == 0) |
|
|
|
if (value > 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException($"{parameterName}{ExceptionMessage}"); |
|
|
|
} |
|
|
|
@ -461,7 +456,7 @@ namespace Shentun.Peis |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 数据检查 Guid
|
|
|
|
/// 验证Guid数据是否为null
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="value">需要验证的值</param>
|
|
|
|
/// <param name="parameterName">字段名称</param>
|
|
|
|
@ -469,12 +464,44 @@ namespace Shentun.Peis |
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
public static void CheckGuidIsNull(Guid? value, string parameterName, string ExceptionMessage = "不能为空") |
|
|
|
{ |
|
|
|
if (value == null || value == Guid.Empty) |
|
|
|
if (value == null) |
|
|
|
{ |
|
|
|
throw new ArgumentException($"{parameterName}{ExceptionMessage}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 验证Guid数据是否为默认值00000000-0000-0000-0000-000000000000
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="value">需要验证的值</param>
|
|
|
|
/// <param name="parameterName">字段名称</param>
|
|
|
|
/// <param name="ExceptionMessage">异常提示后缀</param>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
public static void CheckGuidIsDefaultValue(Guid? value, string parameterName, string ExceptionMessage = "不能为默认值00000000-0000-0000-0000-000000000000") |
|
|
|
{ |
|
|
|
if (value == Guid.Empty) |
|
|
|
{ |
|
|
|
throw new ArgumentException($"{parameterName}{ExceptionMessage}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///验证decimal类型数据大于0
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="value">需要验证的值</param>
|
|
|
|
/// <param name="parameterName">字段名称</param>
|
|
|
|
/// <param name="ExceptionMessage">异常提示后缀</param>
|
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
public static void CheckDecimalIsGeaterThanZero(decimal value, string parameterName, string ExceptionMessage = "值只能大于0") |
|
|
|
{ |
|
|
|
if (value > 0) |
|
|
|
{ |
|
|
|
throw new ArgumentException($"{parameterName}{ExceptionMessage}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 数据检查 decimal
|
|
|
|
/// </summary>
|
|
|
|
@ -484,7 +511,7 @@ namespace Shentun.Peis |
|
|
|
/// <exception cref="ArgumentException"></exception>
|
|
|
|
public static void CheckDecimalIsNull(decimal? value, string parameterName, string ExceptionMessage = "不能为空") |
|
|
|
{ |
|
|
|
if (value == null || value == 0) |
|
|
|
if (value == null ) |
|
|
|
{ |
|
|
|
throw new ArgumentException($"{parameterName}{ExceptionMessage}"); |
|
|
|
} |
|
|
|
|