-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,8 @@ If you want to pass some domains always you can add them to the whitelist. These | |
|
||
## Usage | ||
|
||
## Validation Rule | ||
|
||
This package provides a basic `TrashmailRule` which you can use. All more specific rules only extend this rule with a predefined `format`. | ||
|
||
```php | ||
|
@@ -60,6 +62,47 @@ $rule = new TrashmailRule(false); | |
$rule->nullable(); | ||
``` | ||
|
||
## Facade | ||
|
||
You can also use the facade if you want to check any email address outside validation. | ||
This will run the same logic as the validation rule and runs all providers set in the config. | ||
|
||
```php | ||
use Elbgoods\TrashmailRule\Facades\Trashmail; | ||
|
||
Trashmail::isDisposable('[email protected]'); | ||
``` | ||
|
||
## single Provider | ||
|
||
You can also check using a single provider only. | ||
Keep in mind that all providers only accept the domain to check and not a full email address. | ||
The facade provides a method that returns the domain used in an email address. | ||
|
||
```php | ||
use Elbgoods\TrashmailRule\Facades\Trashmail; | ||
|
||
Trashmail::provider('config')->isDisposable( | ||
Trashmail::getDomain('[email protected]') | ||
); | ||
``` | ||
|
||
## custom Provider | ||
|
||
If you want to add your own provider you can do so. | ||
|
||
```php | ||
use Elbgoods\TrashmailRule\Facades\Trashmail; | ||
use Illuminate\Contracts\Container\Container; | ||
use Elbgoods\TrashmailRule\Contracts\ProviderContract; | ||
|
||
Trashmail::extend('custom_provider', static function (Container $app): ProviderContract { | ||
return new CustomProvider(); | ||
}); | ||
``` | ||
|
||
|
||
|
||
## Changelog | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters