UserEmailValidator.php 437 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace App\Module\User\Validator;
  3. use App\Module\User\Models\User;
  4. use UCore\Validator;
  5. /**
  6. * 用户邮箱是否 不存在true
  7. *
  8. */
  9. class UserEmailValidator extends Validator
  10. {
  11. public function validate(mixed $value, array $data): bool
  12. {
  13. // dd($value);
  14. $user = User::query()->where('email', $value)->first();
  15. if ($user) {
  16. return false;
  17. }
  18. return true;
  19. }
  20. }