You are here

protected function USPSRateRequest::validateUsaZip in Commerce USPS 8

Utility function to validate a USA zip code.

Parameters

string $zip_code: The zip code.

Return value

bool Returns TRUE if the zip code was validated.

File

src/USPSRateRequest.php, line 166

Class

USPSRateRequest
Class USPSRateRequest.

Namespace

Drupal\commerce_usps

Code

protected function validateUsaZip($zip_code) {
  return preg_match("/^([0-9]{5})(-[0-9]{4})?\$/i", $zip_code);
}