arnidan / yii2-disposable-email-validator
Yii2 disposable email validator
2.0
2021-12-06 11:57 UTC
Requires
- php: >=7.2
- ext-json: *
- mattketmo/email-checker: ^2.0
- yiisoft/yii2: ^2.0
This package is not auto-updated.
Last update: 2025-03-26 02:32:44 UTC
README
This library contains validator for block email from disposable domains like mailinator. Uses mattketmo/email-checker under the hood.
Originally forked from jimmlog/yii2-disposable-email-validator.
Installation
composer require arnidan/yii2-disposable-email-validator
How To Use
- Configure the component in your configuration file (web.php). The parameter additionalDomains is optional.
'components' => [ 'disposableEmail' => [ 'class' => \arnidan\yii2\DisposableEmail::class, 'additionalDomains' => [ 'gmail.com' // for example ], ], ...
- Add
DisposableEmailValidator
in your model, for example: Example of use:
class FormModel extend \yii\base\Model
{
...
/**
* @inheritdoc
*/
public function rules()
{
...
[['email'], 'email'],
[['email'], \arnidan\yii2\DisposableEmailValidator::class],
...
}
...
}
Example with custom message:
class FormModel extend \yii\base\Model
{
...
/**
* @inheritdoc
*/
public function rules()
{
...
[['email'], 'email'],
[['email'], \arnidan\yii2\DisposableEmailValidator::class, 'message' => 'Please provide another email'],
...
}
...
}
License
The MIT License (MIT). See LICENSE file.