You are here

function _postal_code_validation_validate_DE in Postal Code Validation 7

Implements _postal_code_validation_validate_COUNTRYCODE().

File

countries/de.inc, line 11
Postal code validation functions for Germany.

Code

function _postal_code_validation_validate_DE($postal_code) {
  $return = array(
    'country' => 'DE',
  );
  if (preg_match('/^((?:0[1-46-9]\\d{3})|(?:[1-357-9]\\d{4})|(?:4[0-24-9]\\d{3})|(?:6[013-9]\\d{3}))$/', $postal_code)) {
    $return['postal_code'] = $postal_code;
  }
  else {
    $return['error'] = t('Invalid postal code. Postal codes in Germany are like "99999".');
  }
  return $return;
}