src/DotNetCommon.Core/Validate/ValidateHelper.cs
(开头部分) 10KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using DotNetCommon;
using DotNetCommon.Extensions;
using DotNetCommon.Data;
using DotNetCommon.Validate;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
namespace DotNetCommon.Validate
{
/// <summary>
/// 校验帮助类
/// </summary>
public static class ValidateHelper
{
#region 权威校验身份证号码
private static readonly string[] ChinaIDProvinceCodes = {
"11", "12", "13", "14", "15",
"21", "22", "23",
"31", "32", "33", "34", "35", "36", "37",
"41", "42", "43", "44", "45", "46",
"50", "51", "52", "53", "54",
"61", "62", "63", "64", "65",
"71",
"81", "82",
"91"
};
/// <summary>
/// 第二代身份证号,18位长度
/// </summary>
/// <param name="ID"></param>
/// <returns></returns>
public static bool IsChinaIdCard18(string ID)
{
ID = ID.ToUpper();
Match m = Regex.Match(ID, @"\d{17}[\dX]", RegexOptions.IgnoreCase);
if (!m.Success)
{
return false;
}
if (!ChinaIDProvinceCodes.Contains(ID.Substring(0, 2)))
{
return false;
}
CultureInfo zhCN = new CultureInfo("zh-CN", true);
if (!DateTime.TryParseExact(ID.Substring(6, 8), "yyyyMMdd", zhCN, DateTimeStyles.None, out DateTime birthday))
{
return false;
}
if (!birthday.IsBetween(new DateTime(1800, 1, 1), DateTime.Today))
{
return false;
}
int[] factors = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
后面还有 248 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
