EmailNotBanned.php 598 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Rules;
  3. use Closure;
  4. use App\Services\EmailService;
  5. use Illuminate\Contracts\Validation\ValidationRule;
  6. class EmailNotBanned implements ValidationRule
  7. {
  8. /**
  9. * Run the validation rule.
  10. *
  11. * @param string $attribute
  12. * @param mixed $value
  13. * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
  14. * @return void
  15. */
  16. public function validate(string $attribute, mixed $value, Closure $fail): void
  17. {
  18. if (EmailService::isBanned($value)) {
  19. $fail('Email is invalid.');
  20. }
  21. }
  22. }