invalid_postal_code
The postcode is not the shape that country uses
A postcode was given and checked against the country's published pattern, and it does not match: the wrong length, the wrong mix of letters and digits, or a code from another country.
- appears in
- reason
- credits
- Free. An address that cannot stand as written never costs a credit.
What it means
Every country with postcodes publishes the shape they take, and Spaw checks the value against that pattern (`postal_code_valid` reports the same fact on answers that are otherwise valid). A five-digit value in the United Kingdom, a four-digit ZIP, or a Dutch code without its letters all fail here.
This is a check of shape, not of existence: a postcode of the right shape that no directory knows answers `postcode_not_found` instead. Country prefixes some operators print ("NL-1012 JS") are stripped before the check.
What to do
Show the user the postcode that was checked — it is echoed in `postal_code` — and the country it was checked against; the two disagreeing is the usual cause. `postal_code_type` names what that country calls it.
Example response
{
"valid": false,
"reason": "invalid_postal_code",
"country": "US",
"postal_code": "9404",
"postal_code_valid": false,
"postal_code_type": "zip",
"risk_score": null
}Abbreviated: a real answer carries all 33 fields, listed in the validate-phone reference.
Related
- empty_address · nothing in the request was an address
- unknown_country · no postal format is published for that country
- missing_street · the country requires a street line and none was found
- missing_locality · a country with no postcode to name the town was given neither
- missing_administrative_area · a country with no postcodes needs the state or province
- missing_postal_code · the country requires a postcode and none was given
- postcode_not_found · the postcode is well formed but is not in the directory
- All verdict reasons
- Phone fields and the risk score
- API reference
markdown version: /docs/reasons/invalid_postal_code.md