AddressValidator.php 570 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * This file is part of web3.php package.
  4. *
  5. * (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
  6. *
  7. * @author Peter Lai <alk03073135@gmail.com>
  8. * @license MIT
  9. */
  10. namespace blockchain\web3\src\Validators;
  11. use blockchain\web3\src\Validators\IValidator;
  12. class AddressValidator
  13. {
  14. /**
  15. * validate
  16. *
  17. * @param string $value
  18. * @return bool
  19. */
  20. public static function validate($value)
  21. {
  22. if (!is_string($value)) {
  23. return false;
  24. }
  25. return (preg_match('/^0x[a-fA-F0-9]{40}$/', $value) >= 1);
  26. }
  27. }