IsUserAddress.php 510 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace UCore\Validator;
  3. use App\Module\Ulogic\Model\UserAddress;
  4. use UCore\Validator;
  5. class IsUserAddress extends Validator
  6. {
  7. /**
  8. * @param mixed $value
  9. * @param array $data
  10. * @return bool
  11. * 验证地址id是否属于该用户
  12. */
  13. public function validate(mixed $value, array $data): bool
  14. {
  15. $res = UserAddress::getUserAddress($data['userId'], $data['addressId']);
  16. if (!$res) {
  17. return false;
  18. }
  19. return true;
  20. }
  21. }