function _postal_code_validation_validate_SE in Postal Code Validation 7
Implements _postal_code_validation_validate_COUNTRYCODE().
File
- countries/
se.inc, line 11 - Postal code validation functions for Sweden.
Code
function _postal_code_validation_validate_SE($postal_code) {
$return = array(
'country' => 'SE',
);
if (preg_match('/^([1-9][0-9]{2}) ?([0-9]{2})$/', $postal_code, $matches)) {
$return['postal_code'] = $matches[1] . ' ' . $matches[2];
}
else {
$return['error'] = t('Invalid postcode. Postcodes in Sweden are like "999 99" and never start with zero.');
}
return $return;
}