arubacao / tld-checker
PHP顶级域名(TLD)验证库
1.2.251
2024-09-22 04:01 UTC
Requires
- php: ^7.0|^8.0
- ext-intl: *
Requires (Dev)
- orchestra/testbench: ~3.0|^4.0|^5.0|^6.0
- phpunit/phpunit: ~4.8.36 || >=5.7.21
Suggests
- illuminate/validation: Required for Laravel validation
- dev-master
- 1.2.251
- 1.2.250
- 1.2.249
- 1.2.248
- 1.2.247
- 1.2.246
- 1.2.245
- 1.2.244
- 1.2.243
- 1.2.242
- 1.2.241
- 1.2.240
- 1.2.239
- 1.2.238
- 1.2.237
- 1.2.236
- 1.2.235
- 1.2.234
- 1.2.233
- 1.2.232
- 1.2.231
- 1.2.230
- 1.2.229
- 1.2.228
- 1.2.227
- 1.2.226
- 1.2.225
- 1.2.224
- 1.2.223
- 1.2.222
- 1.2.221
- 1.2.220
- 1.2.219
- 1.2.218
- 1.2.217
- 1.2.216
- 1.2.215
- 1.2.214
- 1.2.213
- 1.2.212
- 1.2.211
- 1.2.210
- 1.2.209
- 1.2.208
- 1.2.207
- 1.2.206
- 1.2.205
- 1.2.204
- 1.2.203
- 1.2.202
- 1.2.201
- 1.2.200
- 1.2.199
- 1.2.198
- 1.2.197
- 1.2.196
- 1.2.195
- 1.2.194
- 1.2.193
- 1.2.192
- 1.2.191
- 1.2.190
- 1.2.189
- 1.2.188
- 1.2.187
- 1.2.186
- 1.2.185
- 1.2.184
- 1.2.183
- 1.2.182
- 1.2.181
- 1.2.180
- 1.2.179
- 1.2.178
- 1.2.177
- 1.2.176
- 1.2.175
- 1.2.174
- 1.2.173
- 1.2.172
- 1.2.171
- 1.2.170
- 1.2.169
- 1.2.168
- 1.2.167
- 1.2.166
- 1.2.165
- 1.2.164
- 1.2.163
- 1.2.162
- 1.2.161
- 1.2.160
- 1.2.159
- 1.2.158
- 1.2.157
- 1.2.156
- 1.2.155
- 1.2.154
- 1.2.153
- 1.2.152
- 1.2.151
- 1.2.150
- 1.2.149
- 1.2.148
- 1.2.147
- 1.2.146
- 1.2.145
- 1.2.144
- 1.2.143
- 1.2.142
- 1.2.141
- 1.2.140
- 1.2.139
- 1.2.138
- 1.2.137
- 1.2.136
- 1.2.135
- 1.2.134
- 1.2.133
- 1.2.132
- 1.2.131
- 1.2.130
- 1.2.129
- 1.2.128
- 1.2.127
- 1.2.126
- 1.2.125
- 1.2.124
- 1.2.123
- 1.2.122
- 1.2.121
- 1.2.120
- 1.2.119
- 1.2.118
- 1.2.117
- 1.2.116
- 1.2.115
- 1.2.114
- 1.2.113
- 1.2.112
- 1.2.111
- 1.2.110
- 1.2.109
- 1.2.108
- 1.2.107
- 1.2.106
- 1.2.105
- 1.2.104
- 1.2.103
- 1.2.102
- 1.2.101
- 1.2.100
- 1.2.99
- 1.2.98
- 1.2.97
- 1.2.96
- 1.2.95
- 1.2.94
- 1.2.93
- 1.2.92
- 1.2.91
- 1.2.90
- 1.2.89
- 1.2.88
- 1.2.87
- 1.2.86
- 1.2.85
- 1.2.84
- 1.2.83
- 1.2.82
- 1.2.81
- 1.2.80
- 1.2.79
- 1.2.78
- 1.2.77
- 1.2.76
- 1.2.75
- 1.2.74
- 1.2.73
- 1.2.72
- 1.2.71
- 1.2.70
- 1.2.69
- 1.2.68
- 1.2.67
- 1.2.66
- 1.2.65
- 1.2.64
- 1.2.63
- 1.2.62
- 1.2.61
- 1.2.60
- 1.2.59
- 1.2.58
- 1.2.57
- 1.2.56
- 1.2.55
- 1.2.54
- 1.2.53
- 1.2.52
- 1.2.51
- 1.2.50
- 1.2.49
- 1.2.48
- 1.2.47
- 1.2.46
- 1.2.45
- 1.2.44
- 1.2.43
- 1.2.42
- 1.2.41
- 1.2.40
- 1.2.39
- 1.2.38
- 1.2.37
- 1.2.36
- 1.2.35
- 1.2.34
- 1.2.33
- 1.2.32
- 1.2.31
- 1.2.30
- 1.2.29
- 1.2.28
- 1.2.27
- 1.2.26
- 1.2.25
- 1.2.24
- 1.2.23
- 1.2.22
- 1.2.21
- 1.2.20
- 1.2.19
- 1.2.18
- 1.2.17
- 1.2.16
- 1.2.15
- 1.2.14
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.50
- 1.1.49
- 1.1.48
- 1.1.47
- 1.1.46
- 1.1.45
- 1.1.44
- 1.1.43
- 1.1.42
- 1.1.41
- 1.1.40
- 1.1.39
- 1.1.38
- 1.1.37
- 1.1.36
- 1.1.35
- 1.1.34
- 1.1.33
- 1.1.32
- 1.1.31
- 1.1.30
- 1.1.29
- 1.1.28
- 1.1.27
- 1.1.26
- 1.1.25
- 1.1.24
- 1.1.23
- 1.1.22
- 1.1.21
- 1.1.20
- 1.1.19
- 1.1.18
- 1.1.17
- 1.1.16
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0
- dev-analysis-vZWPdE
This package is auto-updated.
Last update: 2024-09-22 04:02:43 UTC
README
此包允许通过iana.org的DNS根区域数据库验证顶级域名。
用于验证例如 域名 或 电子邮件地址。
DNS根区域是DNS层次结构的最高部分,涉及将“顶级域名”的管理责任委托出去,顶级域名是域名名的最后一个部分,如.com、.uk和.nz。
数据库存储在本地,并自动更新为新版本。
安装
使用composer安装此包
composer require arubacao/tld-checker
Laravel
如果您想使用arubacao/tld-checker
与Laravel验证器,您还必须注册服务提供者
(仅适用于Laravel <=5.4
,对于Laravel >=5.5
自动发现已启用)。
// config/app.php 'providers' => [ // Other Service Providers Arubacao\TldChecker\TldCheckerServiceProvider::class, ],
注意事项
arubacao/tld-checker
对PHP7.0
-8.0
& Laravel5.0
-8.x
进行过功能性和全面测试。
用法
使用Validator::isTld()
检查TLD
use Arubacao\TldChecker\Validator; Validator::isTld('com'); // true Validator::isTld('CN'); // true (case insensitiv) Validator::isTld('москва'); // true (works with internationalized domain name (IDN) | unicode) Validator::isTld('XN--CZRS0T'); // true (works with encoded IDN | 商店) Validator::isTld('.org'); // true (allows dot prefix) Validator::isTld('apricot'); // false
使用Validator::endsWithTld()
检查字符串是否以有效的TLD结尾
use Arubacao\TldChecker\Validator; Validator::endsWithTld('apple.com'); // true Validator::endsWithTld('NEWS.CN'); // true (case insensitiv) Validator::endsWithTld('müller.vermögensberater'); // true (works with internationalized domain name (IDN) | unicode) Validator::endsWithTld('xn--mller-kva.xn--vermgensberater-ctb');// true (works with encoded IDN | müller.vermögensberater) Validator::endsWithTld('farming.apricot'); // false
此包扩展了Laravel验证器,增加了这两个方法
is_tld
ends_with_tld
用法如下
$request->validate([ 'tld' => 'required|is_tld', 'email' => 'required|ends_with_tld' ]);
测试
composer test
贡献
请参阅CONTRIBUTING以获取详细信息。
致谢
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。