function _postal_code_validation_validate_BR in Postal Code Validation 7
Implements _postal_code_validation_validate_COUNTRYCODE().
File
- countries/
br.inc, line 11 - Postal code validation functions for Brazil.
Code
function _postal_code_validation_validate_BR($postal_code) {
$return = array(
'country' => 'BR',
);
if (preg_match('/^([0-9]{5})-?([0-9]{3})$/', $postal_code, $matches)) {
$return['postal_code'] = $matches[1] . '-' . $matches[2];
}
else {
$return['error'] = t('Invalid postal code. Postal codes in Brazil are like "99999-999".');
}
return $return;
}