承接 wuori/laravel-unique-gmail-validation 相关项目开发

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

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

wuori/laravel-unique-gmail-validation

Composer 安装命令:

composer require wuori/laravel-unique-gmail-validation

包简介

A validation rule to test uniqueness of Gmail addresses with ./+ modifiers.

README 文档

README

Latest Version on Packagist Total Downloads

Gmail allows two modifiers, + and . to be added to your email address without affecting delivery. For example, michaelwuori@gmail.com and michael.wuori@gmail.com both work as valid addresses to the same Gmail account.

The period (.) modifier can be placed anywhere within your account name, as in the example above.

The plus (+) modifier can be appended to your account name. Example: michael.wuori+junk@gmail.com.

This validation rule removes any period modifiers as well as any +foo appendages then compares the address to any existing @gmail.com emails that exist in the targeted model.

Installation

You can install the package via composer:

composer require wuori/laravel-unique-gmail-validation

The package will automatically register itself.

Using the UniqueGmail Rule

Include the rule:

...
use Illuminate\Http\Request;
use Wuori\UniqueGmail\UniqueGmail;
...

Attach the rule to an email field, passing the Model you wish to validate against as the first parameter.

If no Model is passed, the rule will default to \App\Models\User.

// default User model
$validator = $request->validate([
    'email' => [new UniqueGmail()]
]);

// custom model
$validator = $request->validate([
    'email' => [new UniqueGmail(\App\Models\Customers::class)]
]);

// combined with other rules
$validator = $request->validate([
    'email' => ['required','email','unique:users,email,NULL,id', new UniqueGmail(\App\Models\User::class)]
]);

This validation rule will pass if the id of the logged in user matches the user_id on TestModel who's it is in the model_id key of the request.

Custom Error Message

By default the UniqueGmail rule will use Laravel's built-in unique validation message (trans('validation.unique')).

You can supply your own message as an entry to the second parameter, $options:

$options = [
    'message' => 'An account already exists for :existing_email, a varient of :requested_email.'
];
$validator = $request->validate([
    'email' => [new UniqueGmail(\App\Models\User::class, $options)]
]);

The custom message accepts two optional attributes to replace:

:existing_email is replaced with the matching (existing) email address.

:requested_email is replaced with the email address provided in the request.

Testing

Coming soon...

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security

If you discover any security related issues, please email michael.wuori@gmail.com instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固