Skip to content

Commit

Permalink
laravel support
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-tebiev committed May 28, 2024
1 parent 09b5074 commit a318c5d
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/Adapters/Laravel/DisposableEmailFilterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function boot(ValidationFactory $validationFactory, Translator $translato
], self::PACKAGE_NAMESPACE);
}

$validationFactory->extend(DisposableEmailRule::NAME, static function (string $attribute, string $emailAddress) {
$validationFactory->extend(DisposableEmailRule::NAME, static function (string $attribute, string $emailAddress): bool {
return !DisposableEmailRule::isDisposable($emailAddress);
}, $translator->get(DisposableEmailRule::TRANSLATION_KEY));

Expand All @@ -57,8 +57,8 @@ public function register(): void
$this->mergeConfigFrom(self::CONFIG_PATH, self::PACKAGE_NAMESPACE);

$this->app->singleton(DisposableEmailFilter::class, static function (Application $app): DisposableEmailFilter {
/** @var Repository $config */
$config = $app->get('config');
assert($config instanceof Repository);

if (!isset($config->get(self::PACKAGE_NAMESPACE)['whitelist'])) {
throw new \RuntimeException(self::PACKAGE_NAMESPACE . ': Whitelist array is not defined in configuration file or configuration file is not loaded');
Expand Down
3 changes: 0 additions & 3 deletions src/Adapters/Laravel/ValidationRules/DisposableEmailRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public function validate(string $attribute, $emailAddress, \Closure $fail): void
}
}

/**
* @see \Beeyev\DisposableEmailFilter\Adapters\Laravel\DisposableEmailFilterServiceProvider::boot()
*/
public static function isDisposable(string $emailAddress): bool
{
if (DisposableEmail::isEmailAddressValid($emailAddress)) {
Expand Down
2 changes: 0 additions & 2 deletions src/Adapters/Laravel/stubs/lang/br/validation.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

return [
'disposable_email_validation_message' => 'Não é permitido usar um endereço de e-mail descartável.',
];
2 changes: 0 additions & 2 deletions src/Adapters/Laravel/stubs/lang/de/validation.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

return [
'disposable_email_validation_message' => 'Eine Wegwerf-E-Mail-Adresse ist nicht erlaubt.',
];
2 changes: 0 additions & 2 deletions src/Adapters/Laravel/stubs/lang/en/validation.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

return [
'disposable_email_validation_message' => 'Disposable email address is not allowed.',
];
2 changes: 0 additions & 2 deletions src/Adapters/Laravel/stubs/lang/fr/validation.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

return [
'disposable_email_validation_message' => 'Une adresse e-mail jetable n\'est pas autorisée.',
];
2 changes: 0 additions & 2 deletions src/Adapters/Laravel/stubs/lang/nl/validation.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

return [
'disposable_email_validation_message' => 'Een wegwerp e-mailadres is niet toegestaan.',
];
4 changes: 1 addition & 3 deletions src/Adapters/Laravel/stubs/lang/ru/validation.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

return [
'disposable_email_validation_message' => 'Одноразовый адрес электронной почты не разрешен.',
'disposable_email_validation_message' => 'Одноразовый адрес электронной почты запрещен.',
];
5 changes: 5 additions & 0 deletions src/Adapters/Laravel/stubs/lang/ua/validation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'disposable_email_validation_message' => 'Одноразова електронна адреса не дозволяється.',
];

0 comments on commit a318c5d

Please sign in to comment.