|
|
@@ -30,8 +30,9 @@ PM> Install-Package Masuit.Tools.Core
|
|
|
```
|
|
|
## 为工具库注册配置
|
|
|
工具库需要用到外部配置节:
|
|
|
-1. EmailDomainWhiteList,邮箱校验需要用到的白名单域名,若未配置,则不启用邮箱校验白名单
|
|
|
-2. BaiduAK,获取IP/地理位置相关百度云APIKey,若未配置,则无法调用GetIPLocation以及GetPhysicalAddress相关方法
|
|
|
+1. EmailDomainWhiteList,邮箱校验需要用到的白名单域名,英文逗号分隔,每个元素支持正则表达式,若未配置,则不启用邮箱校验白名单
|
|
|
+2. EmailDomainBlockList,邮箱校验需要用到的黑名单域名,英文逗号分隔,每个元素支持正则表达式,且黑名单优先级高于白名单,若未配置,则不启用邮箱校验黑白名单
|
|
|
+3. BaiduAK,获取IP/地理位置相关百度云APIKey,若未配置,则无法调用GetIPLocation以及GetPhysicalAddress相关方法
|
|
|
```csharp
|
|
|
public Startup(IConfiguration configuration)
|
|
|
{
|
|
|
@@ -41,7 +42,7 @@ public Startup(IConfiguration configuration)
|
|
|
## 特色功能示例代码
|
|
|
### 1.检验字符串是否是Email、手机号、URL、IP地址、身份证号
|
|
|
```csharp
|
|
|
-bool isEmail="[email protected]".MatchEmail(); // 可在appsetting.json中添加EmailDomainWhiteList配置邮箱域名白名单,逗号分隔
|
|
|
+bool isEmail="[email protected]".MatchEmail(); // 可在appsetting.json中添加EmailDomainWhiteList和EmailDomainBlockList配置邮箱域名黑白名单,逗号分隔,如"EmailDomainBlockList": "^\\w{1,5}@qq.com,^\\w{1,5}@163.com,^\\w{1,5}@gmail.com,^\\w{1,5}@outlook.com",
|
|
|
bool isInetAddress = "114.114.114.114".MatchInetAddress();
|
|
|
bool isUrl = "http://masuit.com".MatchUrl();
|
|
|
bool isPhoneNumber = "15205201520".MatchPhoneNumber();
|