Class Validate
Namespace: Tool.Utils
Assembly: Tool.Net.dll
各种验证类,包含正则表达式
public sealed class ValidateInheritance
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 判断当前请求用户的设备名
public static UserSystem CheckAgent(string UserAgent = null)Parameters
UserAgent string
平台信息,为空时,获取默认信息
Returns
枚举CheckedDataRow(DataRow)
判断对象中的是否为空,行为空,对象为空
public static bool CheckedDataRow(DataRow dr)Parameters
dr DataRow
Returns
返回类型
CheckedDataSet(DataSet)
判断对象中的是否为空,行为空,表为空,对象为空
public static bool CheckedDataSet(DataSet ds)Parameters
ds DataSet
Returns
返回类型
CheckedDataTable(DataTable)
判断对象中的是否为空,行为空,对象为空
public static bool CheckedDataTable(DataTable dt)Parameters
dt DataTable
Returns
返回类型
CheckedObjcetArray(object[])
判断对象中的是否为空
public static bool CheckedObjcetArray(object[] obj)Parameters
obj object[]
数组
Returns
返回类型
GetCardDetail(string)
根据银行卡获取信息
public static Validate.CardDetail GetCardDetail(string cardNo)Parameters
cardNo string
银行卡
Returns
GetGdIpRegion(string)
根据IP获取所在城市地区(该秘钥有dll内部提供,如有问题请联系dll开发者)(高德)
public static dynamic GetGdIpRegion(string ip)Parameters
ip string
IP地址
Returns
dynamic
返回所在城市地区
GetGdIpRegion(string, string)
根据IP获取所在城市地区(高德)
public static dynamic GetGdIpRegion(string ip, string key)Parameters
ip string
IP地址
key string
高德秘钥
Returns
dynamic
返回所在城市地区
GetIpRegion(string)
根据IP获取所在城市地区(该秘钥有dll内部提供,如有问题请联系dll开发者)(百度)
public static dynamic GetIpRegion(string ip)Parameters
ip string
IP地址
Returns
dynamic
返回所在城市地区
GetIpRegion(string, string)
根据IP获取所在城市地区(百度)
public static dynamic GetIpRegion(string ip, string ak)Parameters
ip string
IP地址
ak string
百度秘钥
Returns
dynamic
返回所在城市地区
GetTbIpRegion(string)
淘宝获取IP详细信息(不举建使用该API)
public static dynamic GetTbIpRegion(string ip)Parameters
ip string
IP地址
Returns
dynamic
返回所在城市地区
IsBase64String(string)
判断是否是 Base64 格式的字符串
public static bool IsBase64String(string expression)Parameters
expression string
字符串
Returns
返回类型
IsCnChar(string)
判断是否是 Char 类型数据
public static bool IsCnChar(string expression)Parameters
expression string
字符串
Returns
IsCnCharAndWordAndNum(string)
判断是否是 Char 类型数据
public static bool IsCnCharAndWordAndNum(string expression)Parameters
expression string
字符串
Returns
IsDate(string)
判断是否是时间类型数据
public static bool IsDate(string dateval)Parameters
dateval string
字符串
Returns
IsDecimalFraction(string)
判断是否是十进制分数
public static bool IsDecimalFraction(string expression)Parameters
expression string
字符串
Returns
返回类型
IsDoEmail(string)
判断是否是电子邮件格式
public static bool IsDoEmail(string strEmail)Parameters
strEmail string
字符串
Returns
IsDomain(string)
判断是否是域名格式
public static bool IsDomain(string strHost)Parameters
strHost string
Returns
IsDouble(object)
判断是否是Double格式
public static bool IsDouble(object expression)Parameters
expression object
Returns
IsEmail(string)
判断值是不是邮箱格式
public static bool IsEmail(string strEmail)Parameters
strEmail string
判断值
Returns
返回类型
IsFileName(string)
判断值是不是文件名
public static bool IsFileName(string filename)Parameters
filename string
判断值
Returns
IsIDCard(string)
判断值是不是合法的身份证
public static bool IsIDCard(string strIDCard)Parameters
strIDCard string
判断值
Returns
IsIP(string)
验证IP地址是否合法
public static bool IsIP(string ipval)Parameters
ipval string
待验证的IP
Returns
返回类型
IsIPAndPort(string)
是不是有效的IP和端口
public static bool IsIPAndPort(string ipval)Parameters
ipval string
判断值
Returns
返回类型
IsIPSect(string)
是不是有效的IP
public static bool IsIPSect(string ipval)Parameters
ipval string
判断值
Returns
返回类型
IsImage(string)
判断值是不是图像
public static bool IsImage(string filename)Parameters
filename string
文件名称
Returns
IsLongDate(string)
是不是长日期
public static bool IsLongDate(string dateval)Parameters
dateval string
字符串
Returns
IsMobileCode(string)
是不是移动电话号码
public static bool IsMobileCode(string strMobile)Parameters
strMobile string
字符串
Returns
IsNegativeInt(string)
是不是负整数
public static bool IsNegativeInt(string expression)Parameters
expression string
字符串
Returns
IsNickName(string)
是否是昵称
public static bool IsNickName(string strVal)Parameters
strVal string
字符串
Returns
IsNotNull(object)
判断expVal里面是否有值
public static bool IsNotNull(object expVal)Parameters
expVal object
判断值
Returns
返回类型
IsNull(object)
判断expVal里面是否为空
public static bool IsNull(object expVal)Parameters
expVal object
判断值
Returns
返回类型
IsNumeric(object)
判断是不是数字
public static bool IsNumeric(object expression)Parameters
expression object
判断值
Returns
返回类型
IsNumericArray(string[])
验证这个string数组是否全是可以强转为int的对象
public static bool IsNumericArray(string[] strNumber)Parameters
strNumber string[]
Returns
IsPhoneCode(string)
验证是否是合格的电话号码
public static bool IsPhoneCode(string strPhone)Parameters
strPhone string
号码
Returns
IsPhysicalPath(string)
验证是否是物理路径
public static bool IsPhysicalPath(string s)Parameters
s string
路径
Returns
IsPositiveInt(string)
验证是否是正整数
public static bool IsPositiveInt(string expression)Parameters
expression string
字符串
Returns
IsPositiveInt64(string)
验证是否是正整数64位的
public static bool IsPositiveInt64(string expression)Parameters
expression string
字符串
Returns
IsPostalCode(string)
验证是否是邮政编码
public static bool IsPostalCode(string strPostalCode)Parameters
strPostalCode string
字符串
Returns
IsRelativePath(string)
验证是否是相对路径
public static bool IsRelativePath(string s)Parameters
s string
字符串
Returns
IsSQL(string)
检测字符串中是否包含SQL注入
public static bool IsSQL(string sqlExpression)Parameters
sqlExpression string
要检测的字符串
Returns
返回结果
IsSafeInputWords(string)
验证是否是安全的输入词
public static bool IsSafeInputWords(string expression)Parameters
expression string
字符串
Returns
IsSafeSqlString(string)
验证是否是安全的Sql字符串
public static bool IsSafeSqlString(string expression)Parameters
expression string
字符串
Returns
IsSafety(string)
验证是否是安全的Sql字符串
public static bool IsSafety(string s)Parameters
s string
字符串
Returns
IsShortDate(string)
验证字符串是不是短日期
public static bool IsShortDate(string dateval)Parameters
dateval string
要检测的字符串
Returns
返回结果
IsSpecifyWordAndNum(string, int, int)
检测字符串是不是指定单词和数字
public static bool IsSpecifyWordAndNum(string expression, int start, int end)Parameters
expression string
要检测的字符串
start int
开始下标
end int
结束下标
Returns
返回结果
IsTime(string)
验证字符串是不是时间格式
public static bool IsTime(string timeval)Parameters
timeval string
要检测的字符串
Returns
返回结果
IsURL(string)
验证字符串是不是有效的Url链接
public static bool IsURL(string strUrl)Parameters
strUrl string
要检测的字符串
Returns
返回结果
IsUnicode(string)
验证字符串是不是Unicode编码格式
public static bool IsUnicode(string s)Parameters
s string
要检测的字符串
Returns
返回结果
IsUserName(string)
验证字符串是不是中文名称
public static bool IsUserName(string strVal)Parameters
strVal string
要检测的字符串
Returns
返回结果
IsWordAndNum(string)
检测字符串是不是单词和数字
public static bool IsWordAndNum(string expression)Parameters
expression string
要检测的字符串
Returns
返回结果