Skip to content

Class Validate

Namespace: Tool.Utils
Assembly: Tool.Net.dll

各种验证类,包含正则表达式

csharp
public sealed class Validate

Inheritance

objectValidate

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods

ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)

Remarks

代码由逆血提供支持

Methods

CheckAgent(string)

根据 Agent 判断当前请求用户的设备名

csharp
public static UserSystem CheckAgent(string UserAgent = null)

Parameters

UserAgent string

平台信息,为空时,获取默认信息

Returns

UserSystem

枚举

CheckedDataRow(DataRow)

判断对象中的是否为空,行为空,对象为空

csharp
public static bool CheckedDataRow(DataRow dr)

Parameters

dr DataRow

对象

Returns

bool

返回类型

CheckedDataSet(DataSet)

判断对象中的是否为空,行为空,表为空,对象为空

csharp
public static bool CheckedDataSet(DataSet ds)

Parameters

ds DataSet

对象

Returns

bool

返回类型

CheckedDataTable(DataTable)

判断对象中的是否为空,行为空,对象为空

csharp
public static bool CheckedDataTable(DataTable dt)

Parameters

dt DataTable

对象

Returns

bool

返回类型

CheckedObjcetArray(object[])

判断对象中的是否为空

csharp
public static bool CheckedObjcetArray(object[] obj)

Parameters

obj object[]

数组

Returns

bool

返回类型

GetCardDetail(string)

根据银行卡获取信息

csharp
public static Validate.CardDetail GetCardDetail(string cardNo)

Parameters

cardNo string

银行卡

Returns

Validate.CardDetail

GetGdIpRegion(string)

根据IP获取所在城市地区(该秘钥有dll内部提供,如有问题请联系dll开发者)(高德)

csharp
public static dynamic GetGdIpRegion(string ip)

Parameters

ip string

IP地址

Returns

dynamic

返回所在城市地区

GetGdIpRegion(string, string)

根据IP获取所在城市地区(高德)

csharp
public static dynamic GetGdIpRegion(string ip, string key)

Parameters

ip string

IP地址

key string

高德秘钥

Returns

dynamic

返回所在城市地区

GetIpRegion(string)

根据IP获取所在城市地区(该秘钥有dll内部提供,如有问题请联系dll开发者)(百度)

csharp
public static dynamic GetIpRegion(string ip)

Parameters

ip string

IP地址

Returns

dynamic

返回所在城市地区

GetIpRegion(string, string)

根据IP获取所在城市地区(百度)

csharp
public static dynamic GetIpRegion(string ip, string ak)

Parameters

ip string

IP地址

ak string

百度秘钥

Returns

dynamic

返回所在城市地区

GetTbIpRegion(string)

淘宝获取IP详细信息(不举建使用该API)

csharp
public static dynamic GetTbIpRegion(string ip)

Parameters

ip string

IP地址

Returns

dynamic

返回所在城市地区

IsBase64String(string)

判断是否是 Base64 格式的字符串

csharp
public static bool IsBase64String(string expression)

Parameters

expression string

字符串

Returns

bool

返回类型

IsCnChar(string)

判断是否是 Char 类型数据

csharp
public static bool IsCnChar(string expression)

Parameters

expression string

字符串

Returns

bool

IsCnCharAndWordAndNum(string)

判断是否是 Char 类型数据

csharp
public static bool IsCnCharAndWordAndNum(string expression)

Parameters

expression string

字符串

Returns

bool

IsDate(string)

判断是否是时间类型数据

csharp
public static bool IsDate(string dateval)

Parameters

dateval string

字符串

Returns

bool

IsDecimalFraction(string)

判断是否是十进制分数

csharp
public static bool IsDecimalFraction(string expression)

Parameters

expression string

字符串

Returns

bool

返回类型

IsDoEmail(string)

判断是否是电子邮件格式

csharp
public static bool IsDoEmail(string strEmail)

Parameters

strEmail string

字符串

Returns

bool

IsDomain(string)

判断是否是域名格式

csharp
public static bool IsDomain(string strHost)

Parameters

strHost string

Returns

bool

IsDouble(object)

判断是否是Double格式

csharp
public static bool IsDouble(object expression)

Parameters

expression object

Returns

bool

IsEmail(string)

判断值是不是邮箱格式

csharp
public static bool IsEmail(string strEmail)

Parameters

strEmail string

判断值

Returns

bool

返回类型

IsFileName(string)

判断值是不是文件名

csharp
public static bool IsFileName(string filename)

Parameters

filename string

判断值

Returns

bool

IsIDCard(string)

判断值是不是合法的身份证

csharp
public static bool IsIDCard(string strIDCard)

Parameters

strIDCard string

判断值

Returns

bool

IsIP(string)

验证IP地址是否合法

csharp
public static bool IsIP(string ipval)

Parameters

ipval string

待验证的IP

Returns

bool

返回类型

IsIPAndPort(string)

