DeniedEmail.php 935 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Rules;
  3. use Illuminate\Contracts\Validation\Rule;
  4. class DeniedEmail implements Rule
  5. {
  6. /**
  7. * Create a new rule instance.
  8. *
  9. * @return void
  10. */
  11. public function __construct()
  12. {
  13. //
  14. }
  15. /**
  16. * Determine if the validation rule passes.
  17. *
  18. * @param string $attribute
  19. * @param mixed $value
  20. * @return bool
  21. */
  22. public function passes($attribute, $value)
  23. {
  24. // 금지 이메일 포함 여부
  25. $deniedEmails = config('denied_email_list') ?? "";
  26. $deniedEmails = aTrim($deniedEmails);
  27. $deniedEmails = explode(',', $deniedEmails);
  28. return (in_array($value, $deniedEmails) ? false : true);
  29. }
  30. /**
  31. * Get the validation error message.
  32. *
  33. * @return string
  34. */
  35. public function message()
  36. {
  37. return "입력하신 E-mail 주소는 사용이 금지되었습니다.";
  38. }
  39. }