arubacao / tld-checker
Top Level Domain (TLD) validation library for PHP
Installs: 1 033 078
Dependents: 2
Suggesters: 0
Security: 0
Stars: 70
Watchers: 4
Forks: 15
Open Issues: 0
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.264
- 1.2.263
- 1.2.262
- 1.2.261
- 1.2.260
- 1.2.259
- 1.2.258
- 1.2.257
- 1.2.256
- 1.2.255
- 1.2.254
- 1.2.253
- 1.2.252
- 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-wOrr3e
This package is auto-updated.
Last update: 2024-12-22 04:06:45 UTC
README
This package allows validation of top level domains against the official The DNS Root Zone database from iana.org.
Use this to validate e.g. domains or email addresses.
The DNS Root Zone is the upper-most part of the DNS hierarchy, and involves delegating administrative responsibility of “top-level domains”, which are the last segment of a domain name, such as .com, .uk and .nz.
The database is stored locally and automatically updated for new database versions.
Installation
Install this package via composer:
composer require arubacao/tld-checker
Laravel
If you would like to use arubacao/tld-checker
with the Laravel Validator, you must also register the service provider:
(only required for Laravel <=5.4
, for Laravel >=5.5
auto-discovery is enabled.)
// config/app.php 'providers' => [ // Other Service Providers Arubacao\TldChecker\TldCheckerServiceProvider::class, ],
Notes:
arubacao/tld-checker
is functional and fully tested for PHP7.0
-8.0
& Laravel5.0
-8.x
.
Usage
Check a TLD using Validator::isTld()
:
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
Check if a string ends with a valid TLD using Validator::endsWithTld()
:
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
This package extends the Laravel Validator with these 2 methods:
is_tld
ends_with_tld
Use them as follows:
$request->validate([ 'tld' => 'required|is_tld', 'email' => 'required|ends_with_tld' ]);
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.