是不是有效的IP和端口

csharp
public static bool IsIPAndPort(string ipval)

Parameters

ipval string

判断值

Returns

bool

返回类型

IsIPSect(string)

是不是有效的IP

csharp
public static bool IsIPSect(string ipval)

Parameters

ipval string

判断值

Returns

bool

返回类型

IsImage(string)

判断值是不是图像

csharp
public static bool IsImage(string filename)

Parameters

filename string

文件名称

Returns

bool

IsLongDate(string)

是不是长日期

csharp
public static bool IsLongDate(string dateval)

Parameters

dateval string

字符串

Returns

bool

IsMobileCode(string)

是不是移动电话号码

csharp
public static bool IsMobileCode(string strMobile)

Parameters

strMobile string

字符串

Returns

bool

IsNegativeInt(string)

是不是负整数

csharp
public static bool IsNegativeInt(string expression)

Parameters

expression string

字符串

Returns

bool

IsNickName(string)

是否是昵称

csharp
public static bool IsNickName(string strVal)

Parameters

strVal string

字符串

Returns

bool

IsNotNull(object)

判断expVal里面是否有值

csharp
public static bool IsNotNull(object expVal)

Parameters

expVal object

判断值

Returns

bool

返回类型

IsNull(object)

判断expVal里面是否为空

csharp
public static bool IsNull(object expVal)

Parameters

expVal object

判断值

Returns

bool

返回类型

IsNumeric(object)

判断是不是数字

csharp
public static bool IsNumeric(object expression)

Parameters

expression object

判断值

Returns

bool

返回类型

IsNumericArray(string[])

验证这个string数组是否全是可以强转为int的对象

csharp
public static bool IsNumericArray(string[] strNumber)

Parameters

strNumber string[]

Returns

bool

IsPhoneCode(string)

验证是否是合格的电话号码

csharp
public static bool IsPhoneCode(string strPhone)

Parameters

strPhone string

号码

Returns

bool

IsPhysicalPath(string)

验证是否是物理路径

csharp
public static bool IsPhysicalPath(string s)

Parameters

s string

路径

Returns

bool

IsPositiveInt(string)

验证是否是正整数

csharp
public static bool IsPositiveInt(string expression)

Parameters

expression string

字符串

Returns

bool

IsPositiveInt64(string)

验证是否是正整数64位的

csharp
public static bool IsPositiveInt64(string expression)

Parameters

expression string

字符串

Returns

bool

IsPostalCode(string)

验证是否是邮政编码

csharp
public static bool IsPostalCode(string strPostalCode)

Parameters

strPostalCode string

字符串

Returns

bool

IsRelativePath(string)

验证是否是相对路径

csharp
public static bool IsRelativePath(string s)

Parameters

s string

字符串

Returns

bool

IsSQL(string)

检测字符串中是否包含SQL注入

csharp
public static bool IsSQL(string sqlExpression)

Parameters

sqlExpression string

要检测的字符串

Returns

bool

返回结果

IsSafeInputWords(string)

验证是否是安全的输入词

csharp
public static bool IsSafeInputWords(string expression)

Parameters

expression string

字符串

Returns

bool

IsSafeSqlString(string)

验证是否是安全的Sql字符串

csharp
public static bool IsSafeSqlString(string expression)

Parameters

expression string

字符串

Returns

bool

IsSafety(string)

验证是否是安全的Sql字符串

csharp
public static bool IsSafety(string s)

Parameters

s string

字符串

Returns

bool

IsShortDate(string)

验证字符串是不是短日期

csharp
public static bool IsShortDate(string dateval)

Parameters

dateval string

要检测的字符串

Returns

bool

返回结果

IsSpecifyWordAndNum(string, int, int)

检测字符串是不是指定单词和数字

csharp
public static bool IsSpecifyWordAndNum(string expression, int start, int end)

Parameters

expression string

要检测的字符串

start int

开始下标

end int

结束下标

Returns

bool

返回结果

IsTime(string)

验证字符串是不是时间格式

csharp
public static bool IsTime(string timeval)

Parameters

timeval string

要检测的字符串

Returns

bool

返回结果

IsURL(string)

验证字符串是不是有效的Url链接

csharp
public static bool IsURL(string strUrl)

Parameters

strUrl string

要检测的字符串

Returns

bool

返回结果

IsUnicode(string)

验证字符串是不是Unicode编码格式

csharp
public static bool IsUnicode(string s)

Parameters

s string

要检测的字符串

Returns

bool

返回结果

IsUserName(string)

验证字符串是不是中文名称

csharp
public static bool IsUserName(string strVal)

Parameters

strVal string

要检测的字符串

Returns

bool

返回结果

IsWordAndNum(string)

检测字符串是不是单词和数字

csharp
public static bool IsWordAndNum(string expression)

Parameters

expression string

要检测的字符串

Returns

bool

返回结果

基于Apache-2.0协议开源