insign/dumb-emails-validator
Composer 安装命令:
composer require insign/dumb-emails-validator
包简介
Laravel validator for common email domain typos
README 文档
README
This package provides a custom validator for Laravel that checks for common typos in email domains.
Installation
-
Install the package via Composer:
composer require insign/laravel-dumb-emails-validator
-
Publish the config file (optional):
php artisan vendor:publish --provider="insign\DumbEmailsValidator\DumbEmailsValidatorServiceProvider"
Usage
Use the dumb_email rule in your validation rules:
use Illuminate\Support\Facades\Validator; $validator = Validator::make($request->all(), [ 'email' => 'required|email|dumb_email', ]); if ($validator->fails()) { // Handle validation errors dd($validator->errors()); }
Customization
You can customize the list of domain corrections, and the error message in the config/dumb-emails.php file.
return [ 'corrections' => [ 'gmal.com' => 'gmail.com', // Add your custom corrections here // ... ], 'message' => "Did you mean @:correct_domain?" // Change the default message, you can use :attribute and :correct_domain placeholders ];
The :attribute placeholder will be replaced with the field name (e.g., "email"), and :correct_domain will be replaced with the suggested correct domain.
**6. `LICENSE`**
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar sam@hocevar.net
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- You just DO WHAT THE FUCK YOU WANT TO.
**How to Use in Your Laravel Project**
1. **Create the extension directory:** In your Laravel project's root, create a directory like `packages/your-vendor/laravel-dumb-emails-validator` (replace `your-vendor` with your vendor name, e.g., your GitHub username).
2. **Place the files:** Put the files from above (`src/`, `config/`, `README.md`, `LICENSE`) into the `laravel-dumb-emails-validator` directory.
3. **Composer:** In your project's main `composer.json`, add the following to the `autoload` section (under `psr-4`):
```json
"autoload": {
"psr-4": {
"App\\": "app/",
// ... other autoload entries
"insign\\DumbEmailsValidator\\": "packages/your-vendor/laravel-dumb-emails-validator/src"
}
},
```
And add in the `repositories` section:
```json
"repositories": [
{
"type": "path",
"url": "packages/your-vendor/laravel-dumb-emails-validator"
}
]
```
4. **Install:** Run `composer require your-vendor/laravel-dumb-emails-validator`
5. **Publish Config:** Run `php artisan vendor:publish --provider="insign\DumbEmailsValidator\DumbEmailsValidatorServiceProvider" --tag="config"`
6. **Register Service Provider:** Add the provider to your `config/app.php`:
```php
'providers' => [
// ...
insign\DumbEmailsValidator\DumbEmailsValidatorServiceProvider::class,
],
```
Now you can use the `dumb_email` validation rule as shown in the `README.md`. Remember to adjust the vendor name and namespaces as needed if you change them.
insign/dumb-emails-validator 适用场景与选型建议
insign/dumb-emails-validator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.2k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 insign/dumb-emails-validator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 insign/dumb-emails-validator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-06