You are here

function _postal_code_validation_validate_CL in Postal Code Validation 7

Implements _postal_code_validation_validate_COUNTRYCODE().

File

countries/cl.inc, line 11
Postal code validation functions for Chile.

Code

function _postal_code_validation_validate_CL($postal_code) {
  $return = array(
    'country' => 'CL',
  );
  if (preg_match('/^([1-9][0-9]{2})-?([0-9]{4})$/', $postal_code, $matches)) {
    $return['postal_code'] = $matches[1] . '-' . $matches[2];
  }
  else {
    $return['error'] = t('Invalid postal code. Postal codes in Chile are like "999-9999" and never start with zero.');
  }
  return $return;
}