IsUrausAddress.php 688 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace UCore\Validator;
  3. use App\Module\Ulogic\Services\UserAddressService;
  4. use UCore\Validator;
  5. class IsUrausAddress extends Validator
  6. {
  7. /**
  8. * @param mixed $value
  9. * @param array $data
  10. * @return bool
  11. * 检测是否uraus地址
  12. */
  13. public function validate(mixed $value, array $data): bool
  14. {
  15. $sysStr = '0xuraus';
  16. $prefix = substr($data['to_address'], 0, 7); // 截取前 7 位
  17. if ($sysStr !== $prefix) {
  18. return false;
  19. }
  20. $addressData = UserAddressService::getDataByAddress($data['to_address']);
  21. if (!$addressData) {
  22. return false;
  23. }
  24. return true;
  25. }
  26. }