承接 arubacao/tld-checker 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

arubacao/tld-checker

最新稳定版本:1.2.292

Composer 安装命令:

composer require arubacao/tld-checker

包简介

Top Level Domain (TLD) validation library for PHP

README 文档

README

Latest Version on Packagist Build Status Codecov Quality Score Total Downloads

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 PHP 7.0 - 8.0 & Laravel 5.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.

统计信息

  • 总下载量: 1.49M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 72
  • 点击次数: 2
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 71
  • Watchers: 3
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-23